Relative Seek Behavior

The following is an excerpt from our "UniversalStepper" manual, describing the technique for use of the "S" command.

The “S”lew command is used to cause the currently selected motor to go in the selected direction.  If the current value is only “+” or “-” (i.e., just has a sign associated with it), then the motor will slew in the indicated direction on the selected motor(s).  Otherwise, the motor(s) will go VALUE steps in the direction indicated by the sign of VALUE, after first stopping the motor (more accurately, will target current location + x, then act as goto).

For example,

      +s

will cause the current motor to start slewing in the forward direction, while

      -250s

will invoke the “relative seek” calculation mode of the firmware.

When doing a relative seek (i.e., “-250s”), the address calculations are normally based on the current TARGET location, not the current instantaneous location.  The actual rules are as follows:

1.  If the given motor is currently executing a GoTo or relative Seek command, then the new location is calculated as a delta from the old target.  For example,

            Current State:

                Our current location is 1000

                Our current target is 2000

                We are doing a GoTo action

            Request:

                -500s

            Calculation:

                Since we are doing a normal GoTo,

                the new target location will be "2000-500", or 1500

            Result:

                Motor stops, then goes forward to location 1500

2.  Otherwise, the current location is treated as the value to calculate from for the relative motion.  For example,

            Current State:

                Our current location is 1000

                We are executing a "+s" command (slew positive)

            Request:

                -500s

            Calculation:

                Since we are executing a Slew,

                the new target location will be "1000-500", or 500

            Result:

                Motor stops, then goes backward to location 500

This was set up this way as being a reasonable compromise on the intent of the meaning of "relative".  If you want to force the motion to be strictly relative to the current location, you issue the "z" (stop) command first.  Once that has been issued, the motor is placed in a special state (stopping, no target), which permits relative slew to be from the current location.

For example, to go -500 steps from the current location, regardless of whether the current action is a slew or a targeted goto, issue the command:

       z-500s