Analog outputs, Programming example, Analog outputs programming example – Spectrum Brands MI.20xx User Manual

Page 83

Advertising
background image

Option Extra I/O

Analog Outputs

(c) Spectrum GmbH

83

Analog Outputs

In addition to the digital I/Os there are four analog outputs available. These outputs are directly programmed with the voltage values in mV.
As the analog outputs are driven by a 12 bit DAC, the output voltage can be set in a stepsize of 5 mV. The table below shows the registers,
you must write the desired levels too. If you read these outputs, the actual output level is given back from an internal software register.

After programming the levels of all analog outputs by the registers above, you have to update the analog outputs. This is done by the register
shown in the table below. To update all of the outputs all you need to do is write a “1“ to the dedicated register.

Programming example

The following example shows how to use either the digital I/O#s and the analog outputs.

Register

Value

Direction

Description

Offset range

SPC_XIO_ANALOGOUT0

47120

r/w

Defines the output value for the analog output A0.

± 10000 mV in steps of 5 mV

SPC_XIO_ANALOGOUT1

47121

r/w

Defines the output value for the analog output A1.

± 10000 mV in steps of 5 mV

SPC_XIO_ANALOGOUT2

47122

r/w

Defines the output value for the analog output A2.

± 10000 mV in steps of 5 mV

SPC_XIO_ANALOGOUT3

47123

r/w

Defines the output value for the analog output A3.

± 10000 mV in steps of 5 mV

Register

Value

Direction

Description

SPC_XIO_WRITEDACS

47130

w

All the analog outputs are simultaniously updated by the programmed levels if a “1“ is written.

// ----- 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

Advertising