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.

Using relay for SW12V, programming Q


JMD78 Sep 27, 2013 02:26 PM

Hello and thanks for reading my question.

I am running an array of optical sensors scanning at 5 seconds and using the SW12V to make take those measurements as a "burst" every 15 min. So it is recording 10 measurements within 50 seconds every 15 min (program outline below). Works great, but we need to add more sensors to the array and the single SW12V on the CR1000 does not provide enough current. I have several CRYDOM relays to control a 12V source on the logger. However, the PortSet function does not appear to work in conditional statements. What other methods can I use to program the logger to take these burst measurements using a relay to control the optical sensors? Any suggestions are greatly appreciated.

Current Program Outline:

Scan(5,Sec,1,0)

'other sensors running, conductivity, rain'

'optical'
If IfTime (0,900,Sec) Then SW12(1)
If IfTime (10,900,Sec) Then Optical_On = True
If IfTime (60,900,Sec)Then
Optical_On = False
SW12(0)
EndIf

If optical_on = True Then...

Thanks,
Joseph


GTProdMgr Sep 27, 2013 03:24 PM

WriteIO is what you can use (it is a little more involved because it can control all 8 control ports at once, but doesn't have the conditional restrictions.) You can use PortSet in a conditional statement, but it forces the program to run in Sequential Mode. Do you have to run your program in Pipeline mode ?


JMD78 Sep 27, 2013 04:46 PM

The program runs in Sequential Mode. I have played around with it some more. When I write the statement like so, I get an "If without EndIf" error.

If IfTime (0,900,Sec) Then
SW12(1)
PortSet (3,1)
If IfTime (10,900,Sec) Then Optical_On = True
If IfTime (60,900,Sec) Then
Optical_On = False
SW12(0)
PortSet (3,0)
EndIf

However, when I write the program like this. It compiles, just fine.

If IfTime (0,900,Sec)Then SW12(1)
If IfTime (0,900,Sec)Then PortSet (3,1)
If IfTime (10,900,Sec) Then Optical_On = True
If IfTime (60,900,Sec)Then
Optical_On = False
SW12(0)
PortSet (3,1)
EndIf

I will test the program this afternoon. Thank you for your reply.


GTProdMgr Sep 27, 2013 06:05 PM

It appears that in your first code block, you just need to
put an EndIf after the PortSet(3,1) line (multi-line syntax):


If IfTime (0,900,Sec) Then
SW12(1)
PortSet (3,1)
EndIf

If IfTime (10,900,Sec) Then Optical_On = True

If IfTime (60,900,Sec) Then
Optical_On = False
SW12(0)
PortSet (3,0)
EndIf

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