
RPBASIC-52 PROGRAMMING GUIDE
2-2
AIN
Syntax: AIN(channel)
Where: channel = 0 to 7, is channel to convert.
Function: Converts analog input to digital number and returns a number from 0 to 4095 (0 to 1023 for the RPC-
52)
Mode: Command, Run
Use: B = AIN(N)
Cards: RPC-52, RPC-320, RPC -330. RPC-52 range is 0 to 1023 (10 bit).
DESCRIPTION
AIN returns a number corresponding to the input voltage. A number from 0 to 4095 (0 to 1023 for RPC-52)
is returned. The result is returned in under 2 ms. Input voltage may be 0-5V or ±2.5 volts, single ended or
differential. Inputs are configured for 0-5V, single ended input on power up. Use CON FIG AIN to configure
each channel's cha racteristics.
The RPC-52 does not have differential inputs or use CONFIG AIN. Refer to the RPC-52 hardware manual
for more information. The following explaination assumes a 12 bit result (0 to 4095) is returned.
A result is scaled to obtain a result representing a physical quantity. The general equation is:
variable = K * AIN(n)
where K is a scaling constant and n is the channel number. The scaling constant is determined as follows:
K = (maximum quantity - minimum quantity) / 4096
The physica l quantity can be volts, curre nt, press ure, inches, or w hatever me asurem ent you are ta king.
"maxim um quantity" is the number with its output at 5 volts while "m inimum quantity" is the num ber at 0
volts. Usually, the minimum quantity is 0.
Suppose you have a 0-200 PSI pressure transducer with a 0-5V output. To compute the constant for one
PSI/count, divide the pressure over the resolution:
K = 200/4096
K = 0.04828 = PSI change per count
To measure 0-5 volts, K = 0.001220703
RELATED
CONFIG AIN
ERRORS
BAD ARGUMENT When channel expr > 7 or negative
BAD SYNTAX When channel expr left out
Komentáře k této Příručce