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.

Bad timing


MortenS Oct 27, 2011 01:04 PM

Hi

I got a rather big program on my CR1000

It should get a status from an ISCO sampler every 10 seconds
and other measurements every 60 seconds.

My scan is declared like this in my main loop: Scan(1,Sec,3,0)

I use "If TimeIntoInterval(0,10,Sec) Then" to get my ISCO statas
and "If TimeIntoInterval(0,60,Sec) Then" other measurements

I measured that a turn in my main loop takes 3-4 seconds. It varies a bit depending on different situation out of my control.

My problem is that if TimeIntoInterval is not hit on the correct second, it would not do the task.
I therefor calculate when the next 10 sec status should run in the future and then use this instead af TimeIntoInterval:

Call GetNextStatusTime
"If Now >= NextStatusTimeSS1990 Then"

Now is a timestamp on time right now and NextStatusTimeSS1990 is the calculated status time into the future.

My sub routines GetNextStatusTime & UpdateNow is:

Sub GetNextStatusTime
Call UpdateNow
SecTilNextStatusTime = StatusInterval - (Now MOD StatusInterval)
NextStatusTimeSS1990 = Now + SecTilNextStatusTime
CallTable (NextStatusTimeTable)
FormattedNextStatusTimeSS1990 = NextStatusTimeTable.NextStatusTimeSS1990(1,1)
EndSub

Sub UpdateNow
Now = Public.TimeStamp(1,1)
CallTable(TimeBarTable)
FormattedNowSS1990 = TimeBarTable.Now(1,1)
EndSub


JDavis Nov 14, 2011 05:54 PM

I suggest reading the help on using Slowsequence.

You can have more than one scan on separate intervals.

The method you are attempting now would result in skipped scans since your measurements take more than one 1 second scan to complete.


MortenS Nov 15, 2011 08:30 AM

That sounds like a good idea...thanks for the tip!

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