(added response and engagement categories) |
|||
Line 74: | Line 74: | ||
=== System Engagement === | === System Engagement === | ||
− | + | ==== reset() ==== | |
− | + | ||
− | + | ||
Reset will reset the servos and leave the amplifiers off. Encoder telemetry will not be lost. | Reset will 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: | ||
+ | <pre> | ||
+ | if active()=false then msgbox("inactive!") | ||
+ | </pre> | ||
+ | |||
+ | === 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. | ||
+ | |||
+ | <pre> | ||
+ | speed(x) | ||
+ | </pre> | ||
+ | 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: | ||
+ | {| border="1" cellspacing="0" cellpadding="3" | ||
+ | | <pre>accel(20)</pre> | ||
+ | | 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: | ||
+ | {| border="1" cellspacing="0" cellpadding="3" | ||
+ | |<pre>moveto 5,4.5,7</pre> | ||
+ | |moves to x=5, y-4.5, z=7 | ||
+ | |- | ||
+ | |<pre>moveto ,-9</pre> | ||
+ | |moves to x=current positon, y=-9 | ||
+ | |- | ||
+ | |<pre>moveto 5,,1</pre> | ||
+ | |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: | ||
+ | {| border="1" cellspacing="0" cellpadding="3" | ||
+ | |<pre>smoveto 5,4.5,7 </pre> | ||
+ | |moves to x=5, y-4.5, z=7 | ||
+ | |- | ||
+ | |<pre>smoveto ,-9</pre> | ||
+ | |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: | ||
+ | <pre>moverel 5,6,-7</pre> | ||
+ | <pre>moverel ,-4</pre> | ||
+ | |||
+ | ==== smoverel x,y,z,a ==== | ||
+ | Will move relative to the current position. Will continue execution of the program while moving. | ||
+ | |||
+ | Examples: | ||
+ | <pre>smoverel 5,6,-7</pre> | ||
+ | <pre>smoverel ,-4</pre> | ||
+ | |||
+ | ==== completedmove() ==== | ||
+ | Will return true when all axes are not moving. Useful for waiting for the end of an smoveto command. | ||
+ | |||
+ | Example: | ||
+ | <pre> | ||
+ | do | ||
+ | if completedmove()=true then exit do | ||
+ | loop | ||
+ | </pre> | ||
+ | |||
+ | 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. | |
− | + | Will move the Z axis positively first and singly if the destination Z value is higher than the current Z value. | |
− | + | Will move 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 | ||
+ | will change tools automatically if a toolchanger is present and configured, alternately, if no toolchanger is present, will prompt for a manual toolchange. | ||
+ | exmaple: | ||
+ | toolchange 4 | ||
[[Category:Software]] | [[Category:Software]] |
Revision as of 10:06, 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]
messagetop 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 will 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. Will move the Z axis positively first and singly if the destination Z value is higher than the current Z value. Will move 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 will change tools automatically if a toolchanger is present and configured, alternately, if no toolchanger is present, will prompt for a manual toolchange. exmaple: toolchange 4