Programming example – Spectrum Brands MC.31XX User Manual
Page 88
88
MC.31xx Manual
Programming example
Option Extra I/O
Programming example
The following example shows how to use either the digital I/O#s and the analog outputs.
// ----- output 8 bit on D7 to D0 and read 8 bit on D15 to D8 -----
SpcSetParam (hDrv, SPC_XIO_DIRECTION, XD_CH0_OUTPUT | XD_CH1_INPUT); // set directions of digital I/O transfer
SpcSetParam (hDrv, SPC_XIO_DIGITALIO, 0x00005A); // write data to D7-D0
SpcGetParam (hDrv, SPC_XIO_DIGITALIO, &lData); // read data and write values to lData
// ----- write some values to the analog channels. -----
SpcSetParam (hDrv, SPC_XIO_ANALOGOUT0, -2000); // -2000 mV = -2.0 V
SpcSetParam (hDrv, SPC_XIO_ANALOGOUT1, 0); // 0 mV = 0.0 V
SpcSetParam (hDrv, SPC_XIO_ANALOGOUT2, +3500); // 3500 mV = 3.5 V
SpcSetParam (hDrv, SPC_XIO_ANALOGOUT3, +10000); // 10000 mV = 10.0 V
SpcSetParam (hDrv, SPC_XIO_WRITEDACS, 1); // Write data simultaneously to DAC