Hi there,
I'm struggling with a beginner-issue here...
I'm creating an FB to log running times of actuator devices.
My approach is to place instances of these FB's (PulseToTime FB) in a task to be executed on a time basis of one minute. Every input signal's pulse goes to one CTU for totalizing minutes. A second CTU totalize hours.
The output for this "PulseToTime" FB should return a TIME type variable for the totalized device's running time.
I'd like to add the .CV values (WORD types) from both CTUs (the CTU for minutes and the CTU for hours) and then convert the result to a TIME type variable showing only hours and minutes, for example, T#1h20m...
How can I perform this add and convert operation?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2019-10-02
Originally created by: ph0010421
The TIME datatype is actually in ms, so if you multiply the minutes CV by 60000, and the hours CV by 360000 and add them together, you'll have the total ms.
You'll end up with some big numbers, so change from a WORD to a UDINT.
Add these values together, then use UDINT_TO_TIME function.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ph0010421 hat geschrieben:
The TIME datatype is actually in ms, so if you multiply the minutes CV by 60000, and the hours CV by 360000 and add them together, you'll have the total ms.
You'll end up with some big numbers, so change from a WORD to a UDINT.
Add these values together, then use UDINT_TO_TIME function.
Thanks for the hint ph0010421!
Tomorrow I will test something like this...
Hi there,
I'm struggling with a beginner-issue here...
I'm creating an FB to log running times of actuator devices.
My approach is to place instances of these FB's (PulseToTime FB) in a task to be executed on a time basis of one minute. Every input signal's pulse goes to one CTU for totalizing minutes. A second CTU totalize hours.
The output for this "PulseToTime" FB should return a TIME type variable for the totalized device's running time.
I'd like to add the .CV values (WORD types) from both CTUs (the CTU for minutes and the CTU for hours) and then convert the result to a TIME type variable showing only hours and minutes, for example, T#1h20m...
How can I perform this add and convert operation?
Originally created by: ph0010421
The TIME datatype is actually in ms, so if you multiply the minutes CV by 60000, and the hours CV by 360000 and add them together, you'll have the total ms.
You'll end up with some big numbers, so change from a WORD to a UDINT.
Add these values together, then use UDINT_TO_TIME function.
Thanks for the hint ph0010421!
Tomorrow I will test something like this...
pFB_CurrentRunTime:= UDINT_TO_TIME ((100060WORD_TO_UDINT(FB_Minute_Pulses.CV))) + ((10006060*WORD_TO_UDINT(FB_Hour_Pulses.CV)));
Originally created by: ph0010421
Yup