Hello, I am new here and new to gcodes and hoping to find some help.
What I'm trying to do via gcode write and string of letters and numbers to a .txt file using M120 and after each M120 use a .bat command file to read the string and use it as a variable to then associate it with .png file to display it, this even happens in several locations during the length of the gcode,
The problem is that the .txt file seams to be written at the end of the cycle so only the last M120/122 is recorded and the command calls the .dat file several more times than is called.
any suggestions? what am I missing.
M CODES!
Moderator: cnckeith
-
- Posts: 11
- Joined: Fri Aug 20, 2021 10:47 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: 402E71D16818-0414214669
- DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
Re: M CODES!
[]this is how my .bat file looks like.
@echo off
FOR /F "tokens=* delims=" %%I in (C:\cncm\ncfiles\prtLABEL.txt) do (SET imagen=%%~nI)
Set MyVar=%imagen%
set MyVar=%MyVar: =%
"C:\Users\FileEXAMPLE\OutSide_K_Image\%MyVar%.bmp"
PAUSE
@echo off
FOR /F "tokens=* delims=" %%I in (C:\cncm\ncfiles\prtLABEL.txt) do (SET imagen=%%~nI)
Set MyVar=%imagen%
set MyVar=%MyVar: =%
"C:\Users\FileEXAMPLE\OutSide_K_Image\%MyVar%.bmp"
PAUSE
- Attachments
-
- atest.cnc
- (907 Bytes) Downloaded 66 times
-
- prtLABEL.txt
- (11 Bytes) Downloaded 68 times
Last edited by ART on Fri Sep 10, 2021 12:36 pm, edited 1 time in total.
-
- Posts: 667
- Joined: Fri Nov 30, 2018 1:04 pm
- Acorn CNC Controller: Yes
- Plasma CNC Controller: No
- AcornSix CNC Controller: No
- Allin1DC CNC Controller: No
- Hickory CNC Controller: No
- Oak CNC controller: No
- CNC Control System Serial Number: none
- DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
- Location: Thorp WI
Re: M CODES!
Not sure if I'm following you exactly, but each time M120 is passed, it will close the previous file and open a new one, overwriting the existing one. So you'll only get the last value. You might need to use a M00, M01, or M224/225 to wait for the bat file to do it's thing. There's also a L1 parameter for M130, but not sure what the outcome for that is, meaning can you continue after the shell command.
Others may chime in here, but we might need the whole file set to test along with you.
Others may chime in here, but we might need the whole file set to test along with you.
Scott
-
- Posts: 11
- Joined: Fri Aug 20, 2021 10:47 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: 402E71D16818-0414214669
- DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
Re: M CODES!
Yes!, thanks for your help, in fact every time M120 is called M125 writes the text and M150 is immediately call to execute the information, then the machine moves to a different coordinate and does it all again.
regardless of what I do I only get the last call and .bat is called 3 times at once.
regardless of what I do I only get the last call and .bat is called 3 times at once.
-
- Posts: 11
- Joined: Fri Aug 20, 2021 10:47 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: 402E71D16818-0414214669
- DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
Re: M CODES!
I just updated my atest.cnc file to reflect a little better the real work it does or should do, hopefully.Sword wrote: ↑Fri Sep 10, 2021 12:24 pm Not sure if I'm following you exactly, but each time M120 is passed, it will close the previous file and open a new one, overwriting the existing one. So you'll only get the last value. You might need to use a M00, M01, or M224/225 to wait for the bat file to do it's thing. There's also a L1 parameter for M130, but not sure what the outcome for that is, meaning can you continue after the shell command.
Others may chime in here, but we might need the whole file set to test along with you.
Re: M CODES!
You might also need to put additional M120 calls between each operation.
For example:
By using M120 to open a different file, you force CNC12 to flush and close the one that it previously had open. That should ensure that the contents have been written by the time you call M130.
For example:
Code: Select all
M120 "dummy.txt"
-
- Posts: 11
- Joined: Fri Aug 20, 2021 10:47 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: 402E71D16818-0414214669
- DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
Re: M CODES!
yep, tried that and I'm still getting 3 extra .bat running at the same time for the first iteration and 1 for the second.cncsnw wrote: ↑Fri Sep 10, 2021 12:50 pm You might also need to put additional M120 calls between each operation.
For example:By using M120 to open a different file, you force CNC12 to flush and close the one that it previously had open. That should ensure that the contents have been written by the time you call M130.Code: Select all
M120 "dummy.txt"
thanks for your help, I'm looking forward to find this bug and kill it.
-
- Posts: 373
- Joined: Fri Jan 10, 2014 11:29 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: none
- DC3IOB: Yes
- CNC12: Yes
- CNC11: Yes
- CPU10 or CPU7: Yes
- Location: Howard, PA
Re: M CODES!
Are your runtime graphics on (parameter 150)? The plot is executing the .bat file extra times.
Try opening your file again with M121 before M130 to flush the data.
Also try M130 L1 command with a pause in the .bat to get a better idea when the command is actually running.
-
- Posts: 11
- Joined: Fri Aug 20, 2021 10:47 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: 402E71D16818-0414214669
- DC3IOB: No
- CNC12: Yes
- CNC11: No
- CPU10 or CPU7: No
Re: M CODES!
*** Please advice me with syntax on the M130 L1.. I've not used it before, would you post an example of how to, please.eng199 wrote: ↑Fri Sep 10, 2021 3:53 pmAre your runtime graphics on (parameter 150)? The plot is executing the .bat file extra times.
Try opening your file again with M121 before M130 to flush the data.
Also try M130 L1 command with a pause in the .bat to get a better idea when the command is actually running.
thanks
*** I'm displaying a .bmp file
-
- Posts: 373
- Joined: Fri Jan 10, 2014 11:29 am
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: Yes
- Oak CNC controller: Yes
- CNC Control System Serial Number: none
- DC3IOB: Yes
- CNC12: Yes
- CNC11: Yes
- CPU10 or CPU7: Yes
- Location: Howard, PA
Re: M CODES!
Just toss an L1 in there like so:
M130 L1 "C:\cncm\ncfiles\print.bat"
page 13-16 in the v3.16 Mill manual I was looking at
M130 L1 "C:\cncm\ncfiles\print.bat"
page 13-16 in the v3.16 Mill manual I was looking at