User`s manual

XP8600 Software Reference s 35
6. Power up the controller and bring up Dynamic C on the PC.
7. Open and run the sample program DASAMPL1.C in the Dynamic C
SAMPLES\PLCBUS subdirectory .
8. The LED will increase and decrease in intensity as the program runs.
9. If the LED does not light up at all, its polarity may be reversed. Try
turning the circuit around, connecting the LED at V/I1 and the resistor
at GND.
Program
The program demonstrates how to drive the XP8600 in voltage output
mode. The program first polls the PLCBus, looking for XP8600s. It saves
the highest address found. The program then increments the voltage at
both output channels on the selected board. When it reaches maximum
voltage, it resets the voltage to zero and repeats the process indefinitely.
The setup requires a 1 k resistor and LED in seriesor a volt-ohm meter
between V/I1 and GND on header H1 to show the behavior of the program.
DASAMPL1.C
main(){
int i, log_addr, hi_addr;
reset_pbus(); // reset all boards on PLCBus
hitwd();
reset_pbus_wait(); // delay after reset
// Locate XP8600s; save highest addr found
for( log_addr=0; log_addr<64; log_addr++ ){
if( find_dac(log_addr) ) hi_addr = log_addr;
}
// Set PLCBus to XP8600, initialize DAC
set12adr( plcdac_addr(hi_addr) );
dac_init(); // initialize both channels
// Increment Voltages on Channels out 1 and 2
while(1){
for( i=0; i<4097; i++ ){
plc_fdac1(i); // fdac1 (fast but big),
// writes to DAC channel 1
dac_latch1(); // convert data
plc_sdac2(i); // sdac2 (slower, smaller),
// write to DAC channel 2
dac_latch2(); // convert data
hitwd():
}
}
}