Concord Consortium Sonic Ranger (CCSR) Interface Specification

Version 1.0a1

created: 10/29/97, last modified 11/06/97

Stephen Bannasch, stephen@concord.org

Copyright 1997 (c) by the Concord Consortium

The CCSR is a battery-powerd ultrasonic ranging device based on the Polaroid ultrasonic range finder used in Polaroid cameras and several digital measuring tapes. The CCSR collects between 10 and 50 samples of distance each second and reports the values serially at 9600bps, 8 data, 2 stop, no parity. The maximum range of the CCSR is aproximately 30 feet. Internally the CCSR uses a PIC16C73 microcontroller running at 8MHz to operate the analog electronics, monitor the battery voltage and manage the serial communications. The CCSR is not a stand-alone device but is used with software on a microcomuter to display real-time graphs of distance, velocity, or acceleration versus time. The CCSR uses 4 AA batteries and is housed in a 6V lantern flashlight case.

The CCSR has no on-off switch. Ulta-low power circuitry monitors the serial port and when an active serial connection is detected the CCSR turns on. When the CCSR turns on it is in command mode and will respond to status queries and commands to set the data collection rate.

In addition there is a command to go into data mode. In data mode the CCSR will initiate ultrasonic ranging. Sampling is started at the current data sample rate and will continue until a command is received over the serial port to stop or the serial port becomes inactive (either by powering down or by disconnecting the serial cable).

Command List

In the descriptions below the actions Send and Receive are from the high-level computers perspective.


Data Mode Functions

Info/Break

Send: "?"

Recieve: ?,<device-id>,<version#>,<battery-voltage>,<sample-rate><crlf>

Set Sample Rate

Send either a "1", "2", "3", "4", or a "5"

Recieve the corresponding character back

CCSR button down

Send:

Action: CCSR button pressed down

Receive: "<":

CCSR button up

Send:

Action: CCSR button let up

Receive: ">":

Goto Data Mode

Send: "!"

Receive: "!"

Stop Data Mode

Send: "#"

Receive: any pending measurement is completed and sent


Command Mode Functions

Info/Break

Send: "?"

Recieve: ?,<device-id>,<version#>,<battery-voltage>,<sample-rate><crlf>

The Info/Break command is used to determine if a CCSR is connected and operating and can also be used while the CCSR is in data mode to immediately interrupt data collection and return the CCSR to command mode.

The information returned by the Info/Break command can be used by the computer to determine whether a CCSR is connected, the version of the CCSR software that is installed, the CCSR's current battery voltage and sample rate.

The string data are retuned in a comma-delimited form and are ended with a <crlf> pair of characters. It is possible in future version of the CCSR software that additional data will be returned. When the sample rate element of the string is parsed make sure to look for either a <cr> character or a "," character. If older software finds a comma after the sample rate string it should finish parsing the sample rate information and ignore the following string data until the <crlf> character pair is found.

Here is a possible result string from the Info/Break command:

?,CCSR,v1.0,5.6,20<crlf>

The elements of the string are interpreted as follows:

"CCSR" Concord Consortium Sonic Ranger

"v1.0" software version 1.0

"5.6" the battery voltage is 5.6

"20" the current sample rate is 20 samples per second.

Set Sample Rate

Send either a "1", "2", "3", "4", or a "5"

Recieve the corresponding character back

The corresponding data rates are as follows:

1 10 samples per second

2 20 samples per second

3 30 samples per second

4 40 samples per second

5 50 samples per second

CCSR button down

Send:

Action: CCSR button pressed down

Receive: "<":

In command mode when the CCSR button transitions from up to down (with an appropriate delay for de-bouncing) the CCSR responds with a single "<" character. In order to start collection of data in response to a button down event the high-level software must subsequently send the Goto Data Mode command.

CCSR button up

Send:

Action: CCSR button let up

Receive: ">":

In command mode when the CCSR button transitions from down to up (with an appropriate delay for de-bouncing) the CCSR responds with a single ">" character indicating the CCSR button has been let up. I haven't thought of a use for this command and I've only put it here for symetry.

Goto Data Mode

Send: "!"

Receive: "!"

After the CCSR receives the "!" character it echos the "!", enters Data Mode and starts sampling and communicating data at the currently selected sample rate.

Data Mode: Data Stream Description

While in data mode the CCSR continuously collects data at the current sample rate and communicates the results serially. Data collection continues until the CCSR receives either the stop command, "#", or the Info/Break command "?". If the CCSR is unplugged from the serial port or if the serial port is powered off the CCSR will automatically power-off and data collection will stop.

Data are sent in in 3 byte packets with 14 bits of resolution for the ranging measurements.

bit 7 6 5 4 3 2 1 0  
first byte 0 1 r r r r d13 d12  
second byte 1 0 d11 d10 d9 d8 d7 d6  
third byte 1 1 d5 d4 d3 d2 d1 d0  

The 14 bits of data (d0 ... d13) represent samples at 8 uS intervals, a distance resolution of about 0.05 inches.

Bits 6 and 7 are framing bits which identify the byte sent back to the computer. Valid data packet bytes always have either bit 6 and/or bit 7 set. The framing bits can be used for re-syncronizing to the beginning of a 3-byte data packet if there are errors in transmission.

Bits 2:5 of byte 0 are reserved for future definition. The reserved bits may be used later for increasing the resolution to more than 14 bits. In addition the status of the button or a low-battery indicator could be included.

Valid data packet bytes are limited to the range 40h to FFh as follows:

byte 1: 40h-7Fh

byte 2: 80h-BFh

byte 3: C0h-FFh

Bytes in the range 00h to 3Fh (bits 7 and 6 set to 0) are not valid bytes in a data packet and are currently not sent by the CCSR while in Data Mode.

In the future bytes in the range 00h-3Fh range could be used for additional command and status information. In this case they would not be part of a data packet but instead would represent a command channel of information and would appear asyncronously. Command channel bytes would not interrupt the three byte sequence in a data packet transmission. Command channel bytes would only be sent between complete data packets.

Stop Data Mode

Send: "#"

Receive: any pending measurement is completed and sent

The CCSR will continue sending data until the stop data mode command is sent. Any initiated distance measurement will be completed and the 3-byte data packet sent.

There is no echo of the "#" character by the CCSR to the computer.

Info/Break

Send: "?"

Recieve: ?,<device-id>,<version#>,<battery-voltage>,<sample-rate><crlf>

The Info/Break command is used to determine if a CCSR is connected and operating and can also be used while the CCSR is in data mode to immediately interrupt data collection and return the CCSR to command mode.

If a "?" character is received while the CCSR is collecting or transmitting data the CCSR will stop the current operation, return to command mode and send the Info/Break information string. For a complete description of the Info/Break string see the description under command mode.

There may be periods during a measurement where the CCSR will not respond immediately to the Info/Break command. This period should not exceed 70 ms.

It is possible because of serial communication latency for a data byte to be transmitted from the CCSR after the "?" character has been sent. The first character returned by the Info/Break command is the "?" character. This is equal to 3Fh. This charaacter is not a valid byte of data in the 3-byte data packet definition. If a data transmission is in effect when the "?" character is sent any data bytes received can be identified and thrown away while waiting for the "?" character.

The data packet definition defines the 2 high bits of each byte as framing bits an either one or both of the bits must be set. This means data packet bytes are always greater than 3F hex and can be distingushed from the "?" character.