User`s manual

XP8500
46 s Software Reference
Sample program ADC4SMP3.C also shows how to recalibrate
an XP8500 channel and how to store the new calibration
constants in the EEPROM.
Check the board jumpers, PLCBus connections, and the PC/
controller communications if an error message appears.
See the Dynamic C Technical Reference manual for more
detailed instructions.
!
!
$
adc4_readcoeff(adc4_board, 2, &ADC4conv2);
// read cal for chan2
adc4_readcoeff(adc4_board, 3, &ADC4conv3);
// read cal for chan3
printf(“Chan0 Calibration, zero_offset =
%d, invgain = %f\n”, ADC4conv0.zero_offset,
ADC4conv0.invgain);
printf(“Chan1 Calibration, zero_offset =
%d, invgain = %f\n”, ADC4conv1.zero_offset,
ADC4conv1.invgain);
printf(“Chan2 Calibration, zero_offset =
%d, invgain = %f\n”, ADC4conv2.zero_offset,
ADC4conv2.invgain);
printf(“Chan3 Calibration, zero_offset =
%d,invgain = %f\n”, ADC4conv3.zero_offset,
ADC4conv3.invgain);
printf(“Toggle F4 (DOS only) to make
keyboard input active as STDIO.\n”);
printf(“Hit any key to read A/D data from
XP8500 board.\n”);
for(;;) {
while(!kbhit()) runwatch(); // wait for
// key from the PC
getchar(); // get the key
data0 = adc4_read(adc4_board, 0);
// read A/D Channel 0
data1 = adc4_read(adc4_board, 1);
// read A/D channel 1
data2 = adc4_read(adc4_board, 2);
// read A/D channel 2
data3 = adc4_read(adc4_board, 3);
// read A/D channel 3
printf(“\nData for ADC4 channels 0-3 !!!\n”);
printf(“chan 0 >> %6d, %8.3f volts\n”,data0,
adc4_convert(data0, &ADC4conv0));
printf(“chan 1 >> %6d, %8.3f volts\n”, data1,
adc4_convert(data1, &ADC4conv1));
printf(“chan 2 >> %6d, %8.3f volts\n”, data2,
adc4_convert(data2, &ADC4conv2));
printf(“chan 3 >> %6d, %8.3f volts\n”, data3,
adc4_convert(data3, &ADC4conv3));
}
}