Digital Dream Technology support

Title: Save current coords to file [Print This Page]

Author: cnc-kursk    Time: 2018-11-26 20:34
Title: Save current coords to file
Hello.

I need to write script for scanning surface by touch probe.
May I save touching coordinates to file?

It is possible?
Will it possible in new firmware versions?



Author: ytliu    Time: 2018-11-26 21:07
Currently, this function is not supported by the system. If you need to save the coordinates to a file, does the file name have a fixed name? Can you provide more detailed examples?
Author: cnc-kursk    Time: 2018-12-13 14:58
File name does not matter. I need to add current coordinates to a file by G-code command. I can write a script in a loop to get the coordinate cloud of the object. Format of records - comma delim X,Y,Z then new line. Next G-Code append next line in file.

Author: cnc-kursk    Time: 2018-12-13 15:08
Autoleveling, like this:
https://youtu.be/6WNE3E1ZZYY?t=530

Author: cnc-kursk    Time: 2019-3-12 22:10
UP. Any suggestions?
Author: Will_D    Time: 2019-3-13 18:23
Welcome back ytliu, we have missed you
Author: edelec    Time: 2019-3-14 03:21
Wiil, He is not back check the date on the post! Support is now zero!
Richard
Author: ytliu    Time: 2019-3-14 07:02
I can provide you with a macro function, such as recordc. When using it in G code, the system will append the current coordinate information to a specific file. I don't know if this will meet your requirements.
Author: 71taa    Time: 2019-3-14 11:31
Hi, ytliu! Glad to see you

For me appending coorinate information in file (incremental, until file exists or with createNew/reinit macro) is enough to perform simple scanning operations. All other things (like coordinate formats, etc) could be done via external conversion. It's useful both for creating height maps (like one topic starter is requested, e.g. for external compensation of PCB unevenness), or even full-fledged point clouds to use CNC as an express 3d scanner (e.g. for later engraving on complex surfaces).


Author: ytliu    Time: 2019-3-14 12:46
Sorry,  due to the illness of my wife , I did not respond in time recentely.
Hi 71taa,Thank you for your suggestion. Could you explain your ideas more detail?
Author: 71taa    Time: 2019-3-15 09:49
Last edited by 71taa In 2019-3-15 10:24 Editor

It's only my opinion, maybe the topic starter has more specific requirements.
1. The scanning G-code is being formed by users. It's up to them to define the scanning strategy, speeds, etc - in a standard G-code way
2. In the place users like to capture the coordinates, they place the call to the 'scanning macro', which works similar to probing macro (moves down, senses the probe, stops, falls back off). The coordinates of the touch point should be captured. In case if coordinates are being stored in some internal variable - we even could use standard probing macros for this stage.
In order to not overengineer things here we could assume that scanning macro always works only with Z coordinate. It's fine for majority of CNC schemes and typical appliances like levelling over uneven surfaces. Also (as we already have 3 modes of probing, and one of them is a 'custom' one)
we can use probing functionality itself, yet you have a better view of the controller capabilities and limitations.
3. Then coordinates should be stored sequentially into the file. If we have them in some variable - it could be separate call to "coordinate saving" macro. In case if we have integrated 'scanning macro' - as a part of its call
4. The format of coordinate storage in the file isn't that important, it's good to have all 4 coordinates (maybe someone needs only 3) and some delimiter between them. E.g.:
102.131;14.145;16.14;35.5
112.131;14.145;16.14;35.5
5. Why the format isn't that important comparing to the data itself? Because different external software have their own requirements and it's impossible to meet them all. So it's more efficient to post-process generated data with simplest software converter then define a lot of configuring options to the controller.
6. It's near all, except the file handling. Again we need to be minimalistic here, as a complex file handling could bring a lot of setting options, and instead of flexibility users can face difficulties.
6.1 Here we need the file definition itself (name and location). At the very minimum it could be hardcoded (in the controller) location and name on the external drive and won't be configurable by users. At maximum it could be a parameter of the macro if the controller script processing capabilities allows that. And anyting in between (like configurable location via controller settings, etc).
6.2 Probably it's good to have another macro "start/init scanning" that clears the file in the (defined) location as a preparation for a new cycle. It could be placed by users in their scanning code to form self-contaned scanning code. It will increase usabilitiy of the solution, less errors with uncontrollable growth of the file
6.3 And the last, but not least - the limitations of this solution. In case if we have some hardware limitations (size of the file, number of stored coordinates, etc) - either include them in the description and/or check limits internally, stopping capturing the coordinates as the limit is reached.


For me personally single macro for incremental writing of current coodinates on call is enough (without probing subsequence, etc). As I've tried to use HID emulating controller for simple automation and it's rather convenient (though not that reliable, as I have no feedback from the controller of course). So it will be an external control of manual DDCSV movements in step mode via "keyboard" commands (it could be done via MPG port as well), external touch probe hit detection, call to the "store coordinates" macro via extkey macro call followed by the external switching of the key2, etc. But that's clearly not a standard use




Author: ytliu    Time: 2019-3-15 17:09
Hi,71taa!
Thank you for your proposal. After I have integrated the opinions of Mr. cnc-kursk, I will confirm the solution and ask for your suggestions.
Author: stivemaster    Time: 2019-3-17 05:49
Last edited by stivemaster In 2019-3-17 05:53 Editor

This is of course very useful. Let's say you want to scan an area of 100mm by X and 100 by Y over 5mm in order to have an unevenness to compensate it. Then the controller should stretch the sample 100 times and record the value of the variable showing the height at the touch (although Z passes this point due to the stop ramp). This value should be in XYZA format separated by a comma.
Author: ytliu    Time: 2019-5-3 20:34
In the attachment, I added two macro functions:
1.RecordCoords[], which can append 4 floating point numbers to the specified file on the USB flash drive. The first parameter is the file serial number, and the next 4 parameters are the recorded data.
E.g:
RecordCoords[3,10.2,5.3,0,0]
"10.2000, 5.3000, 0.0000, 0.0000" will be added to the "ProbeMap3.txt" file of the USB flash drive.
2.ClearCoords[], used to clear the contents of the coordinate file.
E.g:
ClearCoords[2]
The contents of the "ProbeMap2.txt" file of the USB flash drive will be erased.

I think that using these two macro functions, as well as the macro variables associated with the coordinate system, should be able to implement the function of plane probe.



DDCSV Coordinate System Description:

The coordinate systems in DDCSV system include machine coordinate system, G53 coordinate system and G54-G59 coordinate system.

The machine coordinate system is established by home operation or zero under MACH. Read # 864- # 867 (X, Y, Z, A) to get the position in the machine coordinate system.

G53 is based on the machine coordinate system. # 800- # 803 (X, Y, Z, A) describes the distance from the origin of the G53 coordinate system to the origin of the machine coordinate system. Adjusting these parameters can reconstruct the G53 coordinate system. Read # 868- # 871 (X, Y, Z, A) to get the position in G53.

The G54-G59 coordinate system is based on the G53 coordinate system. # 804- # 807 (G54 X, Y, Z, A), # 808- # 811 (G55 X, Y, Z, A), # 812- # 815 (G56 X, Y, Z, A), # 816- # 819 (G57 X, Y, Z, A), # 820- # 823 (G58 X, Y, Z, A) , # 824- # 827 (G59 X, Y, Z, A) respectively describe the distance from the origin of G54-G59 coordinate system to the origin of G53 coordinate system, and you can adjust these parameters to reconstruct the G54-G59;

Read #840-#843(G54 X、Y、Z、A)、#844-#847(G55 X、Y、Z、A)、#848-#851(G56 X、Y、Z、A)、#852-#855(G57 X、Y、Z、A)、#856-#859(G58 X、Y、Z、A)、#860-#863(G59 X、Y、Z、A) to get the position in G54-G59.

#516 describes the system currently working coordinate system, 0 corresponds to the G53 coordinate system, 1-6 corresponds to the G54-G59 coordinate system, 7 corresponds to the machine coordinate system.

Reading #699-#702 can get the coordinates in the current workpiece coordinate system.

test.zip

294 Bytes, Down times: 1037

install.zip

586.4 KB, Down times: 1715


Author: ytliu    Time: 2019-5-4 08:49
this is script for scanning surface by touch probe.You can modify the parameters in this file (#2038-#2047) to customize it. You can also add these parameters to the parameter file (such as eng) so that you can modify it on the parameter page.

scanning_surface.nc content:
O0001(Probe subroutine)
G90G0Z#2044
M101
G91G01Z-#2045F#2046
M102
G04P0
RecordCoords[#2047,#699,#700,#701,#702]
G90G0Z#2043
M99

O0000
#2038=5;Steps every
#2039=0;X-axis start at
#2040=0;Y-axis start at
#2041=100;X-axis end at
#2042=50;Y-axis end at
#2043=3;Clearance height
#2044=0.5;Start probing
#2045=1;Max probe distance
#2046=50robe feedrate
#2047=1;Record file serial number

ClearCoords[#2047]

G0Z#2043
G0X#2039Y#2040

IF [#2041-#2039]>=0 GOTO1
#1=-#2038
GOTO2
N1 #1=#2038
N2 IF [#2042-#2040]>=0 GOTO3
#2=-#2038
GOTO4
N3 #2=#2038
N4 #3=[#2041-#2039]/#1
#4=[#2042-#2040]/#2
#6=0

N5 #6=#6+1
#5=0
N6 #5=#5+1
M98P0001
IF #5>#3 GOTO7
G91G0X#1
GOTO6
N7 IF #6>#4 GOTO8
#1=-#1
G91G0Y#2
GOTO5
N8 G90G0X#2039Y#2040
M99



scanning_surface.zip

580 Bytes, Down times: 2128


Author: 71taa    Time: 2019-5-6 17:05
Thanks, Ytliu - you are the best!
I'll test those routines on nearest holidays
Author: ytliu    Time: 2019-5-6 18:38
thank you. If the DDCS processing speed is sufficient, I am going to try to increase the auto level function on the DDCSV.
Author: Robchiks    Time: 2021-2-22 22:35
Last edited by Robchiks In 2021-2-26 17:36 Editor


Author: mellbo    Time: 2021-10-24 03:28
Last edited by mellbo In 2021-10-24 03:32 Editor

this one(motion.out) work with the DDCSV3.1 or not ?
i need autolevel for PCB milling...
how can I do that ?...
can you made one motion.out with this macro for the DDCSV3.1 with curent version firmware ?





Welcome Digital Dream Technology support (http://bbs.ddcnc.com/) Powered by Discuz! X3