SP1 User Manual. Commands Set

Stepper controller command set exists to facilitate application development for wide range of applications and needs. However, the most simple positioning can be done with just a few commands:
VE – read version number
AC - set acceleration and deceleration rate
MV - move relative to the current position
CR - tell the current position in micro steps
? - test the controller motion state

Command Syntax

All commands take an axis number (controller address) as a parameter (x) before them. For such commands, the valid range of axis number is from 1 to 32000, where x is dependent on the configuration of SP1 stepper controller. Some of commands take a number or string as extra parameter (y) after them. Controller utilizes ASCII command set and also outputs system status in ASCII format. The commands may be either upper or lower case characters. The diagram below illustrates the controller command syntax.

Command Syntax.

As indicated in this diagram, a valid command consists of 3 main fields. The first field consists of numerical parameter "x", the second field consists of two letter ASCII mnemonic (exception is command x?), and the third field consists of numerical (integer type) or string parameter "y". The command is finally terminated by a carriage return or line feed character. Blank character (space or tab) may be present between controller address x and a command, or between a command and a parameter. For example, 3MV10 and 3 MV 10 are valid commands. If a command does not require parameter "y", that field is ignored and may be skipped. For example, 1MC and 1 MC are valid commands.

NOTE:

A controller command must be terminated by carriage return or line feed character. However, a line feed terminates all response strings from the controller. The setting can not be changed.

Command Format

The general format of Controller Command is two-character mnemonic (CC). Both upper and lower cases are accepted. Depending on the command, it could also have optional or required preceding (x) and/or following (y) parameters.

Parameter y

y parameter is integer number presented as a string or simple string of characters. For example, valid values for numbers are “-212546”, “0”, “112454”. Float or exponential number format is not valid. Values presented as such strings “-2.13”, or “2E5”, “10-5”, “0.5” or “45,67” are not converted into numbers, but they can be used in a string line of characters as password. For example, command 1PS1x3.4A34 sets password string “1x3.4A34” into nonvolatile flash memory for controller address 1. All numbers for motion commands are presented in micro steps. 1 micro step = 1/8 of single stepper motor step. 1/8 of motor step is the finest resolution of the controller – stepper motor system. For example, if stepper motor of 200 steps/revolution is used, the controller finally enables resolution of 1600 micro steps/revolution.

Blank Spaces

Blank spaces are allowed and ignored between parameters and commands. The following two commands are equivalent:
2 VF 1000
2VF1000

Command Line

Commands are executed line by line. A line consists of one command. The controller interprets the commands in the order they are received and executes them sequentially. The maximum number of characters allowed on a command line is 20.

Terminator

Each command line must end with a line terminator, i.e., carriage return (ASCII 13 decimal) or line feed (ASCII 10 decimal).

Note: By default SP1 controller returns echo string "OK" before received command is executed. This is useful feature for long range communication in noisy surrounding, when host computer needs to be sure, that command has been received by SP1 controller. The option can be enabled/disabled by xRSy command.

Programming algorithm

As command characters arrive from the host terminal, they are placed into the command buffer. When a carriage-return or line feed terminator is received, the command is interpreted. If the command is valid and its parameter is within the specified range, it will be executed. If the command contains an error, it will be ignored.
Typical sequence of execution of the commands is shown below.


Commands sequence.

Note: Terminating characters are not shown here. 
1RL 1                   enable “Right limit” switch
1LL 1                   enable “Left limit” switch
1VF2000             set maximum speed to 2000 micro steps per second

Motion commands take extra time as being executed. Command x? must follow all the motion commands to get the moment when motion is done. Typical commands sequence is presented below.


Programming of the motion commands. Axis number is 1 in this case.
 
where,
1MV 30              Move axis 1 to relative plus position 30 micro steps
1?                        Test axis 1 controller state. Ask for response; is controller ready to execute next motion command?
If response is 0, delay few milliseconds and loop back to “1?
else if response is –1, get error code and explanation
else if response is 1, execute next command.

For example:
2MV-10                move axis 2 to relative minus position 10 micro steps
2?                          test axis 2 controller state. Is it ready to execute next motion command?
….
NOTE:
The controller executes motion commands (xMVy, xSHy, xSTy) in the order received without waiting for completion of previous motion command. So the sequent motion command may interrupt previous motion command. The motion command and one other command are executed simultaneously in parallel threads. Even while the stepper is in motion, the corresponding controller always makes quick response to such status commands, as xVE, x?

Operating modes

Some of the commands may operate in one of the two modes in which each command can be used. Most of them operate in both modes.
 
Default command mode. Controller is idle and the commands will be executed immediately. After the power is switched on, the controller always is initiated in default mode. The controller state (set of all parameters) which has been saved with SO command in flash memory, now is read from flash to set default parameters. Users can predefine the default parameters such as communication rate, velocity, acceleration, access control bit, axis number (controller address), password, stall detection parameters and others. There is no need to set optional parameters every time when SP1 power is switched on.

Service mode. Controller does not execute any motion commands. Hardware Left and Right Limit switches and Left and Right buttons perform motion (positioning) manually.  The two buttons play manipulator role to move stepper motor clockwise or reverse. Some extra commands are available only in service mode.

NOTE:

Switching between the modes is implemented in two commands: xDMy, and xSVy.  Modes also switches, when both hardware (Left and Right) buttons are pressed simultaneously for 3-4 seconds. Then front panel “Ready” LED (light emitting diode) blinks 10 times. This blinking indicates mode switching. Do not switch between the two modes, if the stepper motor has not finished or terminated motion . While the stepper motor is in motion, one of the two buttons in case of emergency stops the axis motion and sets error bit: “Limit is detected”. Use x? command to test controller state or see “Ready” LED on top panel. Mode switching can be initiated, if motor is standing and top panel LED is on.

Command Summary

The controller “understands” 50 commands. These commands are organized into the following categories:
· Controller Status
· Motion Control
· Motion Parameters
· Position Control
· General Mode Selection
· I/O Functions
· Modem Interface

Command List

Command

Command description

Controller response

Default Mode
(N/A - not available)

Service Mode
(N/A - not available)

Controller Status
xVE

Get version number

Returns firmware.
Version and current mode

Yes

Yes

xHL
Get help
Returns reference, where you can get information about SP1

Yes

Yes

x?

Is SP1 controller ready to accept next motion command?

1= ready. 0 = still busy,
-1 = error detected, run xER command to get error explanation

Yes

Yes

xER

Get the last motion error explanation.  The command also resets error bit

1. Error: Left limit detected
2. Error: Right limit detected
3. Error: Stall detected
4. Error: Motion commands disabled in service mode
5. Error: Encoder is absent or disabled

Yes

Yes

xGPy

Get the current parameter. y - parameter number. See extended command description for details

Returns parameter value

Yes

Yes

Motion Control
xON

Switch on the stepper motor current

-

Yes

Yes

xOF

Switch off the stepper motor current

-

Yes

Yes

xMVy Move the stepper motor y number of steps relative to the current position. Steps sign sets rotation direction. 1 micro step = 1/8 of motor step. Consider trapezoidal and gear modes. Motion command is disabled if Error bit is set. Clear Error bit and read error code by ER command

-

Yes

N/A

xMCy Move continuously. Direction is set by y parameter sign. y absolute value is not used. If necessary, apply VF command to set stepper motor speed. Use xST0 command to stop the motion.
-
Yes N/A
xSHy

Search the home (origin) position. y-search direction (sign) and maximum search range (number of micro steps). 1 micro step = 1/8 of motor step. “Home” hardware switch must be connected to the controller. Motion breaks if "Home" is detected. Motion command is disabled and the command is ignored, if Error bit is set. Clear Error bit by ER command

-

Yes

N/A

xORy Search the home (origin) position. The command is similar to xSHy, but it enables soft (decelerated) break, when "Home" position is detected. The stop position is not "exact Home". It  is "about Home". The command  has to be followed by xSHy command to get back and find the exact position
     
xOCy
Search the home (origin) position. The command is similar to xORy, but it instantly resets to zero position counter and enables soft (decelerated) break when "Home" switch is detected (see also xCR command). The stop position is not "exact Home", but absolute position counter shows to it. -
Yes
N/A
xSSy

Preset number of steps into memory. Y sign sets motion direction. 1 micro step = 1/8 of motor step. Consider ST command

-

Yes

Yes

xSTy

Synchronous start or stop. Controller address x = 0 affects all axes (controllers), where y = 1 - start, 0 - stop. Steps and sign must be preset by SS command. When command is executed, controller resets steps to zero, which has been preset by SS command. Motion is disabled if Error bit is set. Then clear Error bit by ER command

-

Yes

N/A

Motion Parameters
xTPy

Set trapezoidal profile of speed. 1 - set trapezoidal speed profile. 0 - set constant speed

-

Yes

Yes

xVFy

Set maximum velocity value.
y: steps/second

-

Yes

Yes

xVSy

Set maximum velocity value for service mode. y: steps/second

-

Yes

Yes

xACy

Set acceleration value y=Deltaspeed/step

-

Yes

Yes

xASy

Set acceleration value for service mode y= Deltaspeed/step

-

Yes

Yes

xAGy

Enable/disable auto-gearing mode.  1 - set auto. 0 - manual gear control

-

Yes

Yes

xMMy

Set the manual gear micro stepping mode. 2=half step, 1=quarter step, 0=eighth step. Consider AG command. Do not employ the command when the stepper motor is in motion

-

Yes

Yes

xTMy

Set time multiplier factor y to reduce stepping rate y times. Time period = time_in_seconds * time_multiplier. Frequency = 1/Time_period. Default y =1. Do not employ the command while stepper motor is in motion

-

Yes

Yes

xSEy

Set/reset encoder presence bit. 1 - enable encoder, 0 – disable. Quadrature encoder hardware should be connected to the controller interface before using the command

-

Yes

Yes

xMTy

Set the steps counter threshold for motion sensor. 16 < y < 32000 micro steps. Encoder hardware should be present. Consider SE, ET and MD commands

Sets error bit (code: Error 5) if encoder presence bit is not set by SE command. Clear Error bit by ER command

Yes

Yes

xETy

Set the encoder steps counter threshold for motion sensor. Consider SE, MD and MT commands

Sets error bit (code: Error 5) if encoder presence bit is not set by SE command. Clear Error bit ER command

Yes

Yes

xMDy

Enable/disable the motion (or Stall) detection. 1 - enable, 0 - disable. Quadrature encoder must be connected to the controller. Consider SE, MT and ET commands

Sets error bit (code: Error 5), if encoder presence bit is not set by SE command. Clear Error bit by ER command

Yes

Yes

Position Control
xCR

Read the absolute counter position in micro steps. 1 micro step = 1/8 of motor step

Returns number. Range ±2000000000

Yes

Yes

xCWy

Write the absolute counter position. y: positive, negative, or zero position. 1 micro step = 1/8 of motor step

-

Yes

Yes

xEN

Read the absolute encoder position. Step size depends on quadrature encoder used

Returns number. Range ±2000000000

Yes

Yes

xEZ

Reset the absolute encoder to zero

-

Yes

Yes

xTH

Test “Home” switch

 

Yes

Yes

xLLy

EnableLeft limit detection. y=1 - enable, y=0 - disable. The controller breaks motion immediately, if the limit switch or “LEFT” button is pressed

-

Yes

Yes

xRLy

Enable Right limit detection. y=1 - enable, 0 - disable. The controller breaks motion immediately, if the limit switch or “RIGHT” button is pressed

-

Yes

Yes

General Mode Selection
xCOy Enable or disable binary commands for contouring y=1 - enable, y=0 - disable. - Yes Yes
xRSy
SP1 response. Set or clear response bit: y=1 - set, 0 - clear. If the bit is set, SP1 returns "OK" string every time when axis number and command are decoded. "OK" string is send before the command execution
-

Yes


Yes


xLCy

Lock the controller. The locked controller ignores all the commands (except UC command) in default mode. All service mode commands remain unlocked. y - password string, if password is set by PS command, otherwise y parameter is ignored

-

Yes

Yes

xUCy

Unlock the controller. Enable the controller commands for default mode, if they are locked by DC command. y - password string, if password is set by PS command, othervise the parameter is ignored

-

Yes

Yes

xSVy

Set the service mode. y - password string, if password is set by PS command, otherwise the parameter is ignored

-

Yes

Yes

xDMy

Set the default mode. y - password string, if password is set by PS command, otherwise the parameter is ignored

-

Yes

Yes

xPSy

Set password. y = password string (till 10 characters).

If succeeds, returns string
“New password is set”, or
“Failed to set password into flash memory”,
if fails

N/A

Yes

xSRy

Set the serial port baud rate. y = 4800, 9600, 19200, 28800, 57600, 115200. Do not employ the command when the stepper motor is moving

-

Yes

Yes

xSO

Save the options. Dump current optional parameters to nonvolatile flash memory. The options become default

If succeeds, returns string “Parameters saved in Flash memory”, or “Flash memory is bad or absent”, if fails

N/A

Yes

xRO

Read options from nonvolatile flash memory

If succeeds, returns string “Option parameters read from Serial memory” or correspondent error message, if it fails to read option parameter from flash memory

N/A

Yes

xNMy

Set axis (or controller) number. y – positive number (1…32000)

-

N/A

Yes

Modem Interface
xPI

Program the modem interface instruction

See extended command description for details

N/A

Yes

xTIy

Test (get) the modem preprogrammed instruction. y - instruction number

See extended command description for details

N/A

Yes

xTRy

This is a debugging command to test operation of the modem preprogrammed instruction set. y = 1 set trace option. y = 0 no tracing. For standard SP1 operation the trace bit must be cleared

Returns one of the strings: Trace mode is set or Default operation, or Flash memory is bad or absent

N/A

Yes

I/O Functions. (SP1 Electronic circuit is available on attached CD for RST customers)
xMRy

Read byte from flash memory. y is a byte address in flash memory

Returns a byte as number, if succeeds, or string “Read error”, if fails

N/A

Yes

xSAy

Set the current flash memory address for MW command

-

N/A

Yes

xMWy

Write a byte to the flash memory current address. y - the byte

Returns string “Write error”, if fails

N/A

Yes

xTBy

Test port bit for AT89C55WD chip. y: 0 = P0.0; 14 = P1.4; 37 = P3.7

Returns to 0, if port input is low, or to 1, if it is high

Yes

Yes

xSBy

Set port bit. y: 11 = P1.1; 17 = P1.7; 36 = P3.6

-

Yes

Yes

xCBy

Clear port bit. y: 22 = P2.2; 35 = P3.5; 7 = P0.7

-

Yes

Yes