RedLion Crimson Programming Questions

DavidRojas

Member
Join Date
Feb 2011
Location
McAllen, TX
Posts
19
Hello all, I'm designing a system to keep track of device runtime using Redlion's Crimson for the G3 series HMIs. There is a global action called "On Tick" which gets called once every second. I have a program that is being called in this event that checks if a flag (bit) variable is set. If so, I increment a runtime variable by 1. In theory this would represent how many seconds the device has been on.

My question is how reliable is the "On Tick" to occur once every second? In my program, I notice that near the end of the day, my runtime is off by about 10-20 seconds sometimes.

Is the On Tick exactly syncronized with the time given by the GetNow() function? In other words, when displaying the time on a page, will the On tick be called on the second every second?
 
Hello all, I'm designing a system to keep track of device runtime using Redlion's Crimson for the G3 series HMIs. There is a global action called "On Tick" which gets called once every second. I have a program that is being called in this event that checks if a flag (bit) variable is set. If so, I increment a runtime variable by 1. In theory this would represent how many seconds the device has been on.

My question is how reliable is the "On Tick" to occur once every second? In my program, I notice that near the end of the day, my runtime is off by about 10-20 seconds sometimes.

Is the On Tick exactly syncronized with the time given by the GetNow() function? In other words, when displaying the time on a page, will the On tick be called on the second every second?

I have noticed that On Tick sometimes will not fire immediately after a page is loaded. After a few seconds it seems to fire correctly.
 
I'd like to ask a separate question, but still related to programming. That is, will the "On Update" continuously fire, even if nothing on the page has changed? In the case of a Datastation with no one viewing a page, is there anything to update?
 
My question is how reliable is the "On Tick" to occur once every second? In my program, I notice that near the end of the day, my runtime is off by about 10-20 seconds sometimes.

In the past I've tried what you're suggesting with similar results. Even if the OnTick signal worked perfectly, I think you will have problems with this approach. What if the run bit comes on halfway between OnTick triggers? That extra 1/2 second won't be recorded, and those discrepancies add up over time. The G3 just isn't good at precise time applications (nor is it meant to be). For things like this I typically do the timing in the PLC and transfer the timer values to the HMI.
 
The On Tick will fire every one second if there is nothing else going on in the system. However if something runs with a higher priority like a program it will delay the On Tick. The best option would be to use the GetNow functions to build your own timer.

Regarding the On Update, this function will fire every time the display page is updated. This may also vary depending on what else is going on. This is even true with the DSP, which doesn't have a physical display.
 
Thanks, I'll try to figure something out by calling a function in the On Update event to keep checking if 1 second has gone by and then increment my counter. I'll assume that On Update occurs as fast as possible which I've seen in the past to be as fast as 30 times a second with some small programs with few lines of code. My fear is that the On Update may not be called if there is nothing to update. If I have nothing on the Display pages and all my code is based on triggers of tags. Will the Global On Update event be called since there is nothing to update on the screen?
 
Last edited:
You might want to try using the DispCount system variable. This is a system counter that increments every time a display update occurs, even if there's nothing to update. Appending a bit number to the end (DispCount.0) will give you a bit that toggles very fast. Use a higher bit number for a slower rate.
 
Thanks, I'll try to figure something out by calling a function in the On Update event to keep checking if 1 second has gone by and then increment my counter. I'll assume that On Update occurs as fast as possible which I've seen in the past to be as fast as 30 times a second with some small programs with few lines of code. My fear is that the On Update may not be called if there is nothing to update. If I have nothing on the Display pages and all my code is based on triggers of tags. Will the Global On Update event be called since there is nothing to update on the screen?

You can have a tag assigned to the function getsec(getnow()), and set up a trigger on change in value of 1, to increase a counter. It may not be always be exactly at one second, but the overall time, should ok, as long as it's not a huge program. Otherwise, you might be able to use the getnow() function, to get the system time, compare when you start and stop.
 
Attached is an example for using a trigger and moving Getnow() to a tag. I also return the current runtime, while the button is pressed.

Note: I used the 24hr Date/Time format, to show the current runtime, instead of doing the math in a script. Therefore the max is 24 hours.

If you need anything more accurate than this, I would definately not do it in the HMI.
 
Just a thought - use your OnTick function to check the state of the flag when it goes on record the current time, and when it goes off subtract the time it when off from the recorded time. Then add this calculated time to the accumulator for the flag. Although far more complex this should give you an error of no more than 1 sec per on off of the flag
 
Just realized that you are wanting an accumulated run time. Just a thought, but you are saying, that your total is off by 10-20 sec, at the end of the day. I don't think that a one second resolution will be accurate enough for you, and I don't think the HMI, has any repeatable time value less than that. If you started 10 times, and the clock was at 0.9 s before the change, you just added 9 seconds to your accumulated value.
 
GeoffC, at one point in time, I was doing just as you described. I'll add another variable and run them both to see which method is more accurate at the end of the day.

Brijm has a good point. Perhaps I'm asking too much from the HMI, but the application is simple enough I don't see the point in investing in a PLC. I guess at the end of the day, if I'm waiting for 1000 hours to accumulate, being off even a few minutes won't be that bad.

Does everyone agree that triggering events from a tag is more reliable than the On Tick event?
 

Similar Topics

Hi, I have a complex database in Crimson 3.0 and in one of the display pages I am trying to get a tag to show the sum of several other tags. The...
Replies
3
Views
134
It states WinPcap must be installed for the Emulator to function. WinPcap.org states that the technology is mature with no updates planned. Am I...
Replies
3
Views
823
Following on from another thread, I just downloaded Crimson 3.2 and it now supports CR and Graphite HMIs. Time for a 'play' :-) It seems to have...
Replies
14
Views
1,962
Action On Release command Set(ConveyorPopup,ConveyorPop_1) rejected w/ string tags. SetStringTag(index, data) wants an index. How does one pass...
Replies
8
Views
908
Looking for the object that will provide entry of an integer value for commanding a setpoint in the DA70A ladder logic. Any ideas?
Replies
2
Views
543
Back
Top Bottom