Pulsecountreset example 2, Readio (dest, pslot, mask) – Campbell Scientific CR9000X Measurement and Control System User Manual
Page 263

Section 7. Measurement Instructions
7-39
PulseCountReset Example 2
Public
PulseHz, Flag(8)
'Declare Variables
DataTable
(Table1,Flag(3) = False,-1)
'Define Data Tables
DataInterval
(0,0,0,10)
Sample
(1,PulseHz,IEEE4)
EndTable
Sub
Sub1
'Define Subroutines
Scan (1,Sec,3,0)
'Enter Measurement Instructions Here
If NOT Flag(1) Then ExitScan
NextScan
Flag(3) = True
‘Controls 1rst Data Output and Reset
PulseHz = 0
‘Set PulseCount Variable’s value to 0
EndSub
'Main Program
BeginProg
Scan
(1,Sec,100,0)
If Flag(3) Then
PulseCountReset
EndIf
PulseCount (PulseHz,1,6,1,0,2000,1,0)
CallTable Table1
Flag(3) = False
If Flag(1) Then Sub1
NextScan
EndProg
ReadIO (Dest, PSlot, Mask)
The ReadIO instruction is used to read the status of selected digital I/O
channels (ports) on the CR9070/CR9071E Counter - Timer / Digital I/O
Module. There are 16 ports on the CR9070/CR9071E. The status of these
ports is considered to be a binary number with a high port (+3.5V to +5 V)
signifying 1 and a low port (-0.5V to +1.2 V) signifying 0. For example, just
looking at the first 8 ports, 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 is a binary
representation of the ports. If a port position is set to 1, the datalogger reads the
status of the port. If a port position is set to 0 the datalogger ignores 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, the result of the instruction will be 4 (decimal, binary = 100). If port 3 is
low, the result would be 0.
ReadIO Example
ReadIO(Port3, 6, &B100) ' read port 3 on the CR9070/CR9071E card in slot 6
' if port 3 is high then Port3 = 4, if port 3 is low then Port3 = 0