Skip to main content

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:

PartDescription
$Delimiter
aaAddress
5Command
vvParameters
[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

CharacterASCII ValueUsage
#0x23Hash/pound sign
%0x25Percentage sign
$0x24Dollar sign
@0x40At sign
~0x7ETilde/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

PartDescription
! or >Delimiter for valid command
?Delimiter for invalid command
aaAddress
(Data)Response data (for certain commands)
[CS]Checksum (optional)
(CR)Carriage Return

Range Settings and Data Formats

ED-549 Analogue Input Type Settings

Type CodeInput TypeEngineering Unit +FSEngineering 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
1A0 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 CodeOutput Type+Full ScaleMinimum
300 to +20mA20.00000.000
31+4 to +20mA20.00004.000
320 to +10V10.00000.000

Baud Rate Settings (cc)

Code030405060708090A
Baud1200240048009600192003840057600115200

Data Format Settings (ff)

Bit 6Bits 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)

ParameterDescription
aaCurrent device address (00-FF)
nnNew device address (00-FF)
ttNot used (legacy field)
ccBaud rate code
ffData 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)

ParameterDescription
nChannel 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)

ParameterDescription
nChannel (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)

ParameterDescription
iChannel to calibrate (0-7)

Response: !aa[CS](CR)

note

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)

ParameterDescription
iChannel to calibrate (0-7)

Response: !aa[CS](CR)

note

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)

FieldDescription
SStatus: 1=First read, 0=Previously read

$aa5vv - Enable/Disable Channels

Applies to: ED-549

Enables or disables specific channels.

Command: $aa5vv[CS](CR)

ParameterDescription
vvHex 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)

ParameterDescription
iChannel (0-7)
rrType 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)

ParameterDescription
nChannel (0-3)
ttType code
ssSlew 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)

warning

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)

ParameterDescription
v1=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 ValueMeaning
00Watchdog timeout cleared
04Watchdog 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)

FieldDescription
e1=Enabled, 0=Disabled
vvTimeout in tenths of second (01-FF = 0.1s-25.5s)

~aa3ett - Set Watchdog Timeout

Applies to: All products

Command: ~aa3ett[CS](CR)

ParameterDescription
e1=Enable, 0=Disable
ttTimeout 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