I'm trying to develop a plugin to 3D scanning a relief.
It will implement a linear laser scanning procedure (parallel scanning to X axis and after each line it will move the Y axis).
I'm going to used a laser measure sensor that will measure the distance between the sensor itsel and the relief surface.
The sensor will be wired to an Arduino. The Arduino will read the analog input from the sensor and it will send the data to the PC.
The PC-Arduino communication is done using SerialPort .net component.
The plugin is quite complete ad the moment. I made a testing setup with an arduino that will spam random value to the PC and I'm using UCCNC in demo mode!
So in the end the sensor will send to the PC the distance data will the CNC head is moving, and the code will gather the Z value from the sensor, the X Y value from the UCCNC core and it will save this value in a file.
At this point what I want to improve before start making real scanning procedure is the collecting data transfer rate.
The main loop_event is called 2time per second, aka 25Hz. About 40ms between each loop.
The sensor is able to produce a correct measure in less tha 10ms, the response time is 5ms. About 8 times faster that the main loop_event.
Measuring the arduino capability I'm able to collect a value each 5-6ms.
Thanks for reading this Wall of text
any help is appreciate!
To surpass the speed of the loop_event I attached a dataRecived_Event to the serialPort object and now I'm able to collect the data from the arduino-sensor baiscally ad the same speed the arduino can generate is (as I said before about 5-6ms).
But now I have a "problem" with the x,y coordinate values that I collect form the plugininterface.
The code I use to get the x y coordinates is
- Code: Select all
double xpos = UC.GetXpos();
double ypos = UC.GetYpos();
and the generate file is something like this (first 3 value are the coordiante the last 3 value are the color of the point)
- Code: Select all
2,81 0 8,1 68 68 68
2,81 0 7,8 66 66 66
2,81 0 7,8 66 66 66
2,81 0 8,1 68 68 68
3,15 0 8,1 68 68 68
3,15 0 7,8 66 66 66
3,15 0 7,8 66 66 66
3,15 0 8,4 71 71 71
3,15 0 8,1 68 68 68
3,15 0 7,8 66 66 66
3,15 0 8,1 68 68 68
3,495 0 8,4 71 71 71
3,495 0 8,1 68 68 68
3,495 0 7,8 66 66 66
3,835 0 8,1 68 68 68
3,835 0 8,4 71 71 71
as you can see there are a loot of duplicate value for the X axis. I think this is caused by the main loop_event that is called at 25Hz and the x,y values that are get from my code are updates at the rate of the main loop_event.
The final question is the follow: is it possibile to get THE REALTIME position of the CNC?
I mean the realtime values from the UCCNC core and not the 25hz updated values?
If I could do this my scanning time will be much lower.