hour timer in AB

g.robert

Lifetime Supporting Member
Join Date
Aug 2003
Location
texas
Posts
320
Hello all.

We use alot of Moeller smart relays (same as PICO)for basic system logic. The timers within can easily be selected to time in seconds,minutes or hours including a decimal place to allow an entry of 1.1 which could be for 1 and 1/10 of an hour or 1 hour and 1 minute, or ETC.

We also use alot of AB micro 1K to 1.5K (and some SLC500). I have a program I allways use with AB that has a timer(TON). The value to the preset(PRE) is moved from a location written too via a micro300 panelview as well as the panel view reads the accumulated (ACC)value. This is allways done in seconds (0-9999 seconds). Customer now wants to enter values in hours and tenths (1.5 = 1&1/10 hour)0.- 24.9 hours.

The only way I know is to use a combination of counters and timers to get where I need to be. The obvious problem to me is it takes alot of "jumping" around to get from an entry at HMI of 1.1 to an actual timed value of 1&1/10 hour. The bigger problem is there are multiple areas in my program monitoring the status (EN & DN)of the original seconds timer.

Does anyone know of an easier way to have a timer set up following the criteria I mentioned above?
 
First off, you can't do floating point in a ML1K, but you can in the ML1200 and ML1500, so in the ML1K you will have to use an integer with an implied decimal point.

I would approach this by creating a floating point hour timer. There are a couple of "gotchas" to watch out for when using a timer and a counter. A timer can keep very accurate time, but the timer /DN bit is not so accurate. The DN bit is set when the timer instruction is scanned and the ACC >= PRE, but this rarely happens exactly when ACC=PRE, rather ACC is almost always slightly greater than PRE. So with simple counting, each time you sum in the extra time between when the time period actually elapsed and the timer is next scanned. You do this enough times and you can have significant timing errors. You get around this by making your timer PRE much larger than desired and instead of using the DN bit and resetting the timer, you subtract the desired preset from the ACC everytime the ACC is > than the desired preset and put the difference back into the ACC.

Now you can use floating point words to sum and calculate the elapsed time in hours. An hour has 3600 seconds in it, so if you add .01 to an floating point word every 3.6 seconds you can keep track of 1/100ths of an hour. By entering the preset into a floating point word in hours and doing a comparrison you can achieve a very accurate floating point hour timer. If finer resolutin that 3.6 seconds is needed then use thosandths of an hour (.36 seconds) or use the timer ACC residual for your calculation.

The attahced PDF shows how to do it as described above. This method gives you a timer which you can use for very long timing durations up thru more than a million hours (should be long enough).

If you are using timing durations that are much shorter (less than 9 hours) then there is no need for convoluted hoop jumping. Just place the time preset into a floating point number and use basic math instructions to convert it to seconds. Eg 5.6 hours is 5.6 hours * 3600 seconds/hour = 20160 seconds.

If you don't need as much resolution, such as just 36 seconds (.1 hours) or 3.6 seconds (.01 hours) then it can be simplified. For scan times less than .1 second and for time periods of less than 36 hours but with .1 hour (36 second) resolution you can probably just forget completely about timer ACC summing errors and use a basic counting method, you'll fall well within the .1 hour resolution.

Edit:
You could also use a bit from the free running clock in S:4 to provide your time base. It all depends on the accuracy you need.
 
Last edited:
Thanks for the informative reply Alaric. I will have to work through this and apply as required. It's going to be a real pain because of all the other re-working I'll have to do to other parts of the program. You miss one thing and it bites you in the butt somewhere else in the program.

I was hoping there was something hidden in the back that would do what I want as an out of the box solution. I wonder why what appears to be a common task (to those on the outside looking in)has to be so complicated. Customer thinks, change it from seconds to hours. No big deal.I mean most of the smart relays have real time clocks for <$200. You can set up a 7 day timer in seconds on them. Oh well.
 

Similar Topics

I am using a CompactLogix. I need to know whether it has been at least 24 hours since a certain event happened. I want to use the wallclock so the...
Replies
16
Views
4,669
Hello everyone, i have searched this forum and looked here for advice before but this time i wasn't able to find an exact answer for what i'm...
Replies
14
Views
10,424
Hi there, I have an SLC503 that I'd like to control an external contact with. Basically I'd like to assert my local contact on the 503 every 12...
Replies
14
Views
7,184
hello I have a system to program in which there are two HVAC's.Always one is standby and the other is running.The HVAC RUN command is given from...
Replies
4
Views
2,268
Need help a source code to make timer display into hour:min descending from a time of delay 1 sec base timer. Thanks
Replies
22
Views
5,937
Back
Top Bottom