Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

How to use PortGet Instruction.


AS Feb 8, 2018 10:52 AM

Hi, can you help me to use PortGet instruction in CR200X. I am trying to start the scan after giving a signal on port C2 through a switch so i am using PortGet instruction to get the status of port (Same as CheckPort instruction CR800/CR1000). The CR200 program which i am using is given below: 

Public batt_volt
Public VW(20)
Public port


DataTable (Test,1,9999) 
DataInterval (0,1,min)
Minimum (1,batt_volt,0,0)
Sample (20,VW())
EndTable

'Main Program
BeginProg

Do
If PortGet (port,C2) Then ExitDo
Loop

Scan (1,min)
Battery (batt_volt)
SWBatt (1)
Delay (2,sec)
SDI12Recorder (VW(1),"KM!",1.0,0)
Delay (1,sec)
SDI12Recorder (VW(3),"LM!",1.0,0)
Delay (1,sec)
SDI12Recorder (VW(5),"MM!",1.0,0)
Delay (2,sec)

SWBatt (0)

But when i am compiling this program i am getting error "undeclared variable PORTGET" and "Invalid dimension: PORTGET (PORT,C2)".


smile Feb 9, 2018 06:17 AM

hi,

the program lines between begin and scan are executed only the first time. To make sure that they are always executed you have to move after the scan statement.

also you must first read the status of the port, writing the result in a variable then you can make an if on that variable.
You can not give the name of an instruction as a variable (portget is an instruction).

Smile


AS Feb 9, 2018 11:37 AM

Please let me know what CRBasic program we shoud use to start the scan by giving an external pulse and wahtr connections we have to make in datalogger.


smile Feb 9, 2018 08:59 PM

Hi 

so it could work.

as long as there are 5V on port C2 the program runs, otherwise it only reads only the battery. Decide whether to keep out from last "endif" the CallTable Test to get historical data processed in memory anyway

'CR200 Series Datalogger
Public batt_volt
Public VW(20)
Public port

DataTable (Test,1,9999)
DataInterval (0,1,min)
Minimum (1,batt_volt,0,0)
Sample (20,VW())
EndTable

'Main Program
BeginProg
Scan (1,min)
Battery (batt_volt)
PortGet( port, 2) 'Get status of Port 2
If port = 1 Then
SWBatt (1)
Delay (2,sec)
SDI12Recorder (VW(1),"KM!",1.0,0)
Delay (1,sec)
SDI12Recorder (VW(3),"LM!",1.0,0)
Delay (1,sec)
SDI12Recorder (VW(5),"MM!",1.0,0)
Delay (2,sec)
SWBatt (0)
EndIf
'Call Output Tables
CallTable Test
NextScan
EndProg

Log in or register to post/reply in the forum.