Portset (port, state) – Campbell Scientific CR5000 Measurement and Control Module User Manual
Page 148

Section 7. Measurement Instructions
7-22
Parameter
& Data Type
Enter
Dest
Variable
The variable in which to store the result of the instruction. A 1 is stored if the port is high;
0 is stored if the port is low.
Port
Constant
The control port number (1-8) for which the status should be obtained.
PortGet Example
This example uses PortGet to read the status of port 1 at the beginning of each
scan.
Const RATE = 500
'Scan interval number
Const RUNITS = 1
'Scan interval units (mSecs)
Const TBLINT1 = 200
'Table 1 interval number
Const UNITS1 = 1
'Table 1 interval units (mSecs)
Dim Tblk1( 1 ),PortStatus
'Block #1 dimensioned source
Dim Tref
'Declare reference temperature variable
Public Flag( 8 )
'Flag dimension
DataTable( TEST, Flag( 1 ), 1000 ) 'Trigger, buffer of 1000 Records
DataInterval( 0, TBLINT1, UNITS1, 100 )
'200 mSecs, 100 lapses
Average( 1, Tblk1(), FP2, 0 ) 'Reps,Source,Res,Disable
Sample ( 1, PortStatus, FP2 ) 'Reps,Source,Res,Disable
EndTable
'End of table TEST
BeginProg
'Program begins here
Scan( RATE, RUNITS, 3, 0 ) 'Scan 500 (mSecs)
PortGet( PortStatus, 1)
'Set port 1 high
PanelTemp( Tref. Integ ) 'PanelTemp
TCDiff( Tblk1(), 1, 1, 1, 1, Tref, 0, 20, 40, 1.8, 32 )
CallTable
TEST
'Run Table TEST
Next
Scan
'Loop up for the next scan
EndProg
'Program ends here
PortSet (Port, State)
This Instruction will set the specified port high or low.
Parameter
& Data Type
Enter
Port
Constant,
Variable, or
Expression
The number of the port (1-8) to set with the instruction.
State
The state (high or low) to set the port to.
Constant,
Code Value State
Variable, or
True 0
Low
Expression
False
≠ 0
High