When configured in “ASCII” serial mode, the Simple Motor Controller offers a simple serial interface based on ASCII characters. This mode makes it easy to interact with the Simple Motor Controller through a terminal program, such as HyperTerminal, and it can provide a more intuitive interface for users who would rather deal with character strings than bits and bytes.
There are some limitations when using ASCII mode, however:
ASCII commands consist of a command string, which is typically a single letter, followed by a comma-separated list of numbers representing the arguments to the command. Not all commands take arguments, and only one command (Set Motor Limit) takes multiple arguments. All commands must be terminated by a special termination character, such as a carriage return (<CR>).
Expressed generally, the format is:
For example, to command the motor to drive forward at speed 3200 (full speed), we could send the following ASCII command:
Here the command string is “F”, the argument string is “3200”, and the termination character is <CR>.
ASCII commands are case-insensitive and white-space is ignored, so “F3200<CR>” has the same effect as “f 3200 <CR>”.
The specific commands are documented in Section 6.3.1.
The following table lists all of the available command strings:
Command arguments are expressed as strings of ASCII digits. By default, the string is interpreted as a decimal (base 10) value, but an “H” can be appended to the end of the string to tell the Simple Motor Controller to interpret it as a hexadecimal (base 16, or hex) value. For example, you can represent an argument value of 127 with “127” or “7FH” (0x7F is the hex representation of 127). The arguments to the three motor commands (“F”, “R”, and “B”) can also be written as percentages by appending a “%” to the end of the argument. For example, you can represent full motor speed with the argument “3200” or with the argument “100%”.
ASCII mode accepts three different termination characters:
One of the above three characters must be the last character in your ASCII command string.
Any ASCII mode command string that contains more than just a termination character will generate a serial response from the Simple Motor Controller. The first character of the response gives you information about the status of the Simple Motor controller; it can be one three possible characters:
If the command sent responds with data (e.g. the Get Variable command), the data follows the status character as a decimal (base 10) string of ASCII digits.
The ASCII mode serial response is always terminated by a carriage return (<CR>) followed by a line feed (<LF>).
For example, if we send a Motor Forward command while no errors are stopping the motor, the response would be “.<CR><LF>”. If we send a Get Variable command while errors are stopping the motor, the response might be “!123<CR><LF>”, which would indicate that the requested variable has a value of 123.
Commands that consist only of termination characters do not result in a serial response from the Simple Motor Controller. All other commands, even invalid ones, cause the Simple Motor Controller to respond when a termination character is received.
Using a Terminal Program
ASCII mode makes it easy to communicate with the Simple Motor Controller from a terminal program, such as HyperTerminal. The responses are formatted so that they will appear nicely in the terminal window.
We recommend you enable local echoing of transmitted characters when typing commands into a terminal program. The following picture shows our recommended ASCII settings when using HyperTerminal:
You can get to this dialog by going to the File > Properties menu and clicking on the ASCII Setup… button under the Settings tab.