beautypg.com

Chapter 6 digital and opto ports, Digital i/o port – Remote Processing RPC-30 User Manual

Page 23

background image

CHAPTER 6

DIGITAL AND OPTO PORTS

RPC-30

Page 21

The pr ogram below take s 1,0 00 samp les and stor es it in
an arra y. T he time to read an d store 1, 000 samples is 2
seconds, or 2 ms per sample.

10

DIM F(1000)

20

FOR X = 0 TO 999

30 F(X) = AIN(1)
40

NEXT

Some applications require that measurements be made at
fixed interv als. T he ON TIC K constru ct can be used to
take samples at timed intervals. The progr am below
reads 2 channels every second and stores it into an array.
When the ar ray fills, the tick tim er stops.

10 DIM F(800,2)
20 ON TICK 1 GOSUB 100
30 ..This is a dummy loop
40 GOTO 30
100 F(I,0) = AIN(0)
110 F(I,1) = AIN(1)
120 INC I
130 IF I = 800 THEN ON TICK 1 GOSUB
140 RETURN

The A OT state ment outp uts to a modu le. T he numb er is
in the range of 0 to 4095. The value of the output from
the G5 module is in proportion to the number.

To output to a G5 module, execute the following
command:

1000

AOT

slot,value

slot ranges from 100 to 123 and corr esponds to the
number on an external opto rack. value ranges fr om 0 to
4095. The inter nal opto ra ck cannot be used for o utput.

Converting analog measureme nts

Input readings can be converted to usable units of
measurem ent by performing scaling calculations in the
progr am. The A IN func tion retur ns values fr om 0 to
511. To change these r eading to other units, use the
following calculation:

v a r ia b le = K * AI N (slot)

K is a scaling constant. It is obtained by diving the
highest measurement unit number by 511.

Example:

You want to measure a 0 to 200 PSI pressure
transducer with a 0 to + 5 volt output. Divide 200
by 511 to obtain the value of K.

K = 200 / 511
K = .3913894

To obtain the final value for the equation in PSI:

V = .3913894 * AIN (n)

DIGITAL I/O PORT

Digital I/O lines on the RPC-30 is supplied by an 82C55
chip. The chip' s lines go to connector J3.

Add 100 to CAM BASIC LINE and OP TO state ments to
access an individual port. For exam ple, line 3 on the
STB boar d is accessed a s LIN E 103, ON. Opto m odule
position M7 is accessed as OPTO(107).

The lines on J3 are divid ed into 3 eight bit gr oups. Ports
A and B can be configured as all inputs or outputs. Port
C can b e progr amed a s one gro up of 8 inputs or outputs
or as two groups of four lines (upper and lower C ). The
four lines in upper and lower C can each be programmed
as all inputs or outputs.

When a line is configured as an output, it can sink a
maximum of 2.5 ma at 0.4V and 15 ma at 1.0V.

The address for port A is 0, B is 1, and C is 2. The
CON FIG PIO statement is used to configure the 8255
lines. Use an address of 0.

Port B is connected to a high current sink through U1.
See "High current output" later in this chapter.

Pull up / down resistors

Digital I/ O lines at J3 m ay be pulled up to + 5 volts or to
ground through a 10K resistor pack using jumper W 6.

Jumper W6 for pull up or down configuration is as
follows:

[1-2]

Pull up

[2-3]

Pull down

Setting W6 for pull up makes interfacing to switches and
"open collector" TTL devices easy . See "Inter facing to
Switches and other devices" below.