HP (Hewlett-Packard) B Network Router User Manual


 
C Language Example (16-bit readings)
/* dynamically allocate memory for readings */
rdgs = malloc(20 * sizeof(int));
/* set number of bytes placed in memory, and number of bytes read */
swap = sizeof(int);/* place 2 bytes/reading in memory */
bytes = 20 * swap;/* read 40 bytes */
IOOUTPUTS(ADDR, "READ?", 5);/* retrieve the readings */
IOENTERAB(ADDR, rdgs, &bytes, swap); /* enter the readings */
/* and remove the block header */
/* Remove line feed which trails the last data byte */
length = 1;
IOENTERS(ADDR, lf_remove, &length);
The command which removes the block header from the readings is
IOENTERAB. The parameters passed to IOENTERAB are:
ADDR - the address of the digitizer
rdgs - the array name which will store the readings
bytes - a variable specifying the maximum number of bytes to be read
swap - a variable specifying how the bytes are placed into memory
(2 bytes per reading)
Converting Packed
Readings
The equation for converting packed readings is:
reading
voltage
= (reading
packed
/ 16) * reading resolution
Reading resolution is a function of the signal range. The resolutions for the
digitizer signal ranges are given in Table 3-2.
Signal Range Resolution Signal Range Resolution
-0.1023 to 0.10235
-0.2046 to 0.2047
-0.5115 to 0.51175
-1.0230 to 1.0235
-2.0460 to 2.0470
0.00005
0.00010
0.00025
0.0005
0.0010
-5.115 to 5.1175
-10.230 to 10.235
-20.460 to 20.470
-51.15 to 51.175
-102.30 to 102.35
0.0025
0.005
0.010
0.025
0.05
Table 3-2. Reading Resolutions for Packed Data Conversions
136 Understandin
g
the HP E1429 Di
g
itizer Chapter 3