Hi all. I'm currently trying to build a simple LED display count-down timer in perspective, that's formatted as HH:mm:ss. All I want it to do is reset to a specified time via a button and then proceed to infinitely countdown at an increment of 1 second till it reaches 0. It would be helpful if this could be done using the tag system so I can record the elapsed timestamp for a report later.
Thank you,
Cam
Try something like this, should get you most of the way there:
I used a date time input and then an expression binding on the LED component with a script transform (code i found from one of
@JordanCClark's posts).
A pure expression. Should save an extra round trip to the gateway to run a script:
if(secondsBetween(now(), {path/to/time/value}) < 0,
'0:00:00',
toInt(floor(secondsBetween(now(), {path/to/time/value})/3600))
+ ':'
+ numberFormat(toInt(floor(secondsBetween(now(), {path/to/time/value})/60)) % 60, '00')
+ ':'
+ numberFormat(secondsBetween(now(), {path/to/time/value}) % 60, '00')
)
This looks like exactly what I would want but I have no idea where to put it. Would you be able to give me some instructions as to how to get this running and bind it to my display?
Add an expression binding on your led component's value property:

Use Jordan's code, but update it to wherever you are storing the time.
My example does not have a button, if you want that you have a number of ways to set the time value when you click the button.

Right-click | Open image in new tab for larger view.
3 Likes
Ohhh! Thank you very much! I'm sorry, I'm still very new at this stuff but I appreciate your efforts.
when I tried this script it says left operand is null
Refer to @Transistor's post above. I'm guessing you tried to use the expression directly.
That's not a script. It's an expression and it goes into an expression binding as shown in my animation.
yes
it gives me 0:00:00 but now how do I get it to countdown or bind it to a tag in the plc that is the cycle_time
Marcus, you really need to show how you've set it up if you want us to debug what's wrong with the way you set it up.
Jordan showed where to put the tagpath.
{path/to/time/value} in the expression represents a future time.
Looking over some of your other posts are you wanting to count up for cycle time or down?
A UDT you can use. Point the 'Running' boolian to a machine that is in cycle. Use 'Ideal Cycle Time sec' to define the countdown value.
udt_CycleTime.json (1.5 KB)
i never got bottom of timer to change everyday and actually keep track of real time. Also, I was trying to connect timer to plc to get realtime cycle time and count backwards from 59 sec and if timer was not reset after 59 sec then it would turn red and keep counting until reset. plus this stores 10 cycle times in history. Never got it working correctly
Are you using a timer in the PLC itself? If so, what PLC? Asking because, of course, different platforms have different ways of handling timers.
controllogix Allen Bradley. but it doesn't have to be. I just thought this would be easier way of recording cycle times plus displaying on the screen how long it took to produce part