CCA2D2-v2 Firmware
Documentation for Firmware for the CC A2D2v2 interface.file: A2D2FirmwareDocsE-20030304.txt
Updated March 4, 2003 for firmware version 'CCA2D2v0.91'.
1. Overview
The firmware running on the CCA2D2v2 interface is designed to allow the host to use the interface for data collection and storage. The firmware has commands that will read sensors in the probes and will:- Return 2 or 4 channels of 24 bit analog data at 6 or 12 DPS (Datums per Sec).
- Return 1 to 4 channels of 10 bit analog data at 400 DPS.
- Return rotary encoder data at 100 DPS.
- Return rotary encoder and single channel 10 bit analog data at 100 DPS.
- Sample and store 1000 points of 10 bit data in main FRAM at up to 10,000 DPS
- Sample and store 508 points of 24 bit data in main FRAM in
the sleep mode
- • Get the interface's Firmware version information
- • Return information on the interface's general status
- • Return information on the interface's Main FRAM status
- • Read and write to/from the Main 8KB (early models had 2KN) FRAM memory
- • Read 2K of the Main FRAM memory as 10 bit data
- • Read 2K of the Main FRAM memory as 24 bit data
- • Read and write to/from an individual probe's 2KB EEPROM memory
- • Read and write to/from the PIC's 128 byte EEPROM memory
- • Put the interface in sleep mode and log data at intervals set by the user
At startup, the main FRAM memory size (written at device calibration and expressed as 1024 byte blocks) is read from the up's EEProm and stored in the variable 'FRAMsze' -> this can be either 2 or 8 as of now. This controls the memory interaction, and the max address range allowed. The firmware thus supports both sizes.
The probe is normally connected to (and powered by - except in sleep mode) the host with a 9600 Baud 1.8.1 serial line, and many commands from host to interface are single byte commands. Exceptions to this are the memory access commands, the commands for setting the Probe's DIO2 and 5 V power lines, and the Sleep command, all of which require one or more argument bytes.
2. Summary of the commands (all commands are case sensitive):
A. Switch to COMMAND mode - this is the only command available in DATA mode.'c' -> switch to COMMAND mode
RESPONSE: Switch to COMMAND mode and terminate any existing DATA mode
B. Switch to the Streaming 24 Bit A2D DATA Mode at 6 or 12 DPS
'a' -> Alternate CH 0 and CH 1 on Probe A at 6 DPS (Datums Per Second)
'b' -> Alternate CH 0 and CH 1 on Probe B at 6 DPS
'd' -> Alternate CHs 0 on Probes A&B and CHs 1 on Probes A&B at 12 DPS
RESPONSE: Switch to Data mode and start Streaming Datums
Datum Format: 4 bytes; 0PCS.ODDD 1DDD.DDDD 1DDD.DDDD 1DDD.DDDD
[P=Probe#, C=Channel#, S=Sign, O=Overrange, D=data bit]
Sign bit: If VIN is > 0, this bit is HIGH. If VIN is < 0, this
bit is LOW. The sign bit changes state during the zero code.
Overrange bit: If the input is within the normal input range
0 >= VIN <= VREF, this bit is 0. If the input is outside the
normal input range, VIN > VREF or VIN < 0, this bit is 1.
The ADC has the ability to return valid data for inputs both
less than and greater than VREF (on the A2D2 VREF is 2.5 volts).
The maximum excursion is 0.125 * VREF. Input values smaller
than VREF * -0.125 will be reported as -2,097,152. Inputs
higher than VREF * 1.125 will be reported as +18,874,368.
Here is a table of example data.
0PCS.ODDD 1DDD.DDDD 1DDD.DDDD 1DDD.DDDD
VEF * -0.125 0PC0.1111 1111.0000 1000.0000 1000.0000 = -2,097,152
-1 LSB 0PC0.1111 1111.1111 1111.1111 1111.1111 = -1
0+/0- ** 0PC0.0000 1000.0000 1000.0000 1000.0000 = 0 (-0)
0+/0- ** 0PC1.0000 1000.0000 1000.0000 1000.0000 = 0 (+0)
VREF * 0.5 0PC1.0011 1111.1111 1111.1111 1111.1111 = +8,388,607
VREF 0PC1.0111 1111.1111 1111.1111 1111.1111 = +16,777,215
VREF + 1 LSB 0PC1.1000 1000.0000 1000.0000 1000.0000 = +16,777,216
VREF * 1.125 0PC1.1111 1111.0000 1000.0000 1000.0000 = +18,874,368
** The sign bit changes state during the zero code. That means it can be
either 0 or 1.
C. Switch to the Streaming 10 Bit A2D DATA Mode at 400 DPS (Datums Per Second)
'e' - Ch0, Probe A
'f' - Ch0, Probe B
'g' - Alternate CH 0 and CH 1 on Probe A
'h' - Alternate CH 0 and CH 1 on Probe B
'i' - Alternate CH 0 on Probe A and CH 0 on Probe B
'j' - Rotate thru all 4 channels on Probe A and Probe B
'k' & 'l' - Same as 'j'
RESPONSE: Switch to Data mode and start Streaming Datums
Datum Format: 2 Bytes; 001P.CDDD 1DDD.DDDD [Type = 001]
[P=Probe#, C=Channel#, D=data bit]
D. Switch to the Streaming Rotary encoder (and 10 Bit A2D) DATA Mode
'r' - Rotary encoder at 100 DPS (Datums Per Second)
's' - Rotary encoder at 100 DPS with 10 bit A2D Probe B Ch0 at 300 DPS
't' - Rotary encoder at 100 DPS with 10 bit A2D Probe B Ch1 at 300 DPS
RESPONSE: Switch to Data mode and start Streaming Datums
Datum Format (Encoder): 2 Bytes; 000x.xxED 1DDD.DDDD [Type = 000]
Datum Format (10 bit A2D): 2 Bytes; 001P.CDDD 1DDD.DDDD [Type = 001]
[P=Probe#, C=Channel#, D=data bit, E=error, x=Garbage]
If bit E is set, it signifies at least 1 Gray code sequence
error in that 10 mS data period.
E. Initiate Fast A2D data conversion and storage in main FRAM
The A2D multiplexer is set for channel 0 -> this is Probe A Ch0
'Q' - Save 1000 samples of fast AD10 data at 10,000 SPS
'R' - Save 1000 samples of fast AD10 data at 5,000 SPS
'S' - Save 1000 samples of fast AD10 data at 2,000 SPS
'T' - Save 1000 samples of fast AD10 data at 1,000 SPS
RESPONSE: Convert and save desired data. Respond with 'F' if successful.
F. Main FRAM Fast A2D data Playback
'Y' - Replay 1000 samples of fast AD10 data
RESPONSE: Stream 1000 datums back.
Datum Format: 2 Bytes; 001P.CDDD 1DDD.DDDD [Type = 001]
[P=Probe#, C=Channel#, D=data bit]
'Z' - Zero all of main FRAM memory
RESPONSE: Zero FRAM. Respond with 'Z'
G. Read data from Interface Main FRAM, Probe FRAM, and uP's EEPROM.
-> All commands are followed by 2 address bytes.
The address refer to long words, In other words address 0001 specifies
bytes 0004-0007.
'A' - Read 4 bytes from Probe A EEPROM (starting at address 0 -> 511)
'B' - Read 4 bytes from Probe B EEPROM (starting at address 0 -> 511)
'C' - Read 4 bytes from Main FRAM (starting at address 0 -> 511)
'D' - Read 4 bytes from uP's EEPROM (starting at address 0 -> 31)
RESPONSE: 1. Stream back 4 data bytes if an address was sent in time.
2. Respond with an 'a' if no address was sent in time.
3. Respond with an 'R' if the address was out of range.
H. Write data to Interface Main FRAM, Probe FRAM, and uP's EEPROM.
-> commands are followed by 2 address bytes and 4 data bytes.
The address refer to long words, In other words address 0001 specifies
bytes 0004-0007.
'E' - Write 4 bytes to Probe A FRAM (starting at address 0 -> 511)
'F' - Write 4 bytes to Probe B FRAM (starting at address 0 -> 511)
'G' - Write 4 bytes to Main FRAM (starting at address 0 -> 511)
'H' - Write 4 bytes to uP's EEPROM (starting at address 0 -> 31)
RESPONSE: 1. Write 4 data bytes to memory if arguments received in time, then
respond with a 'P' (probe), 'M' (Main), or 'U' (EEprom).
2. Respond with an 'A' if no address was sent in time.
3. Respond with a 'd' if not enough data arguments were received.
4. Respond with an 'R' if the address was out of range.
I. Sleep mode - put the Device into long term data collection mode
'm' <Argument1> <Argument2> -> Enter Sleep Mode
RESPONSE:
1. Respond with an 'S' and Go to sleep if arguments were received.
2. Respond with an 'E' if arguments were not received in time.
ARGUMENT FORMAT: <'00ccpptt'> <'tttttttt'>
1. 'cc': The channel/probe selection bits.
00 = A0; 01 = A0 & A1; 10 = A0 & B0; 11 = A0 & A1 & B0 & B1
2. 'pp': The basic sleep interval.
00 = 2 Sec; 01 = 4 Sec; 10 = 8 Sec; 11 = 16 Sec
3. 'tt tttttttt': Determines the basic sleep intervals between
samples taken (1-1024)
DURATION: There is enough FRAM memory to store a 16 byte Data header block
and 508 four byte data samples. This combined with the basic sleep
interval (2 to 16 Seconds) and the number of intervals per sample (1
thru 1024) gives a minimum sleep time for 1 channel of 16.9 Minutes
[(2 * 1 * 508)/60], and a maximum time of 96.3 Days [(16 * 1024 *
508)/60/60/24]. This will be reduced if multiple channels are sampled.
OPERATION: The device wakes up every basic sleep interval and determines
whether enough intervals have elapsed to take a sample, based on
'tt tttttttt'. If not, it flashes the LED for 50 mS and goes back
to sleep. If so, it flashes the LED for 150 mS and takes and stores
the samples and then goes back to sleep. Before taking a samples,
it powers up the 5V lines to the probes and sets the Probe's DIO2
lines as requested. After taking a sample it resets them.
TERMINATION of SLEEP MODE:
1. When main FRAM is full (508 samples), the Device will turn itself off.
2. If the user presses the RED button and an active host is connected,
the Device will quit sleep mode and return to Command mode.
3. If the user presses the RED button and no active host is connected,
the Device's LED will flash for 50 mS and return to sleep mode.
FRAM MEMORY USAGE: The current Device uses a RAMTRON FM24CL16 FRAM memory
chip (2,048 bytes), and the firmware divides this into 512 four byte
blocks for purposes of data storage.
The Sleep mode uses the first 4 of these blocks to keep track of the
circumstances of the data collection process, and the rest of the
memory (508 blocks) for data storage - 1 of these blocks to store
every datum acquired. The format of the first four blocks is as follows:
1. Block 0 (0->3) - Holds a signature and the amount of data collected.
Bytes 0 & 1 hold FEFEh, a unique signature, and bytes 2 & 3 are the
data amount (MSB first). This number is managed by the device's
firmware.
2. Block 1 (4->7) - Holds the configuration information for the data
collected. Bytes 4 & 5 hold a unique signature (FEFEh), and bytes
6 & 7 hold the arguments that started the sleep process. These
locations are managed by the device's firmware.
3. Block 2 (8->11) - Holds host defined information for the data
collected (perhaps the date/time in a standard format). These
locations are managed by the Hosts's software.
4. Block 2 (12->15) - Holds host defined information for the data
collected. These locations are managed by the Hosts's software.
OTHER DETAILS:
1. The device uses battery or wall wart power during sleep mode.
J. Playback of sleep mode data.
'o' -> Initiate playback
RESPONSE:
1. If there is no data stored, send an 'N'.
2. If there is data stored, Send it back as AD24 data.
K. Retrieve Version, Memory, Status, and Voltage information
'v' - Get the Device's version information
RESPONSE: Returns firmware version: i.e. 'CCA2D2v0.88 [Hb 11/01 WCL]'
'n' - Get the Device's Main FRAM memory information
RESPONSE: Returns main FRAM memory information as 'M:0002 F08h',
M:xxxxh: xxxx = memory data amount in hex
F08h signals the 8KB FRAM Part is in stalled
F02h signals the 2KB FRAM Part is in stalled
'w' - Get the Device's status information
RESPONSE: Returns status information as 'Vxxxx Bxxx Sxxx Wxxx Pxx'
Vxxxx: xxxx = characters 8, 9, 10, & 11 of the Device's ID string
Bxxx: xxx = 0->255, where 255 = +3.2 Volts on the battery
Sxxx: xxx = 0->255, where 255 = +7.8 Volts from the Serial Handshake
Wxxx: xxx = 0->255, where 255 = +5.0 Volts from the Wall Wart
Pab: ab = Presence (1) or absence (0) of Probes in Port A and B
Example response: V0.91 B220 S202 W025 P00
To convert the value returned from the battery status into voltage use
the following formula:
battery_voltage = battery_raw_status / 255 * 3.2 Volts
To convert battery voltage into charge:
battery_charge = (battery_voltage - 1.8 Volts) / 1.4
Using the example response above the Battery voltage is 2.76 Volts
and the charge is 69%. The voltage on the serial port line is 6.18
Volts and for some reason there is 0.49 voltas measured on the input
from the wall.
'u' - Get the Probe's 5V line status information
RESPONSE: Returns status information as 'Axxx Bxxx !'
Axxx: xxx = 0->255, where 255 = +7.5 Volts at probe A
Bxxx: xxx = 0->255, where 255 = +7.5 Volts at probe B
L. Misc Commands.
'y' <Argument> -> Immediately control The Probe's 5 Volt power and DIO2 lines
RESPONSE:
1. Set the Probe's power and DIO2 lines as requested and return 'P'
2. Respond with an 'E' if argument was not received in time.
ARGUMENT FORMAT: <'0000abAB'>, where A and B represent the desired
state of the respective probe's 5 Volt power line, and a and b
represent the state of the probe's DIO2 lines.
'q' <Argument> -> Set or read the DIO2's status mask (used in Data mode)
RESPONSE:
1. Set the Probe's DIOs pins status mask as requested and return 'M
2. If argument was not received, the current mask byte is sent back.
ARGUMENT FORMAT: <'000000AB'>, where A and B represent the desired
state of the respective probe's DIO2 line.
'p' - Check the crystals' accuracy. _DIOA2 pulses 60 mS during 32kHz count.
RESPONSE: Returns 60 mS 32 kHz crystal count as 2 byte Hex (trailing 'h')
Should be '07AEh' (1966 -> 32,768 * .060)
M. Development Routine Commands.
'z', 'x', '0', '9', '*', '1' thru' '8'
RESPONSE: Respond with a 'Tst?' if no routine is currently programmed.
It is unpredictable what these commands might do at any given time.
N. Any unused keys.
RESPONSE: Respond with a '?'
GENERAL NOTES:
1. Most commands have a response upon completion - it is advisable to
wait for the response (or a known period) before issuing the next
command. Sometimes there is a delay in completing the process, during
which time the interface can be blind. The most obvious example is the
EEPROM write -> When Writing 4 bytes to the uP's EEPROM, the response
('U') should be back about 21 mS after start of the 6.2 mS (4 byte)
transmission.
2. Multiple byte commands will only wait for slightly less than 1 extra
byte time before declaring an error.
Firmware Change History
10/30/01: version 'CCA2D2v0.88'
1. Read and write commands now have a 2 byte address argument, instead of 1.
'A','B','C','D': Read data from Probes FRAM, Main FRAM, uP's EEPROM.
'E','F','G','H': Write data to Probes FRAM, Main FRAM, uP's EEPROM.
2. Sleep mode is now functional
'm' <2 arguments>: Put the Device into long term data collection mode
'o': Playback of sleep mode data.
3. A memory info command has been added
'n': Get the Device's Main FRAM memory information
4. The ability to specify the state of the probe's DIO2 line has been added
'q': Set or read the DIO2's status mask (used in Data mode)
12/21/01: version 'CCA2D2v0.89'
1. Implement a timing measurement command
'p': Check the crystals' accuracy.
2. Add immediate DIO2 control.
'y': Add immediate DIO2 control to 5V control in bits 2 and 3
3. Streaming mode delayed start bug was fixed, Sleep data preface implemented.
3. LED Status Indication
The device's side mounted LED indicator can be an aid to help ascertain what the device's status is. The indicator's Flash Pattern are:A. At startup when powered up by the serial port
10 X 170 mS flashes in the first 3.8 Seconds
B. Command mode: 1 X 333 mS flash every Second
C. 24 Bit A2D: 2 X sequential 170 mS flashes every second
D. 10 Bit A2D: 3 X sequential 80 mS flashes every 644 mS
E. Rotary: 4 X sequential 80 mS flashes every 1270 mS
F. When the device is not on, and the RED button is pressed:
1. Has Data (battery OK or Wall wart) - 3 X 170 mS flashes and then Dies
2. No Data, has good battery - 2 X 170 mS flashes and then Dies
3. With weak battery - 6 X 170 mS flashes and then Dies
G. When the device is in sleep Mode:
1. 50 mS flash every basic sleep mode period.
2. 150 mS flash every time data is collected.
3. 50 mS flash when the RED button is pressed (with no wall wart).
4. Wakes up when the RED button is pressed with wall wart.
4. Interface Calibration
After an A2D2 interface is tested, serialized, and calibrated the following data are stored in 4-bytes blocks in the EEPROM on the microprocessor (results are stored Big Endian Format - MSB first):Block 0: Unit's device Type as 4 byte ASCII String ('INT2' for this device).
Block 1: Unit's Serial Number as 4 byte ASCII String ('0000'->'9999').
Block 2: Unit's Manufacture date as 4 byte MAC date format.
Block 3: Unit's Last Calibration date as 4 byte MAC date format.
Block 4: Unit's 2.5 V calibration as 00h & 24 bit unsigned integer
Block 5: Unit's 3.3 V calibration as 00h & 24 bit unsigned integer
Block 6: Unit's 5.0 V calibration as 00h & 24 bit unsigned integer
The data in location 4 can be used by an external program to calibrate the A2D2's internal precision 2.5 Volt reference that is used for analog to digital conversions. The value saved in location 4 is the average of the Port A and B 24-bit conversion of the 2.048 voltage reference supplied by the tester.
Here's the basic (non-optimized) calibration algorithm.
eeprom_2.5_calibration = data_in_eeprom_location_4
vref2.5_calibration = (2.048 / 2.5 * 2^24) / eeprom_2.5_calibration
adc24_raw_voltage = adc24_normalized_raw_data / 2^24 * 2.5 Volts
adc24_calibrated_voltage = adc24_raw_voltage * vref2.5_calibration
The data in locations 5 and 6 can be used in a similar manner to determine the nominal values for the 3.3 and 5.0 Volt A2D2 power buses. The data saved in the eeprom are the 24-bit adc conversions of the power buses as measured with 1% precision resistor dividers designed to nominally create a 2.300 Volt reference derived from 3.3 V power rail and a 1.800 Volt reference derived from the 5 V power.
