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

Page 19

Advertising
background image

CHAPTER 6

DIGITAL AND OPTO PORTS

Page 17

using the PW M statem ent.

Jumper s W6 and W7 set the P WM output for o pto
positions 0 and 1.

Jumper Position

Description

W 6

[1-2]

Position 0 normal mode

W 6

[2-3]

Position 0 PWM output

W 7

[1-2]

Position 1 normal mode

W 7

[2-3]

Position 1 PWM output

When either position is jumpered for PW M output, none
of the LINE com mands will work for that position.

PWM outputs are used to gener ate analog outputs.
When using one of the PWM positions, the
corresponding analog output should not be used.

G5 operation

The G5M OD statement can refer to an input or output
module, depending upon how it was used. Its use as an
input is discussed fir st.

Values from G5 modules are returned using the G5MOD
function. The syntax is

A = G 5 M O D (slot)

The slot number is from 0 to 3 or 100 to 123,
corr esponding to the position on or off the boar d. T his
function returns a number from 0 to 256, corr esponding
to a resolution of 8 bits. The G5M OD function takes
about 7 ms to convert the input data.

WARNING:

Conve rsion tim e is appro ximately 7 m s. D uring this
time, all interrupts are turned off. Serial characters
will be missed at baud rates at and above 9600.

When installing and operating a G5 module in a
particular slot, make sure it is not turned "ON" as for a
G4 digital output module. If an output is turned on, then
no reading is received. W hen executing the CONF IG
LIN E 0 statem ent, the slot the G5 m odule goes into
should be set as an input (1).

The program below takes 100 samples and stores it in an
array. The time to read and store 100 samples is 0.7
seconds, or 7 ms per sample.

10

DIM G(100)

20

FOR X = 0 TO 99

30 G(X) = G5MOD(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 c hannels eve ry tenth of a second and stores it
into an array. When the ar ray fills, the tick tim er stops.

10 DIM G(100)
20 DIM H(100)

30 ONTICK .1,100
40 REM This is a dummy loop
50 GOTO 40
100 G(I) = G5MOD(0)
110 H(I) = G5MOD(1)
120 PRINT I,G(I),H(I)
120 I=I+1
130 IF I=100 THEN ONTICK 0,100
140 RETI

The G5MO D statement also outputs to a module on an
external opto rack. It is not possible to use the internal
opto rack due to the electrical driver required. The
output number is from 0 to 4095.

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

1000

G5MOD channel,value

channel is from 100 to 123 and corresponds to the
external opto rack position. value ranges fr om 0 to
4095.

Converting analog measureme nts

Input readings are converted to usable units of
measurem ent by performing scaling calculations in the
p r o gr a m . T h e G 5 M O D fu n ct io n r et ur n s v a lu e s f r om 0
to 255. To change these readings to other units, use the
following calculation:

v a r ia b le = K * G5 M O D (slot)

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

Example:

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

K = 200 / 256
K = .78125

To obtain the final value for the equation in PSI:

100 V= .78125 * G5M OD(n)

DIGITAL I/O PORT

D i gi ta l I / O li ne s o n t he R P C -5 2 go to c on n ec to r J4 . I / O
interface is through an 82C55 chip.

This por t can be used to interface additional opto
modules ( using the M PS ser ies racks) , dr ive small
relays, solenoids, motors, or lamps, and provide general
purpose TTL I/O to other logic devices or mechanical
switches. The L INE com mand is used to access and
control this po rt.

The lines on J4 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

Advertising