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.

User Flag to Trigger Different Scan Intervals


Terrapin Mar 23, 2017 02:25 PM

I am trying to write a program that will contain two different scan intervals that are controlled by a user flag.  I want the program scan interval to be 5 minutes normally, but when the flag is set True, run the same program at a 30 second (or ideally, user configurable)  interval.  I've tried creating variables for the Scan Interval and Scan Units, but it won't accept that. Is there a clever way I haven't thought of for doing this that doesn't involve putting the same exact code in the Main Scan and SlowSequence sections?  

Any help or suggestions would be very appreciated.


Sam Mar 23, 2017 06:37 PM

 

Public I_Wanna_Go_Fast As Boolean

Public ScanSec As Long
ReadOnly ScanSec

Public CS451(2)
Alias CS451(1) = Walker
Alias CS451(2) = Texas_Ranger

BeginProg
  Scan (1,Sec,0,0)

    If I_Wanna_Go_Fast Then
      ScanSec = 30
    Else
      ScanSec = 300
    EndIf

    If TimeIntoInterval(0,ScanSec,Sec) Then
      SDI12Recorder (CS451,1,0,"M!",1.0,0,2)
    EndIf

  NextScan
EndProg

 


Terrapin Apr 4, 2017 10:38 AM

Thanks Sam for the suggestion and humor.  This is exactly what I was trying to do.


Raphael xing Apr 5, 2017 08:36 AM

a good idea


Nicolas Jun 11, 2021 12:33 AM

Hello,
when the "Timetointevral" condition is not positive, does the logger have lower energy consumption?


Sam Jun 11, 2021 06:25 AM

The power consumption will be lower through a combination of less time spent on the SDI-12 communication and the reduced power draw in sensor operation. With that said, I believe that most applications would consider the power savings negligible in this exact example. How the concept is applied will be an important factor in determining the impact.

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