beautypg.com

Computer programming – Vernier LabPro User Manual

Page 21

background image

Revision Date: 08/02/02

LabPro Technical Manual

21

Computer Programming

Basic communications


Commands are sent using the following format:

s{command number, parameter 1,…, parameter n}

where the command number is required followed by one or more parameters that may or may not be
required (see command reference section).


Data is returned either automatically or by requesting data by sending: the character "g".


Before you start programming, it is a healthy exercise to spend some time with a terminal program
(Hyperterm for Windows or Zterm for Mac are two examples) sending commands and receiving data.

Data Formats

ASCII Data

Numbers are returned as ASCII representation of 32-bit floating point numbers in the format of


sm.dddddEsee (sign mantissa_digit . digit digit digit digit digit E sign exponent exponent)

Hex Data

Binary mode is requested by the command {4,0, -1} but is only supported on the active analog and motion
channels. It reports the raw ADC output (i.e. calibration equations and derivatives are ignored). The data
format is 16 bits of ADC output that is zero filled, left justified according to the interfaces ADC resolution.

MSB LSB

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

| |

|<------- LabPro 12 bit data ----------| 0 0 0 0|

| or |

|<---- CBL2 10 bit data ------ | 0 0 0 0 0 0|

| |


The data is transferred most significant byte first. No carriage return or line feed is transmitted.


In real time sampling mode, all active channels plus the 32-bit time counter are returned.


Ch1_MSB Ch1_LSB ... ChN_MSB ChN_LSB T_MSB T_B2 T_B1 T_LSB Chk


Where CH1_MSB indicates the most significant byte of data from the lowest number channel that is
active. After all the data has been transferred for a sample point, a checksum is included verifying the data
integrity (serial port only, does not apply to USB communications). The checksum is a single byte
computed by exclusive-ORing all bytes in the line and ones-complementing the result.


For example, assume you request a single data point with time. LabPro will transmit the following bit
pattern for a data value 8CH, a time of 00e0H and the checksum of 93H:


0000-1000 1100-0000 0000-0000 0000-0000 0000-0000 1110-0000 1101-0111

16-bit data

32-bit time

ChkSum

In non-real-time sampling mode, all N data points for the current channel are returned. Less than N data
points will be returned if windowing is turned on with Command 5. Each successive "Get" iterates through