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 The equation for converting packed readings is:

Readings

readingvoltage = (readingpacked / 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.

Table 3-2. Reading Resolutions for Packed Data Conversions

Signal Range

Resolution

Signal Range

Resolution

 

 

 

 

 

 

 

 

-0.1023 to 0.10235

0.00005

-5.115 to 5.1175

0.0025

-0.2046 to 0.2047

0.00010

-10.230 to 10.235

0.005

-0.5115 to 0.51175

0.00025

-20.460 to 20.470

0.010

-1.0230 to 1.0235

0.0005

-51.15 to 51.175

0.025

-2.0460 to 2.0470

0.0010

-102.30 to 102.35

0.05

 

 

 

 

 

 

 

 

136 Understanding the HP E1429 Digitizer

Chapter 3

Page 136
Image 136
HP E1429A manual Readings, Language Example 16-bit readings