User`s manual

Exp-A/D12
72 s Software Reference
5. Power up the controller and bring up Dynamic C on a PC. Consult the
controllerī‚’s userī‚’s manual if there are any problems re-establishing
communications between the PC and the controller.
6. Open and run the sample program ADSAMPL1.C.
7. Dynamic C will begin displaying voltage output from the TEMP pin.
8. Place a finger on the U1 chip (LT1019) case. The voltage and
temperature readings should increase after a few seconds; the readings
will decrease when the finger is removed.
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.
ADSAMPL1.C
#define AN0 0
// global(!) signal table - one entry
#define TEMP 0
struct signal_rec adtab[1];
main(){
int i, board;
int mode = 10; / / A/D mode 10 (gain=2, unipolar)
int comp = 1; // use EEPROM compensation
float avg, tempC, sum;
Reset_PBus(); // Always do this!
Reset_PBus_Wait();
board = plcad_addr(3); // PAL 0, J1 unjumpered
// Make entry in signal table
add_sig_table( TEMP, board, AN0, mode, comp );
// Set mux for this signal, allow MUX to settle
set_mux(TEMP); mxdel18();
while( 1 ){ // loop forever
// Read signal 1000 times, take average
sum=0.0;
for( i=0; i<1000; i++ ){
sum += ad_conv( TEMP, plad_rd12(adch(TEMP)) );
}
avg = sum / 1000;
// convert to temperature, display on screen
tempC = (avg / 0.0021) - 273;
printf(ā€œ%f Volts %5.2f Degrees\nā€,avg,tempC );
}
}
!
$