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.

Different scan timing for instruments with Delays


WayneJacob Dec 30, 2011 07:39 PM

We have a HC2S3 Temp/Rel Humidity Sensor, a 61302V Barometer and a TD4 Rain Gauge, running on a CR1000 logger using Loggernet 4.1 to administer.

Default sample scans using the manual supplied code for the HC2S3 and Barometer are 5 second intervals with a 3 second delay on the humidity sensor. The rain gauge samples every 1 second again just using the manual supplied code example.

How can I get the rain gauge samples every second when the program scan rate is set at 5 seconds for the other two, and one has a 3 second delay?

Would it be best to put the rain gauge alone in the main program scan/nextscan routine with a scan rate of one second, and have the other two instruments in a slowsequence at a 5 second interval, then setting the datatable datainterval to 5 seconds or longer?

Any assistance would be appreciated.

* Last updated by: WayneJacob on 12/30/2011 @ 12:41 PM *


Sam Dec 31, 2011 04:30 AM

Scan 1 sec

read rain gage

Iftime 2 into 5 secs, turn sw12 on

Iftime 0 into 5 secs, read hc2s3, then turn off sw12v

Next scan


WayneJacob Jan 3, 2012 09:44 PM

Thanks Sam.

Another issue now, can you then have nested TimeIntoIntervals? The Barometer we have gets turned on one minute before the hour then read and turned off on the hour. Not a problem if you can have a nested TimeIntoInterval (one loop set for seconds as you indicate above, another to minutes for the turning on and off of the Barometer). Alternatively (and simply) we leave the barometer on I guess.

Wayne


Grant Jan 3, 2012 11:48 PM

Wayne

No point in reading it every 5 seconds if you are only turning it on every one hour.

I'd suggest looking at the data you want out of the instruments and programming to that rather than using the default code supplied in the manuals.

The pulses from the raingauge will be stored by the logger between the scans, the number of counts then processed and the count reset for the next scan interval.

For most applications, have it all on the one scan rate for the KISS principle unless you actually need one second rainfall.

In answer to your question though, you can nest the time intointervals

If IfTime (0,60,Sec) Then
If IfTime (5,60,sec) Then
Do something
EndIf
Do some other thing
EndIf

Cheers

Grant


Sam Jan 4, 2012 02:30 PM

It's pointless to nest IfTime's. If the time is currently 0 seconds into a 60 second interval, then it will not be 5 seconds into a 60 second interval. Therefore the nested statement will never execute. Similarly, even if it is 5 into 60, the nested statement will never execute because the outer is not true.

What you are looking for is actually two independent statements

If IfTime (59,60,Min) Then
'turn it on
EndIf

If IfTime (0,60,Min) Then
'read it
'turn it off
EndIf


WayneJacob Jan 6, 2012 07:27 PM

Thanks for the assistance.

The comment on nested IfTimes referred to the potential to have two differnet intervals in a nested configuration. For example:

If IfTime(3,5,sec)then
If IfTime(1,60,min) then...
End If

so, you may be doing some actions every 3rd second on a 5 second loop, but on the hour may do an additional task within this loop. Here the logger will be tracking seconds in one loop and minutes in the inner loop.

Since that post however I used Grant's KISS advice...

Wayne


Grant Jan 7, 2012 03:43 AM

Wayne

I to get it to work correctly the second time interval would have to be divisable by the first, as Sam was eluding to.

If IfTime(0,10,sec)then
If IfTime(0,60,sec) then
Do something
EndIf
Do something else
EndIf

If you have your example

If IfTime(3,5,sec)then
If IfTime(1,60,min) then...
End If

The second part IfTime(1,60,min) may never run as it gets called three seconds into a five second interval and the IfTime(1,60,min) will get called at zero seconds into the one minute interval. (I think)

Remember KISS, keep your units the same and it may be easier to see.

Cheers

Grant


TomHiddleston Dec 11, 2023 04:23 AM

This post is under review.

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