beautypg.com

Rpbasic-52 programming guide – Remote Processing BASIC 52 User Manual

Page 21

background image

RPBASIC-52 PROGRAMMING GUIDE

2-2

AIN

Syntax:

A I N (channel)
Where: channel = 0 to 7, is channe l to convert.

Function:

C o n v er t s a n a lo g in p u t t o di g it a l n u m b er a nd r et u rn s a n u m b er f ro m 0 to 4 0 95 ( 0 t o 10 2 3 fo r th e R P C -
52)

Mode:

Comm and, Run

Use:

B = A I N (N )

Cards:

RPC -52, RPC -320, RPC -330. RPC -52 range is 0 to 102 3 (10 bit).

D E S C R IP T I ON

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 configu red for 0-5V, single e nded input on p ower up. U se CON FIG AIN to configure
each chann el's cha racteri stics.

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 cha nnel number. The scaling constan t is determined as follows:

K = (maximum quantity - minimum quantity) / 4096

The p hysica l quan tity can be vol ts, curre nt, press ure, inc hes, or w hatev er me asurem ent yo u are ta king.
"maxim um quan tity" is the numb er with its output at 5 v olts 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

CON FIG AIN

ERRORS

B A D A R G U M E N T When channel expr > 7 or negative
B A D S Y N T A X

When channel expr left out