So, with Lua replacing VBscript, how is the above described process handled by MACH4? Specifically, does MACH4 suspend the G-code execution until macros return or will the programmer still have to test and insert delays to assure this happens?
Secondly, will macros be able to have any legal windows file name and be called by a 'RunScript' (or equiv) call?
simpson36,
First I want to explain the main difference between how mach3 handled Mcodes and how mach4 handles Mcodes. In mach3 every time a Mcode was called from gcode or a RunScript command mach would go find the mcode load that single VB script, compile it and then run it. So in mach3 every mcode was run on its own thread and the only way to have one mcode pass variables to another mcode was through a DRO, LED ect.
Now lets talk about mach4!!
Andrew, thanks for the info. It does help. However, my original question remain:
1) Does MACH4 wait for a return from a 'function' before it parses the next G-code block.
- and-
2) Can 'named' (sorry, I don't know what else to call them) scripts residing in legally named Windows files be called from a 'function'.
Here is an example:
'© 2012 www.theCUBEstudio.com
'NAME: M4011
'ACTION: Runs script to set Lathe mode ON
'USE: embedded macro
If RunScript("\macros\Simpson\4thAxisModeOFF") < 0 Then
MsgBox "RunScript 4thAxisModeOFF returned an error"
End If
The above 'numbered' macro calls the following 'named' macro:
'© 2012 www.theCUBEstudio.com
'NAME: 4thAxisModeOFF
'ACTION: Macro to set Axis mode
'USE: Called From M4011 - embed in Gcode
'NOTE 'unconditionally enables 4th axis - built from 4thAxisModeSWITCH macro
Style1 = 4 + 32 '4=display Yes and NO buttons only 32 = Question Icon
Style2 = 0 + 48 '0= display OK button only 48=Exclamation Icon
GoFlag = true
DriveDisabled = GetUserLED(1003)
IndexON = GetUserLED(1004)
SpindleON = GetUserLED(1005) + GetUserLED(1006) 'Either Spindle ON CW or CCW will = true
CurrentRPM = GetUserDRO(1003)
' activate Turn MODE
If (DriveDisabled = 1) Then ' drive is disabled, enable drive
If RunScript("\macros\Simpson\4thEnableON") < 0 Then
MsgBox "RunScript 4thEnableON returned an error"
End If
End If
SetUserLED(1004,0) ' Index Mode LED OFF
SetModOutput(4,1) ' set INDEX mode OFF thru Modbus
Sleep(300)
sleep(20)
The larger 'named' macro is in the windows file 'c:\MACH3\macros\Simpson\4thIndexModeOFF.m1s'. The delays are primarily to allow enough time for the Modbus to finish processing. Because of the time involved to execute, this macro is problematic to run directly as an 'M*********' macro because MACH3 would be off and crunching thru the next several G-code blocks before the macro completes.
So, if any of the above makes sense, can anyone either answer the two questions above or perhaps just describe how to duplicate this functionality in MACH4?
Much appreciated!
simpson36,
To try to answer your question.
1. Yes mach will wait for a return before executing the next block
2. You can use named like 4thAxisModeOFF.mcs and then in your M4011 you could call the script with 4thAxisModeOFF().
When you make your scripts make sure you name the script the same name as the function in the script.
Scott - The range is the pulley range, and in mach4 each range has it own accel and decel parameters.
Andrew
MachMotion