Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: BR549 on July 20, 2010, 12:25:00 AM
-
Here is some code to play with for an Auto Batch Loader This idea came from another thread(ya-nvr-no) I just brought it here to expand on the idea (;-)
'Auto Batch Loader
Dim fname1,fname2,fname3,fname4,fname5 As String
Dim F1offset,F2offset,F3offset,F4offset,F5offset As Double
fname1 ="c:\mach3\gcode\" & AskTextQuestion("File#1 Name?")
F1offset= "" & Question("File#1 Offset#")
Message(Fname1 & " AND G" & F1offset)
fname2 ="c:\mach3\gcode\" & AskTextQuestion("File#2 Name?")
F2offset= "" & Question("File#2 Offset#")
Message(Fname2 & " AND G" & F2offset)
fname3 ="c:\mach3\gcode\" & AskTextQuestion("File#3 Name?")
F3offset= "" & Question("File#3 Offset#")
Message(Fname3 & " AND G" & F3offset)
fname4 ="c:\mach3\gcode\" & AskTextQuestion("File#4 Name?")
F4offset= "" & Question("File#4 Offset#")
Message(Fname4 & " AND G" & F4offset)
fname5 ="c:\mach3\gcode\" & AskTextQuestion("File#5 Name?")
F5offset= "" & Question("File#5 Offset#")
Message(Fname5 & " AND G" & F5offset)
For x = 1 To 5
If x = 1 Then loadfile(fname1)
While Isloading()
Sleep(1000)
Wend
If X = 1 Then Code"G" & F1offset
Sleep(1000)
If x = 2 Then loadfile(fname2)
While Isloading()
Sleep(1000)
Wend
If X = 2 Then Code"G" & F2offset
Sleep(1000)
If x = 3 Then loadfile(fname3)
While Isloading()
Sleep(1000)
Wend
If X = 3 Then Code"G" & F3offset
Sleep(1000)
If x = 4 Then loadfile(fname4)
While Isloading()
Sleep(1000)
Wend
If X = 4 Then Code"G" & F4offset
Sleep(1000)
If x = 5 Then loadfile(fname4)
While Isloading()
Sleep(1000)
Wend
If X = 5 Then Code"G" & F5offset
Sleep(1000)
Message(filename)
While Isloading()
Sleep(5000)
Wend
runfile()
Sleep(2000)
While IsMoving()
Sleep(2000)
Wend
'Insert STOP code here
Next x
Message("thats all folks")
End
-
Dim fname1,fname2,fname3,fname4,fname5 As String
Dim fn1WO,fn2WO,fn3WO,fn4WO,fn5WO As Single
fname1 ="c:\mach3\gcode\" & AskTextQuestion("File#1 Name?")
fn1WO= "" & Question("File#1 Work Offset#")
Message(Fname1 & " AND G" & fn1WO)
fname2 ="c:\mach3\gcode\" & AskTextQuestion("File#2 Name?")
fn2WO= "" & Question("File#2 Work Offset#")
Message(Fname2 & " AND G" & fn2WO)
fname3 ="c:\mach3\gcode\" & AskTextQuestion("File#3 Name?")
fn3WO= "" & Question("File#3 Work Offset#")
Message(Fname3 & " AND G" & fn3WO)
fname4 ="c:\mach3\gcode\" & AskTextQuestion("File#4 Name?")
fn4WO= "" & Question("File#4 Work Offset#")
Message(Fname4 & " AND G" & fn4WO)
fname5 ="c:\mach3\gcode\" & AskTextQuestion("File#5 Name?")
fn5WO= "" & Question("File#5 Work Offset#")
Message(Fname5 & " AND G" & fn5WO)
For x = 1 To 5
If x = 1 Then loadfile(fname1)
If x = 2 Then loadfile(fname2)
If x = 3 Then loadfile(fname3)
If x = 4 Then loadfile(fname4)
If x = 5 Then loadfile(fname5)
While Isloading()
Sleep(5000)
Wend
If x = 1 Then Code"G" & fn1WO
If x = 2 Then Code"G" & fn2WO
If x = 3 Then Code"G" & fn3WO
If x = 4 Then Code"G" & fn4WO
If x = 5 Then Code"G" & fn5WO
Message(filename)
Sleep(2000)
runfile()
Sleep(2000)
While IsMoving()
Sleep(2000)
Wend
Next x
Message("thats all folks")
End
-
(;-) Lookin Mighty FINE . I ran it for hours on end last night (;-) It was still running this morning. I also tested what would happen IF you did not need the total number files(;-) only needed 3 file instead of 5. that work fine as well. just enter throught the rest of the questions and set the defaults.
So you could actually create a macro that did say 10 files. OR perhaps could create the number of files on the fly that you need to run??
Just a thought
-
We do need an excape routine from the program though. (;-)
-
While IsMoving()
Sleep(2000)
(somewhere here exit script if reset pushed)
Wend
I think we Need to get the Brain involved here somehow
-
It would be best IF you can do a gracefull exit and it ALL be self contained in the one script. AND it NOT be a wait loop.
You can exit easy BUT then it attempts to run the NEXT program in line. AND you have to deal with the Gcode side as well as the VB side. SOmetimes they don't play nice together when you try to stop and it locks up mach.
-
OK here are a few twqeaks to the routine. The Work Offsets are in G59P### format so you can use any of the 255 available. Also a tweak to allow the program to cycle through tool changes.
Now this works with programs that can run unattended. To stop the batch just feedhold/stop and that will cancel the batch and end the Batchload. To restart simply reload the batch from scratch. DO NOT FEEDHOLD unless you are cancelling the batch. There is an internal call from the Feedhold that will MESS up the WorkOffsetting big time.
I set this up as a button script and call the button AutoBatchLoader
NOTE: for this to work correctly you need to add this statment to your M1030 macro.
SetVar(601,0)
AUTO BATCH LOADER CODE **************************************************
' AutoBatchLoader macro
Dim fname1,fname2,fname3,fname4,fname5 As String
Dim F1WO,F2WO,F3WO,F4WO,F5WO As Single
fname1 ="c:\mach3\gcode\" & AskTextQuestion("File#1 Name?")
F1WO= "" & Question("File#1 Offset in G59 P### Format")
Message(Fname1 & " AND G59 P" & F1WO)
fname2 ="c:\mach3\gcode\" & AskTextQuestion("File#2 Name?")
F2WO= "" & Question("File#2 Offset in G59 P### Format")
Message(Fname2 & " AND G59 P" & F2WO)
fname3 ="c:\mach3\gcode\" & AskTextQuestion("File#3 Name?")
F3WO= "" & Question("File#3 Offset in G59 P### Format")
Message(Fname3 & " AND G59 P" & F3WO)
fname4 ="c:\mach3\gcode\" & AskTextQuestion("File#4 Name?")
F4WO= "" & Question("File#4 Offset in G59 P### Format")
Message(Fname4 & " AND G59 P" & F4WO)
fname5 ="c:\mach3\gcode\" & AskTextQuestion("File#5 Name?")
F5WO= "" & Question("File#5 Offset in G59 P### Format")
Message(Fname5 & " AND G59 P" & F5WO)
For x = 1 To 5
If x = 1 Then loadfile(fname1)
While Isloading()
Sleep(1000)
Wend
If X = 1 Then Code"G59 P" & F1WO
Sleep(1000)
SetVar(601,1)
Sleep(1000)
If x = 2 Then loadfile(fname2)
While Isloading()
Sleep(1000)
Wend
If X = 2 Then Code"G59 P" & F2WO
Sleep(1000)
SetVar(601,1)
Sleep(1000)
If x = 3 Then loadfile(fname3)
While Isloading()
Sleep(1000)
Wend
If X = 3 Then Code"G59 P" & F3WO
Sleep(1000)
SetVar(601,1)
Sleep(1000)
If x = 4 Then loadfile(fname4)
While Isloading()
Sleep(1000)
Wend
If X = 4 Then Code"G59 P" & F4WO
Sleep(1000)
SetVar(601,1)
Sleep(1000)
If x = 5 Then loadfile(fname4)
While Isloading()
Sleep(1000)
Wend
If X = 5 Then Code"G59 P" & F5WO
Sleep(1000)
Setvar(601,1)
Sleep(1000)
Message(filename)
While Isloading()
Sleep(5000)
Wend
runfile()
Sleep(2000)
While Getvar(601)=1
Sleep(2000)
Wend
If Getvar(601)=1 Then End
Next x
Message("End Of Batch Load")
End