Sign in to follow this  
Followers 0
Raydragon

Time since stopped code?

4 posts in this topic

Been a while since i have posted here but hoping someone will take pity on me a knock up what are sure to be simple bits of code for the experienced among you. Quite new to Logix 5000, much more familar with Logix 500 but i spent a fair bit of time today trying to knock up what should be some fairly simple calculations and the further I went the uglier it became... Typically i have left my ugly logic at work but i was hoping someone might be able to point me in the right direction without it. There is probably a few simple Controllogix instructions that can do the work of the rubbish i have so far that i don't even know exist Basically i am trying to do a bit of downtime displaying of a machine as well as a couple of rolling average cutting rates calculations. What I want is to be able to get "time since stopped" Hrs, Mins and Secs as 3 integers for starters, and while the machine is running ( cutting at about 8000 parts per Hour) i want to be able to get a couple of Average cutting rates , one covering say a rolling "last hour" and then the same for a longer period, probably between 8 and 12 hours. The Value that gives me the current cutting rate from the actual machine unfortunately doesn't update or zero out when the machine stops, which would obviously stuff up the actual averages so when the machine is off the logic would need to basically "add 0" to the total while the machine remains off i spose? Any help would be a greatly appreciated, Ladder Logic only please ( V18, 19 or 20) as I don't have a Logix 5000 Version capable of anything else on the work machines.

Share this post


Link to post
Share on other sites
Check out the real time clock. You'll have to use a GSV command to get it out of the processor. Use one to constantly update a time array for your current time, then use another to grab the time when you go down. You'll have two integer arrays, one with the current time one with the time of the stop. If you subtract them, they'll give you down time. The real time clock updates during power outage as well.

Share this post


Link to post
Share on other sites
Now i'm wondering why that didn't occur to me. Thanks, that will be a much easier method for that part of it. Anyone got any suggestions or examples for the other part of my problem? I found a couple of references to FIFO's to do with averaging but didn't really understand how it worked.

Share this post


Link to post
Share on other sites
Sorry, I was reading quickly and didn't see the averaging part of your application. You want to use FFL and FFU to load and unload an array of values. You'll need to define a control tag that you will use for both instructions. The .LEN attribute is the max length of the array. The .POS is the position of the next new piece of data, which you can also use to track the number of data pieces in the array. For averaging, you'll want to use FFL to fill the array until it's full, then on each additional value, use FFU to discard the oldest value then use FFL to load the newest value. Now you have an array of values that you can use the AVE instruction to average for you. Nice and clean. Post your code if you have any trouble.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0