(→System Timing) |
(→System Inputs and Outputs) |
||
Line 217: | Line 217: | ||
=== System Inputs and Outputs === | === System Inputs and Outputs === | ||
+ | |||
+ | ==== serialioout "a",["1/0"] ==== | ||
+ | Control output a on the serial IO controller. "1" turns on the output and "0" turns it off. | ||
+ | |||
+ | Example: | ||
+ | serialioout "5","1" | ||
+ | |||
+ | ==== serialioin("a") ==== | ||
+ | Return the value of an input on the serial io controller. will return true or false. | ||
+ | |||
+ | Example: | ||
+ | if serialioin("4")=true then messagetop("Serial 4 is on") | ||
+ | |||
+ | ==== ioout "#",["1/0"] ==== | ||
+ | Control output # on the parallel io board. "1" turns on the output and "0" turns it off. | ||
+ | The outputs will not return to defaults after the SAC program is done running. | ||
+ | |||
+ | Example: | ||
+ | ioout "3","1" | ||
+ | |||
+ | ==== ioin (a) ==== | ||
+ | Return the value of an input on the parallel io board. will return true or false. | ||
+ | |||
+ | Example: | ||
+ | if ioin (4) = true then messagetop "4 is ON",2 ELSE messagetop "4 is OFF",2 | ||
+ | |||
+ | NOTE The ()s in ioin versus the lack of () for ioout. The examples are correct, follow them. | ||
+ | |||
+ | ==== homeinp("a") ==== | ||
+ | Return true if a limit switch input is triggered. Values can be X,Y,Z,A as or 0 thru 7 (y=0,x=1,z=2,a=3, if you wish to access the "overtravel" inputs (really just inputs for whatever you want), use numbers 4-7) | ||
+ | |||
+ | Examples: | ||
+ | <pre>if homeinp("x") then msgbox("X is on the switch!")</pre> | ||
+ | <pre> | ||
+ | if homeinp("5") =TRUE then | ||
+ | MESSAGETOP "Home input 5 is triggered!",2 | ||
+ | ELSE | ||
+ | MESSAGETOP "Home input 5 is NOT triggered!",2 | ||
+ | <pre> | ||
+ | |||
+ | Note: Quotes around "X" are NECESSARY, quotes around "5" are not. When you use a number, you are checking the number, when you pass an axis letter, the script interprets x as a variable and not an axis name. | ||
+ | |||
+ | ==== routeron ==== | ||
+ | Turns on the spindle output of the system | ||
+ | |||
+ | Example: | ||
+ | <pre>routeron</pre> | ||
+ | |||
+ | ==== routeroff ==== | ||
+ | Similar to routeron but this function turns off the spindle output. | ||
+ | |||
+ | ==== routerauto ==== | ||
+ | Sets the spindle mode to auto, which will be most useful when running gcode files which turn the spindle on and off from within. | ||
+ | |||
+ | ==== routerrpm(#) ==== | ||
+ | Changes the RPM of the spindle if the appropriate speed-changing hardware is present. | ||
+ | |||
+ | Example: | ||
+ | <pre>routerrpm(15000)</pre> | ||
+ | |||
+ | ==== auxon ==== | ||
+ | Turns on the aux output, usually reserved for coolant. | ||
+ | |||
+ | ==== auxoff ==== | ||
+ | inimical to auxon, this function turns off the aux/coolant output. | ||
+ | |||
+ | ==== auxauto ==== | ||
+ | Sets the aux/coolant output to auto, useful for when running gcode which triggers the coolant output on its own. | ||
=== G-code === | === G-code === |
Revision as of 10:24, 7 December 2010
|
SAC is short for Servo Automation Control, and is a scripting language that can be used to control the router. The syntax is Visual Basic.
Contents
How to use this document
When you encounter [variable/options], the proper syntax is to remove the [].
When you encounter "value", leave the quotes in
When you encounter (value), leave the ()s in, though you don't always need them.
When passing multiple numbers to a function that seems to take ()s, the following rule applies:
- function x,y,z
- function (x),(y),(z)
- function (x),,(z)
- function (x),y,(z)
- NEVER function (x,y,z)
- NEVER function (x),(),(z)
All established VBscript commands are also usable, use your favorite search engine with the term "vbscript functions" to get an up-to-date list of functions and examples. Currently, one such list is at http://www.w3schools.com/VBscript/vbscript_ref_functions.asp or http://msdn.microsoft.com/en-us/library/t0aew7h6(VS.85).aspx
Good VBscript Practice
Goto and gosubs are no longer available. Use public functions and subs to do your branching. If you wrap your entire program in one outer function, it is possible to "end" the program early upon finding an error, as such:
chopblock() public function chopblock() 'do some things here, if error detected then exit function 'do some other things here if error detected then exit function 'do some other things here if error detected then exit function 'do some other things here end function
In the previous example, the first line runs the function chopblock, which frequently checks for an error. When an error is encountered, the function will be exited, and the code will end prematurely.
Command Reference
System Response
messagetop "Message",[1/2]
Prints a message under the percentage bar. There are two places to print, and '1' is higher than '2'.
Examples:
messagetop "Starting...",1
x="hello" messagetop x,2
Note that message "x" and messagetop("x",1) will do the exact same thing.
message "Hello!"
x="Winnebago" message x
System Engagement
reset()
Reset the servos and leave the amplifiers off. Encoder telemetry will not be lost.
powerup()
Reset the servos and engage the amplifiers.
powerdown()
Engage any brakes on brakemotors and disable the amplifiers. Encoder telemetry will not be lost.
active()
Returns false if the system has stalled or if the emergency stop has been pressed. Active should be checked frequently in a loop, as movements will hang the system if the controller is emergency-stopped.
Example:
if active()=false then msgbox("inactive!")
System Trajectory and Movement
It should be noted that if the setting Setup > System > Orientation is set to +1, exchange all the X notes and Y notes in this section with each other.
speed(x)
Speed will alter the speed at which subsequent moves will be made. It will not affect speeds already in motion. Speed is in units per minute. Example: speed(100)
accel(x)
Alters the acceleration at which subsequent moves will be made. It will not affect acceleration of an axis that is already in motion.
Example:
accel(20) |
Acceleration is set to 20 units/sec squared |
moveto x,y,z,a
Start and wait for the completion of a move at the predefined speed with the predefined accel. All values are optional.
Examples:
moveto 5,4.5,7 |
moves to x=5, y-4.5, z=7 |
moveto ,-9 |
moves to x=current positon, y=-9 |
moveto 5,,1 |
moves to x=5, z=1 |
moveto_watchlimitswitches x,y,z,a
Will move just as the moveto command, but will break execution if a limit switch is encountered on any of the axes.
smoveto x,y,z,a
Will load and start a move to a position and continue SAC execution without waiting for the movement to be complete.
Examples:
smoveto 5,4.5,7 |
moves to x=5, y-4.5, z=7 |
smoveto ,-9 |
moves to x=current position, y=-9 |
moverel x,y,z,a
Will move relative to the current position. Will wait for the movement to complete before continuing execution of the program
Examples:
moverel 5,6,-7
moverel ,-4
smoverel x,y,z,a
Will move relative to the current position. Will continue execution of the program while moving.
Examples:
smoverel 5,6,-7
smoverel ,-4
completedmove()
Will return true when all axes are not moving. Useful for waiting for the end of an smoveto command.
Example:
do if completedmove()=true then exit do loop
movedone("a")
Returns true if an axis is NOT moving and false if the axis IS MOVING. Only one axis may be inquired about per run
Example:
if movedone("x") =true then msgbox("X Axis is still moving!")
rapidto x,y,z,a
Will start and wait for the completion of a move. Moves the Z axis positively first and singly if the destination Z value is higher than the current Z value, and moves the X,Y axes first if the destination Z value is lower than the current Z value.
Examples:
rapidto 1,2,3
rapidto 1,,5
halt "a",abruptly
Will stop one or more axes from moving. If abruptly is set to true, the axis will be stopped as quickly as possible (Maximum deceleration), otherwise, it will be decelerated at the same rate by which it was accelerated.
Examples:
halt "XY",TRUE
halt "Z",FALSE
toolchange x
Changes tools automatically if a toolchanger is present and configured, alternately, if no toolchanger is present, will prompt for a manual toolchange.
Example:
toolchange 4
System Telemetry
pos("x")
Returns the theoretical, desired position of the axis relative to the origin set by the user.
Example:
xposition=pos("x")
rpos("x")
Returns the real, instantaneous position of the axis relative to the origin set by the user. This differs from regular pos in that it includes any error - difference between where the axis should be and where it is.
Example:
xposition=rpos("x")
System Timing
delay(x)
Will delay for an amount of time in seconds. Decimals are permitted. Resolution is to .001s and accuracy is dependant on system performance. For very long delays, if a message about the script timing out appears, go to Setup and change the SAC timeout value (default timeout is 120 seconds)
Example:
delay 50
delay 3.423
System Inputs and Outputs
serialioout "a",["1/0"]
Control output a on the serial IO controller. "1" turns on the output and "0" turns it off.
Example: serialioout "5","1"
serialioin("a")
Return the value of an input on the serial io controller. will return true or false.
Example: if serialioin("4")=true then messagetop("Serial 4 is on")
ioout "#",["1/0"]
Control output # on the parallel io board. "1" turns on the output and "0" turns it off. The outputs will not return to defaults after the SAC program is done running.
Example: ioout "3","1"
ioin (a)
Return the value of an input on the parallel io board. will return true or false.
Example: if ioin (4) = true then messagetop "4 is ON",2 ELSE messagetop "4 is OFF",2
NOTE The ()s in ioin versus the lack of () for ioout. The examples are correct, follow them.
homeinp("a")
Return true if a limit switch input is triggered. Values can be X,Y,Z,A as or 0 thru 7 (y=0,x=1,z=2,a=3, if you wish to access the "overtravel" inputs (really just inputs for whatever you want), use numbers 4-7)
Examples:
if homeinp("x") then msgbox("X is on the switch!")
if homeinp("5") =TRUE then MESSAGETOP "Home input 5 is triggered!",2 ELSE MESSAGETOP "Home input 5 is NOT triggered!",2 <pre> Note: Quotes around "X" are NECESSARY, quotes around "5" are not. When you use a number, you are checking the number, when you pass an axis letter, the script interprets x as a variable and not an axis name. ==== routeron ==== Turns on the spindle output of the system Example: <pre>routeron
routeroff
Similar to routeron but this function turns off the spindle output.
routerauto
Sets the spindle mode to auto, which will be most useful when running gcode files which turn the spindle on and off from within.
routerrpm(#)
Changes the RPM of the spindle if the appropriate speed-changing hardware is present.
Example:
routerrpm(15000)
auxon
Turns on the aux output, usually reserved for coolant.
auxoff
inimical to auxon, this function turns off the aux/coolant output.
auxauto
Sets the aux/coolant output to auto, useful for when running gcode which triggers the coolant output on its own.