ASCII Protocol
Introduction
The ASCII protocol is a query-response or a question and answer communication protocol in which a host PC uses ASCII characters to send commands to a device and then receives responses back from that device. The ASCII command set is used to configure devices, send data to devices and to read data and status information back from devices.
The ASCII protocol was first introduced in the 1980s by Analog Devices with its RS485 Half Duplex connected 6B Series modules and digital I/O boards and has been adopted and adapted by many other companies since. It is the de-facto communication protocol on the widely used RS485 Half Duplex connected ADAM/NuDam/eDAM modules. A very wide range of PC based data acquisition packages have support for this command protocol communicating over PC COM port. The Brainboxes ED-xxx range of devices are completely backwards compatible with these devices.
Command Format
The command string is made up of several different parts. For example, the command $aa5vv can be broken down into as many as 6 separate parts:
| Part | Description |
|---|---|
$ | Delimiter |
aa | Address |
5 | Command |
vv | Parameters |
[CS] | Checksum (optional) |
(CR) | Carriage Return |
Every ASCII command sequence is a series of ASCII characters starting with a prefix delimiter and terminating with a carriage return character. All of the ASCII characters used are easily entered from a PC keyboard and every ASCII command is terminated with a Carriage Return character (hex 0D). All commands being sent to the device must be in uppercase characters.
Prefix/Delimiter Characters
| Character | ASCII Value | Usage |
|---|---|---|
# | 0x23 | Hash/pound sign |
% | 0x25 | Percentage sign |
$ | 0x24 | Dollar sign |
@ | 0x40 | At sign |
~ | 0x7E | Tilde/approx sign |
These prefix signs cannot be used interchangeably but are particular to the command string which follows.
Address
Since it was initially developed for an RS485 bus system containing many devices, each ASCII command must include the address of the particular device the command is directed to. The address is a two character field giving the hexadecimal address of the device (00-FF). The default address is 01.
A few commands do not have an address as these are broadcast commands that go to all the devices. Here the address field aa is replaced by the wildcard **.
Checksum
An optional two character checksum can be included immediately before the terminating carriage return. The purpose of the checksum is to help the PC and devices detect communication errors. When checksum is enabled, commands sent without a valid checksum will be ignored by the devices. By default the checksum is turned off.
Response Format
| Part | Description |
|---|---|
! or > | Delimiter for valid command |
? | Delimiter for invalid command |
aa | Address |
(Data) | Response data (for certain commands) |
[CS] | Checksum (optional) |
(CR) | Carriage Return |
Range Settings and Data Formats
ED-549 Analogue Input Type Settings
| Type Code | Input Type | Engineering Unit +FS | Engineering Unit -FS |
|---|---|---|---|
| 05 | +/-2.5V | +2.5000 | -2.5000 |
| 06 or 0D | +/-20mA | +20.000 | -20.000 |
| 07 | +4 to +20mA | +20.000 | +04.000 |
| 08 | +/-10V | +10.000 | -10.000 |
| 09 | +/-5V | +5.0000 | -5.0000 |
| 04 or 0A | +/-1V | +1.0000 | -1.0000 |
| 03 or 0B | +/-500mV | +500.00 | -500.00 |
| 0C | +/-150mV | +150.00 | -150.00 |
| 1A | 0 to +20mA | +20.000 | +00.000 |
| 3A | +/-75mV | +75.000 | -75.000 |
| 3B | +/-250mV | +250.00 | -250.00 |
ED-560 Analogue Output Type Settings
| Type Code | Output Type | +Full Scale | Minimum |
|---|---|---|---|
| 30 | 0 to +20mA | 20.000 | 00.000 |
| 31 | +4 to +20mA | 20.000 | 04.000 |
| 32 | 0 to +10V | 10.000 | 00.000 |
Baud Rate Settings (cc)
| Code | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 0A |
|---|---|---|---|---|---|---|---|---|
| Baud | 1200 | 2400 | 4800 | 9600 | 19200 | 38400 | 57600 | 115200 |
Data Format Settings (ff)
| Bit 6 | Bits 1-0 |
|---|---|
| CS: Checksum (0=Disable, 1=Enable) | DF: Data format (00=Engineering, 01=% FSR, 10=Hex) |
Command Reference
%aannttccff - Set Device Configuration
Applies to: All analogue input/output products
Sets the analogue device configuration including address, baud rate, and data format.
Command: %aannttccff[CS](CR)
| Parameter | Description |
|---|---|
aa | Current device address (00-FF) |
nn | New device address (00-FF) |
tt | Not used (legacy field) |
cc | Baud rate code |
ff | Data format and checksum settings |
Response: !aa[CS](CR) (valid) or ?aa[CS](CR) (invalid)
Examples:
%0102080682(CR) -> !02(CR) // Change address from 01 to 02
%0101080A82(CR) -> !01(CR) // Change baud rate to 115200
#** - Synchronised Sampling
Applies to: ED-549
Allows the device to read and store the current line data for later retrieval. There is no response for this command. The data stored can be retrieved using $aa4.
Command: #**[CS](CR)
#aa - Read All Analogue Inputs
Applies to: ED-549
Reads data from all the analogue input channels.
Command: #aa[CS](CR)
Response: >(Data)[CS](CR)
Examples:
#01(CR) -> >+00.156+00.165-00.038+00.049+00.078+00.111+00.015+00.004(CR)
#aan - Read Single Analogue Input
Applies to: ED-549
Reads the analogue input of the specified channel.
Command: #aan[CS](CR)
| Parameter | Description |
|---|---|
n | Channel to read (0-7) |
Response: >(Data)[CS](CR)
Examples:
#010(CR) -> >+00.144(CR) // Read channel 0, engineering units
#014(CR) -> >0BBC(CR) // Read channel 4, hex format
#aan(Data) - Set Output Value
Applies to: ED-560
Sets the output value of channel n.
Command: #aan(Value)[CS](CR)
| Parameter | Description |
|---|---|
n | Channel (0-3) |
(Value) | Output value |
Response: >[CS](CR)
$aa0Ci - Zero Calibration
Applies to: ED-549
Performs a zero calibration on a specified channel.
Command: $aa0Ci[CS](CR)
| Parameter | Description |
|---|---|
i | Channel to calibrate (0-7) |
Response: !aa[CS](CR)
Calibration must be enabled using ~aaE1 before using this command.
$aa1Ci - Span Calibration
Applies to: ED-549
Performs a span calibration on a specified channel.
Command: $aa1Ci[CS](CR)
| Parameter | Description |
|---|---|
i | Channel to calibrate (0-7) |
Response: !aa[CS](CR)
Calibration must be enabled using ~aaE1 before using this command.
$aa2 - Read Device Configuration
Applies to: All products
Reads the device configuration.
Command: $aa2[CS](CR)
Response: !aattccff[CS](CR)
Example:
$012(CR) -> !01080600(CR) // Address 01, type 08, baud 9600, checksum disabled
$aa4 - Read Synchronised Data
Applies to: ED-549
Reads the synchronised data stored from the last #** command.
Command: $aa4[CS](CR)
Response: >aaS(Data)[CS](CR)
| Field | Description |
|---|---|
S | Status: 1=First read, 0=Previously read |
$aa5vv - Enable/Disable Channels
Applies to: ED-549
Enables or disables specific channels.
Command: $aa5vv[CS](CR)
| Parameter | Description |
|---|---|
vv | Hex bitmask (bit 0=ch0, bit 1=ch1, etc.) |
Examples:
$01501(CR) -> !01(CR) // Enable only channel 0
$015FF(CR) -> !01(CR) // Enable all channels
$aa6 - Read Channel Enable Status
Applies to: ED-549
Reads which channels are enabled/disabled.
Command: $aa6[CS](CR)
Response: !aavv[CS](CR)
$aa7CiRrr - Set Channel Range
Applies to: ED-549
Sets the full scale range for a specified channel.
Command: $aa7CiRrr[CS](CR)
| Parameter | Description |
|---|---|
i | Channel (0-7) |
rr | Type code from range settings table |
Examples:
$017C0R09(CR) -> !01(CR) // Set channel 0 to +/-5V
$017C3R0B(CR) -> !01(CR) // Set channel 3 to +/-500mV
$aa8Ci - Read Channel Range
Applies to: ED-549
Reads the full scale range configuration for a specified channel.
Command: $aa8Ci[CS](CR)
Response: !aaCiRrr[CS](CR)
$aa9nttss - Set Output Range (ED-560)
Applies to: ED-560
Sets the output channel full scale range.
Command: $aa9nttss[CS](CR)
| Parameter | Description |
|---|---|
n | Channel (0-3) |
tt | Type code |
ss | Slew rate (use 00) |
Examples:
$01903200(CR) -> !01(CR) // Channel 0 to 0-10V
$01933100(CR) -> !01(CR) // Channel 3 to 4-20mA
$aa9n - Read Output Range (ED-560)
Applies to: ED-560
Reads the output channel range configuration.
Command: $aa9n[CS](CR)
Response: !aattss[CS](CR)
$aaA - Read All Inputs (Hex)
Applies to: ED-549
Reads all analogue input channels in hexadecimal format.
Command: $aaA[CS](CR)
Response: >(Data)[CS](CR)
$aaB - Read Channel Diagnostics
Applies to: ED-549
Reads the diagnostic status showing whether channels are within range, over, under, or have wire opening status.
Command: $aaB[CS](CR)
Response: !aann[CS](CR)
$aaF - Read Firmware Version
Applies to: All products
Command: $aaF[CS](CR)
Response: !aa(Data)[CS](CR)
Example:
$01F(CR) -> !013.65(CR)
$aaM - Read Device Name
Applies to: All products
Command: $aaM[CS](CR)
Response: !aa(Data)[CS](CR)
Example:
$01M(CR) -> !01ED-549(CR)
$aaM0 - Read Device Model
Applies to: All products
Command: $aaM0[CS](CR)
$aaM1 - Read Device Location
Applies to: All products
Command: $aaM1[CS](CR)
$aaRS - Reset Device
Applies to: All products
Reboots the device. No response is returned.
Command: $aaRS[CS](CR)
The device can take several seconds to reboot. Close all connections after sending this command.
$aaS0 - Internal Calibration
Applies to: ED-549
Performs internal calibration on the device.
Command: $aaS0[CS](CR)
$aaS1 - Restore Factory Calibration
Applies to: ED-549
Resets calibration parameters to factory default.
Command: $aaS1[CS](CR)
~aaEv - Enable/Disable Calibration
Applies to: ED-549
Enables or disables device calibration mode.
Command: ~aaEv[CS](CR)
| Parameter | Description |
|---|---|
v | 1=Enable, 0=Disable |
~aaL(Location) - Set Device Location
Applies to: All products
Sets the device location (10 characters max).
Command: ~aaL(Location)[CS](CR)
~aaO(Name) - Set Device Name
Applies to: All products
Sets the device name (10 characters max).
Command: ~aaO(Name)[CS](CR)
~** - Host OK
Applies to: All products
Broadcast command to all devices indicating host is OK. No response.
Command: ~**[CS](CR)
~aa0 - Read Watchdog Status
Applies to: All products
Command: ~aa0[CS](CR)
Response: !aass[CS](CR)
| SS Value | Meaning |
|---|---|
| 00 | Watchdog timeout cleared |
| 04 | Watchdog timeout set |
~aa1 - Reset Watchdog Status
Applies to: All products
Command: ~aa1[CS](CR)
~aa2 - Read Watchdog Timeout
Applies to: All products
Command: ~aa2[CS](CR)
Response: !aaevv[CS](CR)
| Field | Description |
|---|---|
e | 1=Enabled, 0=Disabled |
vv | Timeout in tenths of second (01-FF = 0.1s-25.5s) |
~aa3ett - Set Watchdog Timeout
Applies to: All products
Command: ~aa3ett[CS](CR)
| Parameter | Description |
|---|---|
e | 1=Enable, 0=Disable |
tt | Timeout value (hex, tenths of second) |
Example:
~0131FF(CR) -> !01(CR) // Enable watchdog, 25.5 second timeout
~aa4n - Read Safe Value (ED-560)
Applies to: ED-560
Reads the safe value of channel n.
Command: ~aa4n[CS](CR)
Response: !aa(Data)[CS](CR)
~aa5n - Set Safe Value (ED-560)
Applies to: ED-560
Sets the safe value of channel n to the present output.
Command: ~aa5n[CS](CR)
Example:
#012+05.130(CR) -> >(CR) // Set output to 5.13V
~0152(CR) -> !01(CR) // Save as safe value for channel 2