Skip to content

Scripting

mschafer edited this page Aug 1, 2012 · 14 revisions

Table of Contents

File Format

Scripts are plain text files.
There is 1 command on each line.
Lines starting with a `#` are treated as comments and ignored.

Commands

Each command starts with a keyword and if followed by one or more parameters. The keywords and parameters are case insensitive. All numeric values are fixed point integers. All parts of a command must be separated by whitespace.

Line

The line command steps all four axes in a straight line from the current position to the relative position specified using Bresenham's algorithm. It consists of the keyword line followed by a 16 bit signed delta position for each axis and a 32 bit unsigned integer specifying the time in microseconds to complete the line. The axes can appear in any order.

 # step in a straight line to a point (100, 0, -40, 10) steps from the current position.
 # take 120000 usec to complete the move.
 line x 100 z -40 u +10 120000

If the delta position for all axes is 0, then the command will have no effect--not even a delay.

Step

The step command causes 1 or more axes to take a single step in the specified direction and then pause for the specified amount of time. It is functionally equivalent to a line command with deltas of +/- 1, but it is transmitted in more compact form to the device which increases the download speed. The command consists of the keyword step followed by up to 4 four axis names and ends with a 16 bit unsigned integer delay value. The direction of the step is specified by a + or - following each axis name without any whitespace separation. Axes that don't appear in the command will not move.

 # step the x axis in the forward(+) direction and the y axis in the reverse(-) direction.
 # wait 100 usec. before the next command.
 # z and u axes do not move.
 step x+ y- 100

The axis will step in the forward direction if the name appears by itself. It is also possible to explicitly name an axis that you don't want to step by following the name with a 0. The axis names may appear in any order. If a delay longer than 16 bits is desired, then use the line command with deltas of +/- 1.
 # step the x axis in the forward(+) direction and the y axis in the reverse(-) direction.
 # wait 100 usec. before the next command.
 # z and u axes do not move.
 step u0 z0 x y- 100

Axis

This command configures the pins used by a particular axis. Each axis must have a step and direction pin: however, the forward and reverse limit pins are optional. The default assignment of pins to an axis is part of the port to a specific device but this command may be used to change those defaults. A pin, described by a port number and a pin number, appears in the command as P1_2. The number following the P is the port number and the number after the _ is the pin numbers. Both must be unsigned 8 bit numbers although valid values are determined by the specific device being used. The value 255 for the port is reserved.

A pin function name precedes the pin description and must be one of step, dir, fwd, or rev. Step and dir are mandatory while the limit pins fwd and rev are optional. The name is separated from the pin descriptor by a : and is preceded by an option + or - to indicate polarity.

Consider this example:

 # Set the pins used to control the x axis
 # The step pin is an active high output directed to port 1, pin 2.
 # The dir pin is an active low output directed to port 1, pin 3.
 # The reverse limit pin is an active high input from port 0, pin 4.
 axis x step:P1_2 -dir:P1_3 +rev:P0_4

The polarity means different things for different pin functions.
step
A positive polarity means the pin is held low. A step is indicated by on the pin by a transition to high followed shortly by a return to low. A negative polarity means the pin is held high with a step indicated by a low going pulse.
dir
A positive polarity means that this pin is held high when the step indicated is in the + or forward direction. Changing the polarity of this pin effectively reverses the direction of motion for an axis.
fwd and rev limit pins
A positive polarity for these pins means that reading a high value on the pin indicates the limit switch is activated and motion in the corresponding direction should be disabled. A negative polarity indicates and active low limit switch.
The pin function names may appear in any order. The devices do not currently implement any non volatile storage so using non-default pins will require a preamble with the necessary axis commands in every script.

Ping

Sends a ping to the device. Currently has no effect inside a script and should not be used.

NoOp

Used for debugging purposes and should not be included in a script.

Clone this wiki locally