Plc code uptime

Mr_Black

Member
Join Date
Oct 2003
Location
Arizona
Posts
10
Can someone help me in writing a small bit of code to track uptime of a peice of equipment.? Take 1 input and see what % of the last hour it was "on". And then for 8 hours.

Thanks

Mr_Black
 
Mr_Black

I think that you will receive more 'helpful' replies if your question was "I have written this code (posted below) to do this:- Take 1 input and see what % of the last hour it was "on". And then for 8 hours. It does not work the way I intended, could someone help me out and tell me where I am going wrong ?"

That way everybody could see that you have put some effort in and tried to help yourself.

There is an unwritten rule in this forum (sometimes broken) that no one will write the code for you, but everyone (those that can) will amend your code and point you in the right direction.

Those that request help, must first help themselves.

Paul
 
Not code, but a method

I won't write the code for you, but I'll suggest an approach. I'm assuming that you want a "rolling" hour window - that if the machine was running for 1 hour, then goes down for 15 minutes, and then goes back to running, you want the one-hour display to show 75% for 45 minutes, and then climb back to 100% as rest of the hour ends (assuming no further downtime).

To track when the machine was up and down, you need a shift register. But it's a pain to count the number of bits in a word, so just compare the entering and exitting bits.


Use a self-resetting one minute timer.
Set up a Bit-shift register that is 60 bits long.
Have a register that represents the total number of 'UP' minutes of the machine.

At the end of each minute, examine the status of the machine. If it's UP, set the bit that will enter the shift registers. If down, reset the bit. Perform the bit shift. If the bit exiting the shift register is reset, and the machine is currently running, add one to the Up-minutes register. If the machine is down and the exiting bit is set, subtract one. If the current status and exiting bit (i.e., the machine status one hour ago) match, do nothing - the efficiency hasn't changed.

Althought in theory, the up-minutes register should never be able to be calculated to be greater than 60 or less than 0, error checking wouldn't hurt.

Percentage running time = Up-minutes/0.60

For 8 hours, use a 5-minute timer and a 96 bit shift-register (a 480-bit register would be too much for some PLCs, and I doubt you need more than ±1% accuracy.
 
Uptime %

:)

I was not asking anyone to write code for me just simply to give a little help.

Thanks for pointing me in the right direction, I will take what you've givin me here and go to work on it. I will post later and let you know how it turns out.

Thanks Again

Mr_Black
 
Another way....

How about 2 counters, both updated once per minute with an extra bit in the rung of one of them that only lets it count if the machine is running. Then calculate the uptime percentage from those 2 numbers, and reset both counters at the end of the shift, maybe after copying the percentage to a data table for viewing later.
 

Similar Topics

Hi All, Someone at work has put a PLC system on my desk, that's just been taken off an idle production line. He said "It's an S7 PLC. We don't...
Replies
10
Views
284
I have a machine which is undergoing upgradation. As part of the process two SEW drives are being replaced., existing Gen B with new Gen C. The...
Replies
3
Views
222
I want to set user security level based on the value of a tag in my PLC called "ActiveUser". That tag will contain the A-P code which we use for...
Replies
6
Views
236
Hi All, I wanted some feedback/thoughts on code implementation or development across several offices. What has been your collaborative...
Replies
6
Views
426
Hi! I'm fairly new to PLCs, and a PLC I was swapping sensors for shows the error code 497 - 0x050000 on the top of the HMI when I powered it back...
Replies
6
Views
629
Back
Top Bottom