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.

Cr1000 Problem with code. SW12


Fasad Aug 2, 2018 07:41 AM

Hi,

I have problem with my CR1000. I wrote simple program where I have several conditions that control the SW12 port. And the problem is that when program is running, during specified hours (8:00pm till 11.30pm) logger doesn't saves records. Below you will find part of my code

Thank in advance to everybody for the support!!

 RealTime(rTime)     

If ((rTime(4) < 7 OR rTime(4) > 19) AND Rain_mm>=0.1 AND WS_ms <5 AND AT_CL_C2 >5 ) Then   

SW12(1)
ElseIf ((rTime(4) < 7 OR rTime(4) > 19)AND Rain_mm<0.1 AND WS_ms <5 AND AT_CL_C2 >5 )  Then

Delay (0,30,Sec)   

 SW12(0)     

 ElseIf ((rTime(4) < 7 OR rTime(4) > 19) AND Rain_mm>=0.1 AND WS_ms >5 AND AT_CL_C2 >5) Then 

Delay (0,30,Sec)   

SW12(0)

ElseIf ((rTime(4) < 7 OR rTime(4) > 19) AND Rain_mm>=0.1 AND WS_ms >5 AND AT_CL_C2 <5) Then

 Delay (0,30,Sec)   

SW12(0)

ElseIf ((rTime(4) < 7 OR rTime(4) > 19) AND Rain_mm>=0.1 AND WS_ms <5 AND AT_CL_C2 <5) Then 

Delay (0,30,Sec)   

SW12(0)

'Special conditions

ElseIf (rTime(4) = 7 AND rTime(5)<=15 AND Rain_mm<0.1 AND WS_ms <5 AND AT_CL_C2 >4)

Then  SW12(1)

 ElseIf (rTime(4) = 7  AND rTime(5)>15 AND Rain_mm<0.1 AND WS_ms <5 AND AT_CL_C2 >4) Then 

Delay (0,30,Sec)    

SW12(0)  

EndIf


ariklee Aug 2, 2018 11:12 PM

Hi Fasad,

What is your sample rate?

And what is the scan rate?

And did you consider writing an Else for the condition where none of the conditions above are TRUE?

And finally, what does SW12 control?

Perhaps you might post your entire program using the <> (insert/edit code)

Good luck,

Eric


Fasad Aug 3, 2018 08:10 AM

Hi Eric, 

Thank you for your reply. Scan of the program is set to 5 second. 

The sw12 port starts the remote control of the rain curtains. More precisely, the controller which, when receiving the 12V voltage, switches over the contactor, which transfers 230V to the motor. 

Here you have all of my program:

 

Public BattV
Public PTemp_C
Public CL_W1
Public CL_C1
Public CL_WP1
Public CL_W2
Public CL_WP2
Public CL_C2
Public CL_WP3
Public CL_C3
Public CL_W3
Public TRHData_3(2)
Public TRHData(2)
Public TRHData_2(2)
Public Rain_mm
Public WS_ms
Public WindDir
Public AirTC
Public RH
Public P
Public rTime(9)
Public VoltSE_1,VoltSE_2,VoltSE_3

Alias TRHData_3(1)=AT_CL_W3
Alias TRHData_3(2)=RH_CL_W3
Alias TRHData(1)=AT_CL_WP1
Alias TRHData(2)=RH_CL_WP1
Alias TRHData_2(1)=AT_CL_C2
Alias TRHData_2(2)=RH_CL_C2

Alias VoltSE_1=Status_1
Alias VoltSE_2=Status_2
Alias VoltSE_3=Status_3

Units BattV=Volts
Units PTemp_C=Deg C
Units CL_W1=Deg C
Units CL_C1=Deg C
Units CL_WP1=Deg C
Units CL_C2=Deg C
Units CL_WP2=Deg C
Units CL_W2=Deg C
Units CL_WP3=Deg C
Units CL_W3=Deg C
Units CL_C3=Deg C
Units Rain_mm=mm
Units WS_ms=meters/second
Units WindDir=degrees
Units AirTC=Deg C
Units RH=%
Units AT_CL_WP1=Deg C
Units RH_CL_WP1=%
Units AT_CL_C2=Deg C
Units RH_CL_C2=%
Units AT_CL_W3=Deg C
Units RH_CL_W3=%
Units Status_1=mV
Units Status_2=mV
Units Status_3=mV

'Define Data Tables DataTable(SOIL,True,-1) DataInterval(0,30,Min,10) Average(1,CL_W1,FP2,False) Average(1,CL_C1,FP2,False) Average(1,CL_WP1,FP2,False) Average(1,CL_C2,FP2,False) Average(1,CL_WP2,FP2,False) Average(1,CL_W2,FP2,False) Average(1,CL_WP3,FP2,False) Average(1,CL_W3,FP2,False) Average(1,CL_C3,FP2,False) EndTable DataTable(BATT,True,-1) DataInterval(0,1,Day,10) Minimum(1,BattV,FP2,False,False) EndTable DataTable(Status_Markiz,True,-1) DataInterval(0,30,Sec,10) Sample(1,Status_1,FP2) Sample(1,Status_2,FP2) Sample(1,Status_3,FP2) EndTable DataTable(AIR_P,True,-1) DataInterval(0,30,Min,10) Average(1,AT_CL_WP1,FP2,False) Average(1,AT_CL_W3,FP2,False) Average(1,AT_CL_C2,FP2,False) Sample(1,RH_CL_WP1,FP2) Sample(1,RH_CL_W3,FP2) Sample(1,RH_CL_C2,FP2) Totalize(1,Rain_mm,FP2,False) Average(1,WS_ms,FP2,False) Sample(1,WindDir,FP2) Average(1,AirTC,FP2,False) FieldNames("Air_2m_AVG") Sample(1,RH,FP2) FieldNames("RH_2m") EndTable DataTable(AIR_5,True,-1) DataInterval(0,5,Sec,10) Average(1,AT_CL_WP1,FP2,False) Average(1,AT_CL_W3,FP2,False) Average(1,AT_CL_C2,FP2,False) Sample(1,RH_CL_WP1,FP2) Sample(1,RH_CL_W3,FP2) Sample(1,RH_CL_C2,FP2) Average(1,AirTC,FP2,False) FieldNames("Air_2m_AVG") Sample(1,RH,FP2) FieldNames("RH_2m") EndTable 'Main Program BeginProg 'Main Scan Scan(5,Sec,1,0) 'Default CR1000 Datalogger Battery Voltage measurement 'BattV' Battery(BattV) 'Default CR1000 Datalogger Wiring Panel Temperature measurement 'PTemp_C' PanelTemp(PTemp_C,_60Hz) '107 Temperature Probe measurement 'CL_W1' Therm107(CL_W1,1,1,1,0,_60Hz,1,0) '107 Temperature Probe measurement 'CL_C1' Therm107(CL_C1,1,2,1,0,_60Hz,1,0) '107 Temperature Probe measurement 'CL_WP1' Therm107(CL_WP1,1,3,1,0,_60Hz,1,0) '107 Temperature Probe measurement 'CL_C2' Therm107(CL_W2,1,4,1,0,_60Hz,1,0) 'poprawiony '107 Temperature Probe measurement 'CL_WP2' Therm107(CL_WP2,1,5,2,0,_60Hz,1,0) '107 Temperature Probe measurement 'CL_W2' Therm107(CL_C2,1,6,2,0,_60Hz,1,0) 'Poprawiony '107 Temperature Probe measurement 'CL_WP3' Therm107(CL_WP3,1,7,2,0,_60Hz,1,0) '107 Temperature Probe measurement 'CL_W3' Therm107(CL_C3,1,8,2,0,_60Hz,1,0) '107 Temperature Probe measurement 'CL_C3' Therm107(CL_W3,1,9,3,0,_60Hz,1,0) 'CS215 Temperature & Relative Humidity Sensor measurements 'AT_CL_CON' and 'RH_CL_CON' SDI12Recorder(TRHData_3(),3,"0","M!",1,0) 'CS215 Temperature & Relative Humidity Sensor measurements 'AT_CL_OTC' and 'RH_CL_OTC' SDI12Recorder(TRHData(),5,"0","M!",1,0) 'CS215 Temperature & Relative Humidity Sensor measurements 'AT_CL_OP' and 'RH_CL_OP' SDI12Recorder(TRHData_2(),7,"0","M!",1,0) 'Generic Tipping Bucket Rain Gauge measurement 'Rain_mm' PulseCount(Rain_mm,1,1,2,0,0.1,0) '03001 Wind Speed & Direction Sensor measurements 'WS_ms' and 'WindDir' PulseCount(P,1,2,0,0,1,0) WS_ms = (P*(2.25/30))*0.44704 BrHalf(WindDir,1,mV2500,10,3,1,2500,True,20000,_60Hz,355,0) If WindDir>=360 OR WindDir<0 Then WindDir=0 'If WS_ms<0.21 Then WS_ms=0 'HMP45C (6-wire, constant power) Temperature & Relative Humidity Sensor measurements 'AirTC' and 'RH' VoltSe(AirTC,1,mV2500,11,0,0,_60Hz,0.1,-40) VoltSe(RH,1,mV2500,12,0,0,_60Hz,0.1,0) If RH>100 AND RH<108 Then RH=100 'Curtains RealTime(rTime) If ((rTime(4) < 7 OR rTime(4) > 19) AND Rain_mm>=0.1 AND WS_ms <5 AND AT_CL_C2 >5 ) Then SW12(1) ElseIf ((rTime(4) < 7 OR rTime(4) > 19)AND Rain_mm<0.1 AND WS_ms <5 AND AT_CL_C2 >5 ) Then Delay (0,30,Sec) SW12(0) ElseIf ((rTime(4) < 7 OR rTime(4) > 19) AND Rain_mm>=0.1 AND WS_ms >5 AND AT_CL_C2 >5) Then Delay (0,30,Sec) SW12(0) ElseIf ((rTime(4) < 7 OR rTime(4) > 19) AND Rain_mm>=0.1 AND WS_ms >5 AND AT_CL_C2 <5) Then Delay (0,30,Sec) SW12(0) ElseIf ((rTime(4) < 7 OR rTime(4) > 19) AND Rain_mm>=0.1 AND WS_ms <5 AND AT_CL_C2 <5) Then Delay (0,30,Sec) SW12(0) 'SPECIAL CONDITIONS ElseIf (rTime(4) = 7 AND rTime(5)<=15 AND Rain_mm<0.1 AND WS_ms <5 AND AT_CL_C2 >4) Then SW12(1) ElseIf (rTime(4) = 7 AND rTime(5)>15 AND Rain_mm<0.1 AND WS_ms <5 AND AT_CL_C2 >4) Then Delay (0,30,Sec) SW12(0) EndIf 'Status markiz PortGet (Status_1,1) PortGet (Status_2,2) PortGet (Status_3,4) 'Call Data Tables and Store Data CallTable SOIL CallTable BATT CallTable AIR_P CallTable Status_Markiz CallTable AIR_5 NextScan EndProg

 I've also try with ELSE conditions but it doesnt helps. 

And I have second question, can I add a timer which will be responsible for keeping sw12 switched on for 30 minutes when the condition is TRUE?

Cheers, 

Marcin

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