Acquiring Digital Sensor Measurements

Acquiring Digital Sensor
Measurements
Tech Note 411
Overview
Digital measurements can be acquired directly from Measurement Specialties digital sensors using custom software written
using a variety of programming tools available today. The digital sensor’s configuration is assumed to have been set using
the Instrument Configuration Utility (ICU), thus allowing interpretation of the returned data values as described later.
The following steps are required to acquire a Digital Sensor measurement:
Needed only once at startup:
1. Send a Synchronize command to cause all attached sensors to lock on to the controller’s baud rate.
2. Wait for at least 128 milliseconds to allow attached sensors to process the Synchronize command.
3. Send a Listen command to enable the Digital Sensor to process commands
4. Wait for the sensor to acknowledge processing of the Listen Command
Repeated operations needed once to retrieve each measurement set:
1. Send the Write Register command to write the data address to the address register
2. Wait for the sensor to acknowledge processing of the Write Register Command
3. Use the Write Data @ Address command to write a zero to trigger a measurement cycle
4. Wait for the sensor to acknowledge processing of the Write Data @Address command
5. Use the Write Register command to write the data address to the address register (to reset the address)
6. Wait for the sensor to acknowledge processing of the Write Register command
7. Send the Read Data @ Address command to read data from the sensor
8. Wait for the sensor to return the measurements
9. Convert measurement to desired units by applying channel gain and offset as set in ICU
Typically, it is common to read all device channels, representing one set of synchronously sampled data. The
example at the end of this Tech Note demonstrates how 4 channels may be read from a typical triaxial
accelerometer, which returns 3 accelerations and 1 temperature measurement with each request.
Message Protocol Details
Each message transmitted to or received from a Measurement Specialties digital sensor is framed with a 1-byte command
header and a 2-byte cyclic redundancy check (CRC). The CRC is of the type CRC16 and is computed from the header and
data sections of the message preceding the CRC. Example code to compute a CRC16 is shown in Tech Note 410. Invalid
messages received by a sensor are discarded and not acknowledged.
The 1-byte command header of each message specifies the number of bytes requested or sent in the upper five bits:
7
6
5
4
3
2
1
Length (Bytes/Blocks)
Flag
Command
when Flag = 0, Length is number of 16-byte blocks (1-16)
when Flag = 1, Length is number of bytes (0-15)
0
Some instruments, like the 35203A, are limited to sending a maximum of 1 Block (16 bytes) in a single message.
TN 411: Acquiring Digital Sensor Measurements
precisionsensors.meas-spec.com 2236 N. Cleveland-Massillon Road
Akron OH 44333 PH : 330-659-3312 7/24/2013
www.meas-spec.com
Channel measurements are typically located occupying 2 bytes per channel starting at address 0x000002E0:
Chn
1
2
3
4
Address
0x000002E0
0x000002E2
0x000002E4
0x000002E6
Chn
5
6
7
8
Address
0x000002E8
0x000002EA
0x000002EC
0x000002EE
Chn
9
10
11
12
Address
0x000002F0
0x000002F2
0x000002F4
0x000002F6
Chn
13
14
15
16
Address
0x000002F8
0x000002FA
0x000002FC
0x000002FE
Addresses are sent low-byte first as 32-bit values, for example 0x000002F0 is sent as 0xF0, 0x02, 0x00, 0x00.
CRCs are sent low byte first as 16-bit values, for example 0x06C0 is sent as 0xC0, 0x06.
Each 16 bit data value is stored and sent high byte first (e.g. channel 0 high byte is at 0x02E0 and the low byte is at
0x02E1), For example, if a channel’s data is 0x1234, it will be sent as 0x12 followed by 0x34.
Example
The first step is to set the instrument’s baud rate and tell the device to listen; needs to be done only once in a simple
system with only one sensor:
Setup
Step
1
2
3
Sent by Controller
0xF8
Wait
0x18
0x01
0xCB
0xC0
Reply from 65210 Series System
Synchronize command from Controller
Controller waits at least 128 milliseconds
Listen command from Controller
Device ID 1 (factory default ID)
\ CRC
/
4
0x0D
0xC1
0xC5
Ack (listening) from Instrument
\ CRC
/
Then a measurement set (similar to a scan except simultaneously sampled) can be read using the following
commands:
Read Each Channel Set (Scan)
Step
1
Sent by Controller
0x4C
0xE0
0x02
0x00
0x00
0x87
0xCE
Reply from 65210 Series System
Write Address Register from Controller
\
\ Channel 1
/ Address
/
\ CRC
/
2
TN 411: Acquiring Digital Sensor Measurements
precisionsensors.meas-spec.com 0x0D
0xC1
0xC5
Ack (new address set) from Instrument
\ CRC
/
2236 N. Cleveland-Massillon Road
Akron OH 44333 PH : 330-659-3312 7/24/2013
www.meas-spec.com
3
0x1D
0x00
0x09
0x50
Write Data @ Address from Controller
Write Zero to Address
\ CRC
/
4
5
0x4C
0xE0
0x02
0x00
0x00
0x87
0xCE
8
9
0x8F
0x41
0xA4
Ack (data written) from Instrument
\ CRC
/
0x0D
0xC1
0xC5
Ack (new address set) from Instrument
\ CRC
/
Write Address Register from Controller
\
\ Channel 1
/ Address
/
\ CRC
/
6
7
0x0D
0xC1
0xC5
Read 8 bytes command from Controller
\ CRC
/
0x8D
Returning 8 bytes from Instrument
<hi byte> \ Channel 1 Counts
<lo byte> /
<hi byte> \ Channel 2 Counts
<lo byte> /
<hi byte> \ Channel 3 Counts
<lo byte> /
<hi byte> \ Channel 4 Counts
<lo byte> /
<lo crc> \ CRC
<hi crc> /
Apply ICU channel gain & offset - see Tech Note 421: Converting Measurement Values to Engineering Units
Alternate Method Using Scripts
There is an alternate method to perform I/O that uses built-in “scripts” that are stored inside the instrument. These scripts
allow for commands that would normally be sent over the RS-485 communications link to be executed out of built-in
memory.
TN 411: Acquiring Digital Sensor Measurements
precisionsensors.meas-spec.com 2236 N. Cleveland-Massillon Road
Akron OH 44333 PH : 330-659-3312 7/24/2013
www.meas-spec.com
It is outside the scope of this document to discuss script programming, but these non-volatile scripts may be easily
changed using ICU to suit specific customer requirements. For the following examples, the instrument must be configured
with ICU to have the Script setting on the main page set as follows (colors for clarity only):
3C0002DF1D006F093C0002DF1D008F09
This setting provides two separate scripts, shown above in blue and green. One is at location 0x2b and will return the first
3 channels of data (normally A1, A2, and A3). The seconds script is at 0x33 and returns 4 channels, thus includes T1 temperature. The following example shows how the first script is used:
Setup
Step
1
2
3
Sent by Controller
0xF8
Wait
0x18
0x01
0xCB
0xC0
Reply from 65210 Series System
Synchronize command from Controller
Controller waits at least 128 milliseconds
Listen command from Controller
Device ID 1 (factory default ID)
\ CRC
/
4
0x0D
0xC1
0xC5
Ack (listening) from Instrument
\ CRC
/
Read Channel Data Using Script - Repeat as Needed
Step
1
Sent by Controller
0x59
0x00
0x2B
0x00
0x00
0x00
0x05
0x2D
Reply from 65210 Series System
Jump to address command from Controller
Mask
\
\ Script
/ Address
/
\ CRC
/
2
TN 411: Acquiring Digital Sensor Measurements
precisionsensors.meas-spec.com 0x6D
<hi byte>
<lo byte>
<hi byte>
<lo byte>
<hi byte>
<lo byte>
<lo crc>
<hi crc>
Returning 6 bytes from Instrument
\ Channel 1 Counts (e.g. A1)
/
\ Channel 2 Counts (e.g. A2)
/
\ Channel 3 Counts (e.g. A3)
/
\ CRC
/
2236 N. Cleveland-Massillon Road
Akron OH 44333 PH : 330-659-3312 7/24/2013
www.meas-spec.com