Running hours counter with retention Micro810

Subsea7

Member
Join Date
Mar 2021
Location
UK
Posts
45
Hi, I'm experienced in Studio 5000 / ControlLogix but have a small project to do in a Micro810 with CCW and something is driving me nuts. I want to store an accumulated time for a machine running so maintenance can look and see how many hours it has actually run for.

The idea was to grab the total ET from an RTO, add it to the T_Master_Count variable (TIME format) and then store that as a retained value (which weirdly only works on local variables, not globals as those get cleared out on every power-up regardless of "retained" setting being ticked in CCW) then if the PLC was powered up again, when running the machine it will continue adding the running ET to the T_Master_Count.

In a ControlLogix I would use MOV or COP to put the previous value of T_Master_Count into another temp variable, add the ET to that, and then MOV or COP it back to T_Master_Count. That way it doesnt rack up to crazy numbers by itself. The RTO doesn't store the ET between power down events, and machines get locked out for maintenance so the hour counter has to be stored for next time it wakes up.

In the Micro810 there is a MOV FB so I thought ok, I'll move the master count value to a temp variable and then add the RTO ET, using the _SYSVA_FIRST_SCAN on a ladder rung but it never executes - as if that bit never becomes true.

Am I missing something stupid? This would be so easy in Studio5000 but it seems to be annoyingly difficult to get it to work in CCW. Can't justify an L83 for example to count running time. The Micro810 is ideal as it has the LCD to display the hour count of the machine for the maintenance guys.

There must be an easy way to count elapsed time when a particular input is on, and then store that value when the input goes off. Next time it is on again, start adding to the value again so a cumulative total time value is stored. Maybe I'm getting tired but I just can't get this to work on the Micro810.

Can you do a one shot (ONS) on the 810? I can't find anything like it in the editor.
 
Rather than trying to reverse-engineer an RTO's behavior through power cycles and mode changes, once I knew I could retain a UINT or Time tag through those events, for simplicity I would go with RTC_READ and add 2s to the retained value on every rising edge (https://literature.rockwellautomati...[{"num":861,"gen":0},{"name":"XYZ"},52,436,0]) of bit 0 of RTCData.Second when the discrete input indicates the machine is running.



Then the code is doing the same thing every scan, and I don't care about first scan.


The model that approach represents has an error of 1s (2s?) on average per machine state change, but on and off errors will roughly cancel, and if the maintenance cycle is measured in hours and there are not a lot of on/off cycles, I suspect that will not matter.
 
Wait a minute, the manual here says the ET of the RTO should persist across power cycles if configured to do so. Does it not work that way?


xxx.png
 
The one-shot we all love isn't available in the CCW. But there is a R_TRIG (rising edge detector), which engages for one cycle.
I'm just now having to get into the CCW as a "more reasonable" Allen-Bradley offering.
 
Hello Subsea!

I too have also had to learn a-lot about CCW very quickly. If you are looking to count up say the number of seconds and input to the PLC is on, I would recommend making a clock in structured text using the TON function. If you are looking for rising edge counting, you could try and create a de-bouncer in your sw/code. (im not sure if there is a function that does this or not in CCW)

Additionally, since if this PLC has no micro SD slot (from what i can see) you will have to make sure the device is powered 24/7. the Micro820 has an SD slot that lets you store loads of variables and data into. Let me know if i'm making any sense and i can explain further.

Example code below

//timers
Global_HeartBeat_01((NOT Global_HeartBeat_02.Q), T#2s);
Global_HeartBeat_02(Global_HeartBeat_01.Q, T#2s);
WAIT_TIMER_01(WAIT_FLAG, WAIT_TIME);



/// simple de-bouncer of sorts. just fires something only once. then resets
IF Enable THEN
if NOT OneTry THEN
//Onetry only sets the state machine to state zero once.
Charge_states := 0;
OneTry := True;
Finished := false;//resets funciton finished output.
END_IF;


//if charging is requested, use fuction below to start and stop charger.
MB_CHG_01(Ready,FALSE, MB2_LocPara_01,MB2_TarPara_01,MB_LocAddr_01);

ELSE
OneTry := FALSE;//resets onetry
Ready := FALSE;//resets ready for next function use

END_IF;
 
Thanks guys. I have created a cascade counter set using CTU's that roll over and self reset using the CTU-1.Q bit for example, one counts seconds, hits 60 then triggers the next CTU to count 1 (for minutes) then etc etc for hours.

The big problem with RTO's is they use the TIME variable type, but in AB code those have a limit of 47days, 117hours for example. This device is to count run hours on a machine that could hit tens of thousands going forward and 47 day limits mean just over 1000 hours so that wasn't going to work.

The other annoyance is that RTO tags retain easily when "retain" is ticked, but it seems no other vars retain in the same way, it dumps them when powered down. TIME vars however, did retain through power downs. Weird huh. So I may end up using Any_To_Time for secs, minutes and hours so I can retain them but you still have the low limit they have. And you're right, no SD card on the 810 but it's perfect as it had the LCD panel for the maintenance techs to read. When required hours are hit, they carry out certain tasks. It has to maintain that count for years.

Maybe I can push the DINT counters of the CTU's to UINTS if those are retained. Funny you can tick anything to retain if it's a user created variable, but it doesn't work.

Incidentally I got CCW 12.0 and it has a Logix theme you can select, which is good because all the old favourite things you can select in Studio5000 are now available. Shame the retention doesn't actually work for non TIME vars. Maybe UINTs do. Have to try that as rules mean LOTO for maintenance so it has to survive power downs.

Also there is ONS available once you enable the Logix theme, and it has AFIs for testing, the whole instruction set of the ControlLogix is there with CCW 12.0 so will keep trying different techniques to get the values to actually be retained.

Thanks so much for all the helpful replies. Any ideas on the retention issue gratefully received!
 
Last edited:
from the RTO here, the possible values range is from 0 ms to 1193h2m47s294ms

If we multiply it out, that is 4G milliseconds i.e. the Time data type is a 32-bit unsigned int.

So you could keep two Time tags: one runs from 0 to 24h0m0s0ms (i.e. 1d) in the RTO, and the other increments by 1ms every day i.e. every time the RTO hits its PT, and when the RTO hits its PT, it resets (feed RTO.Q into the RST input).

You can use the ANY_TO_TIME (see here) to convert an integer value of 1 to milliseconds, and add that to the "days_as_time" Time tag when the RTO's .Q is 1 (for one scan), then use the ANY_TO_UDINT (see here) to convert the days_as_time tag
when you want to convert back to an integer number of days.



Obviously this is a hack and could probably be done many other ways, but if you can only retain Time data types, this seems like a workable choice.
 
Yeah the issue is the TIME tag limit as you say (exactly) is just over 1100 hours, a machine running 24/7 will hit that number in 6 weeks. I want to leave this working for years, not have to keep messing with it.

If the tags which are supposed to retain, actually did that, it would be straightforward.

I'm going to call our Rockwell account manager and see who they can put me onto in RA to find out why this doesn't work.
 
OK Update - solved the retention thing. On the Micro810 you need the LCD screen or the RTC module to actually save variables, and it applies to all variables.

I have the LCD, so you go to the controller main page, select LCD, select load on powerup > Load Always and then click LCD Variables > tick the ones you want retained, and bam it saves them to the LCD and restores them on power up.

The TIME vars are already too limited in value for my purpose but using CTU's as a cascading software timer extends the count ability to as long as the number of hours that can be described in a DINT (or UINT if you want to go nuts) - so 2147483647 hours.

For anyone else trying something similar or just need help making an unlimited (nearly) cascading counter or timer, here is how I did it (attached)

(I used an RA UDFB for the 1 second tick as its a good bit of code, you can set the tick count to anything from 1ms to 1139 hours. That just triggers the first CTU to count seconds, then roll over at 60, which triggers the next one to count minutes and roll over at 60, which triggers the next one to count hours.)
 
Last edited:
Plenty of ways to do it. E.g. add 0.0177778h (=64.0s/(3600.0s/h)) to a float for every rising edge of bit 5 of RTC.Seconds, that float is total hours; if this machine is going to accumulate thousands of hours, it will not likely matter if the resolution is around one minute.
 
What I did using dints works fine. Simple is better.

Using cascaded CTUs to trigger each one in the chain and self reset the first one on 60 secs and the second on 60 mins works perfectly.

Cheers buddy.
 
Glad it worked out. I like that cascading solution, because then there is not need to convert seconds (or milliseconds, even better ;)) to HH:MM:SS.
 
For machine run timers, I typically use a retentive timer set to 36 seconds and each time it completes, I increment a Long integer and reset it. That Long integer provides run times to the hundredth of an hour and I scale it that way on the HMI.

I usually include a rollover for the long integer at 100,000,000 or a billion counts (one or ten million hours), because I expect my controllers to still be running many years after I have returned to dust and I don't wanna be the cause of a math overflow or negative hour total in the year 3097. Seriously I think I stick that GRT>CLR logic in there from habit of doing flowmeter logic.

I don't do CCW, but here's what a typical run hour meter program looks like in a Micrologix.

hourmeter.png
 
I'm a Rockwell-trained Logix programmer too, I just needed an independent display of run hours for the maintenance guys to check on an old machine. Hence the Micro810 and CCW.

Three rungs with cascaded CTUs did the job simply, I just couldn't get it to retain the values when powered down till I figured the variables need to be marked as "save to LCD"
 
Last edited:

Similar Topics

Dear engineers, i want to change the hours meter to any value i need but i can't change it. how to change it...plz help me
Replies
7
Views
2,023
Hey All, I'm looking at putting a running hours indicator into a system and wondered what the best way to do it is. This is what I've come up...
Replies
17
Views
5,698
I want to find pump running Hours(H,M,S). How I can find it?
Replies
6
Views
2,393
Dear All, I need your help to program a PL7 to count running hours of motors. Can anybody send me the program. Regards, Marwan
Replies
0
Views
1,887
I have no experience with Eaton HMIs. I downloaded the Galileo software and I am trying to get the file on a HMI (XV-102-H3-70twrl-10) to modify a...
Replies
4
Views
101
Back
Top Bottom