A SERVICE OF

logo

ANALOG INPUT SECTION 10
Page 10-2 RPC-320
following tables for differential inputs.
When channel = odd
Pol. - + - + - + - +
CH # 0 1 2 3 4 5 6 7
channel 1 3 5 7
When channel = even
Pol. + - + - + - + -
CH # 0 1 2 3 4 5 6 7
channel 0 2 4 6
When range = 0, the input is ±2.5 volts and a 1 = 0 to
5 volts.
Differential Mode
When differential m ode is specified, inputs are actually
pseudo-differential. What this means is that a ground
reference is needed. For example, you cannot place a
battery between channel 0 and 1 and get an accurate
reading. The (-) input must be referenced to ground.
An example of where pseudo-differential works is an
output from a bridge network.
A pseudo-differential input subtracts the DC component
from an input. The IC maker recommends the (-) input
remain stable within 1 count with respect to ground for
best results. Connecting a 0.1 uF capacitor from the (-)
input to ground works well.
When operating in differential mode, relative + and -
voltages must be connected to specific inputs. When
inputs are reversed, a conversion returns a 0. When the
relative voltage changes, perform a conversion on the
alternate channel. CONFIG AIN is performed on both
channels.
Pairs of channels can be differential while others single
ended. Thus, if channel 0 and 1 are differ ential inputs,
channels 2-7 may be single ended.
Examples using CONFIG AIN
Below are sample syntaxes for CONFIG AIN
Differential, 0 to + 5V input
CONFIG AIN 0,0,1
CONFIG AIN 1,0,1
Perform a conversion as normal:
A = AIN(0)
The difference between channel 0 and 1 is returned.
When channel 1 is more positive than channel 0, the
result is zero. The difference is read on channel 1 by
performing:
A = AIN(1)
Single-ended, ±2.5V input
CONFIG AIN channel,1,0
The result is 0 for -2.500V input, 2048 for 0.000V, and
4095 for + 2.4988V.
Acquiring Analog Data
Analog data is accessed with the AIN function. The
syntax is:
A = AIN(channel)
This function assigns the analog value of a channel to the
variable; A in this case. The value returned is always in
the 0 to 4095 range because the converter is 12 bits.
Power up or reset default configures inputs to the 0-5V
range, single ended.
To view the result of a conversion in the command
mode, type:
print ain(0)
The result at channel 0 is returned. The returned value
will always be in the 0 to 4095 range. When using a
channel in the ±2. 5V range, the value returned is
interpreted differently. Zero count is now -2.500V,
4095 is + 4.9988, and 2048 is 0.000V.
Use the following formulas to convert a returned number
to a voltage:
0 - 5V A = .001221 * AIN(channel)
±2.5V A = .001221 * ain(channel) - 2.5
The AIN function requires about 1.5 ms to convert the
data. Additional time is needed to store the data. The
example below takes 255 data samples and stores them