Pulsecountreset, Readio (dest, mask) – Campbell Scientific CR5000 Measurement and Control Module User Manual

Page 151

Advertising
background image

Section 7. Measurement Instructions

7-25

Switch Closure

• Pulse Channels

A switch closure is connected between P1..P4 and analog ground.
When the switch is open, the CR23X pulls the pulse channel to 5 V
through a 100 kOhm impedance. When the switch is closed, the
pulse channel is pulled to ground. The count is incremented when
the switch opens.

Minimum Switch Closed Time: 5 ms

Minimum Switch Open Time: 6 ms

Maximum Bounce Time: 1 ms open without being counted

PulseCountReset

PulseCountReset is used to reset the pulse counters and the running averages
used in the pulse count instruction. The 16 bit counters can count up to
decimal 65535. More counts than 65535 result in an over-range condition.
With each scan, the CR5000 reads the counts accumulated since the last scan
and then resets the counter. If the scans stop, as in a program with more that
one Scan loop, the counter continues to accumulate counts until another scan is
initiated or it over-ranges. If the running averaging is in use, the over-range
value will be included in the average until for the duration of the averaging
period (e.g., with a 1000 millisecond running average, the over-range will be
the value from the PulseCount(...) instruction until 1 second has passed.
Resetting the average prior to (re)starting the scan avoids this.

ReadIO (Dest, Mask)

ReadIO is used to read the status of selected control I/O channels (ports) on the
CR5000. There are 8 ports. The status of these ports is considered to be a
binary number with a high port (+5 V) signifying 1 and a low port (0 V)
signifying 0. For example, if ports 1 and 3 are high and the rest low, the binary
representation is 00000101, or 5 decimal. The mask parameter is used to select
which of the ports to read, it too is a binary representation of the ports, a 1 means
pay attention to the status of the port, a 0 means ignore the status of the port (the
mask is "anded" with the port status; the "and" operation returns a 1 for a digit if
the mask digit and the port status are both 1 and a 0 if either or both is 0).
CRBasic allows the entry of numbers in binary format by preceding the number
with "&B". For example if the mask is entered as &B100 (leading zeros can be
omitted in binary format just as in decimal) and ports 3 and 1 are high as in the
previous example, the result of the instruction will be 4 (decimal, binary = 100);
if port 3 is low, the result would be 0.

Examples

ReadIO(Port3, &B100) ' read port 3 if port 3 is high then

Port3 = 4, if port 3 is low then Port3 = 0

Advertising