Void anaout(int channel, int value) – Digi JACKRABBIT BL1800 User Manual

Page 57

Advertising
background image

User’s Manual

53

The output value is set using the following function.

sets the state of an analog output channel.

jrioInit

must be called first.

channel

is the output channel number (0 or 1 on the Jackrabbit).

value

is an integer from 0–1024 that corresponds to an output voltage as shown in Table 5.

NOTE: See the sample program JRIOTEST.C for examples of using the anaOut func-

tion.

Effect of Interrupts on Analog I/O

The stability of the voltage output (and hence the voltage input determination as well)
depends on the ability of the driver to respond quickly to interrupt requests. Dynamic C
debugging, use of the

printf

function, or any serial communications can disrupt the

pulse-width modulation utilized by the driver and cause fluctuations in the voltage out-
puts. Avoid using serial communications or

printf

statements during portions of your

program where the voltage must remain steady. Also be aware that debugging and running
Dynamic C in polling mode will cause fluctuations. Finally, be certain to disable the PWM
drivers by setting the output values to 0 or 1024 when you are done using them to free up
the CPU.

Calibration of Values to Voltages

The analog output channels on the Jackrabbit can be more accurately calibrated for each
individual Jackrabbit in the following manner (calibration of DA0 is assumed in this
example, calibration of DA1 would proceed similarly):

Set desired channel output to

PWM_MIN

.

Measure voltage V

min

on DA0.

Set desired channel output to

PWM_MAX0

.

Measure voltage V

max

on DA0.

A linear relation between input value and voltage can now be calculated:

Table 5. Typical Analog Output Voltages Corresponding

to Values in anaOut Function

Channel

0

PWM_MIN

PWM_MAX

1024

DA0

0.08 V

0.08 V

2.875 V

3.4 V

DA1

0.004 V

0.63 V

3.6 V

3.6 V

void anaOut(int channel, int value);

b

V

max

m

PWM_MAX0

Ч

=

Advertising