Hello Guest it is March 29, 2024, 06:45:44 AM

Author Topic: Using G-code files in Button Scripts  (Read 24897 times)

0 Members and 1 Guest are viewing this topic.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Using G-code files in Button Scripts
« Reply #10 on: August 12, 2011, 10:22:28 PM »
Gerry same here, (;-) TP
Re: Using G-code files in Button Scripts
« Reply #11 on: August 13, 2011, 06:43:57 AM »
32 bit is the standard.

(;-) TP

Thanks for stating the obvious.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Using G-code files in Button Scripts
« Reply #12 on: August 13, 2011, 12:29:52 PM »
(;-) IF it is so obvious why are people still trying to run 64 bit?

(;-) TP
Re: Using G-code files in Button Scripts
« Reply #13 on: August 13, 2011, 02:40:53 PM »
Thanks for your input everyone but I still cannot get anything to work.  The G-code file I was trying to use originally was fairly long so I just created a really simple file to test things out :

%
% Test Pogram 1
%
G91   (RELATIVE MOVEMENT)
G0 X1 Z2   (MOVE TOOL)
M2   (END)

I saved this in a new folder under Mach3 then created a "Test" button on one of the screens in Mach3Turn to load and run the file:

LoadFile("C:\Mach3\User GCodes\Test Program 1.txt")
RunFile()

The file is clearly loading because it appears in the G-code listing.  Also, when I use the normal "Cycle Start" button the program runs and the axes move.  However when I hit the "Test" button the "Please Wait - Generating Path" message flashes and nothing else happens.

I have tried While IsLoading() Wend between LoadFile and RunFile, I have tried Sleep(1000) as well, I have even tried loading the roadruner.tap file as suggsted and that does not work either.

If I put  Code "G0 X1 Z2" as script in the button it does what I intended!

Gerry; what is the PP driver you mentioned? It looks as if there is something missing in my setup?

J

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Using G-code files in Button Scripts
« Reply #14 on: August 13, 2011, 02:51:34 PM »
What version of Mach3 are you using?
What OS are you using?
When you installed Mach3, did you install the parallel port driver?
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Using G-code files in Button Scripts
« Reply #15 on: August 13, 2011, 03:55:27 PM »
OK did some testing here V.038.  NO LPT driver loaded

LoadFile("C:\mach3\gcode\testprogram.txt")
While Isloading()
Sleep(1000)
Wend
RunFile()

This will run fine here EXCEPT it is VERY dependant on the Sleep Value. Get it too short and it blows right by the Runfile() and does NOT start the program. IF I test with a large Gcode file the value need to be larger as well or it fails to start.

LoadRun("C:\mach3\gcode\testprogram.txt")

LoadRun() Loads the program BUT FAILS to start the program . It Fails EVERY time.  That tells me there is a serious problem  as it blows right by the start command IN a system script as well as the macro script. There is no way to add a wait state in the SYS script(;-)

(;-) TP


« Last Edit: August 13, 2011, 03:57:27 PM by BR549 »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Using G-code files in Button Scripts
« Reply #16 on: August 13, 2011, 04:27:40 PM »
Retested with the new improved dev verison .044

Same Problem no change

(;-) TP
Re: Using G-code files in Button Scripts
« Reply #17 on: August 13, 2011, 09:43:11 PM »
Thanks again guys. For developing programs I am running R3.043.022 (the latest version?) on my laptop using Windows XP, my lathe has R.042.029 running on Windows 7 but behaviour is essentially the same.

After trying things over again it does seem that as BR549 says, the Sleep() part is critical:

LoadFile() - Runfile()       does not work

Loadfile() - While IsLoading() - Wend - Runfile()  does not work either

LoadFile() - Sleep(1000) -  Runfile()       does work  

Loadfile() - While IsLoading() - Sleep(1000) - Wend - Runfile()  also works but no better than the previous set of instructions

I thought that I had tried last two approaches prevously but without success - maybe something else was wrong.

I have checked different sleep times and Sleep(300) (300ms?) is the minimum to load the few lines in my test program.  

Anyway, with your help my problem appears to be solved, although the sleep time will presumably have to be extended for longer programs.  Unfortunately it also appears that the manual does not give the whole story on what is required for loading and running files.

J

  

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Using G-code files in Button Scripts
« Reply #18 on: August 13, 2011, 10:06:14 PM »
Someone should mention to Brian that the While IsLoading is broken, so he can fix it.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Using G-code files in Button Scripts
« Reply #19 on: August 15, 2011, 12:17:35 PM »
I have played around some more and I think I understand what is going on a little better:

When one uses LoadFile() it not only loads the file but goes through quickly (ignoring M0/M1 stops and all time constraints) to check for errors, to generate a toolpath and probably do some other things. The latter part seems to take much longer than the actual loading.  Putting in a sufficiently long Sleep command allows one to see all of this happening. If the Sleep time is not sufficient and RunFile() kicks in before the loading + other processes are complete, then the RunFile() command is ignored. 

This is fine when developing the program because it throws up any errors, however once everything is working OK it results in an irritating delay while the system does its checks.   A "Cancel" button comes on the "Please Wait - Generating Path" display but there does not seem to be a way of programing this to cut out the delay.

Any ideas?

J