Sign in to follow this  
Followers 0
brianafischer

Converting Time on MicroLogix and PanelView

24 posts in this topic

I have an application which counts a cycle time in seconds on a MicroLogix 1200. The display is a PanelView 600. I would like to display the total cycle time on the PanelView in hh:mm:ss. The most obvious way of doing this is dividing the seconds/60, minutes/60. Is there an easier way of accomplishing this rather than using 3 integers and 3 panelview tags for each timer? Thanks!

Share this post


Link to post
Share on other sites
Not that I'm aware of . Pretty much use a text object and embed three numeric variables. "HourTag":"MinuteTage":"SecondTag"

Share this post


Link to post
Share on other sites
Ahhh.. the text with embedded numeric variables is perfect. I was trying to avoid using 3 int tags, with two ":" text objects... Thanks

Share this post


Link to post
Share on other sites
Beware - Size your text box to the longest string anticipated and test it with several times both AM & PM. Nothing worse than a text of 12:23:5 and no 6 on 56 cause you forgot about double digit hours.

Share this post


Link to post
Share on other sites
use modulus insteed of dividing

Share this post


Link to post
Share on other sites
Hi, Check out the link below, may be of some help, http://www.plctalk.net/qanda/showthread.ph...ht=hh%3Amm%3Ass Regards _________________

Share this post


Link to post
Share on other sites
And how would one do that on a MicroLogix 1200? I am currently using the DIV command to S:13 to obtain the quotient and remainder...

Share this post


Link to post
Share on other sites
How can I convert a long data type into hh:mm:ss? This has become more of a challenge than I though. I just got off the phone with Rockwell support, and they said this is pushing the limits of the MicroLogix controller. Here is what I am trying to do: 1. If the seconds remaining are > 32767, then the PLC will fault. Thus, I changed the MUL calculation to store a long for the "seconds remaining". 2. The DIV instruction only supports 16-bit operations for the S;13 and S:14 registers. Thus, no quotient and remainder when using a long data type. 3. The float instruction will give me a decimal value that I could use, but how do I extract the value to the right of the decimal point? Thanks!

Share this post


Link to post
Share on other sites
Think we can come up with something easier but before we start, how long can this cycle time be?

Share this post


Link to post
Share on other sites
Well, it needs to have a resolution of seconds (to stop test at correct time), and it might need to last a full 24 hours or 24(hrs/min)*60(min/hr)*60(sec/min )= 86400 seconds. The main problem is when I multiply by the cycles remaining that overflows the 16-bit integer and requires a long... For instance, the test needs to run once a day, for 4 weeks: 86400 (sec) x 28 cycles = 2419200 seconds. Thanks for the help!

Share this post


Link to post
Share on other sites
Take a look at this: http://forums.mrplc.com/index.php?autocom=downloads&showfile=576 I have used variations of this method to create very long running timers. A variation should be good for 1 second resolution up to 16.7 million seconds. By using a freerunning timer and subtracting from its accumulator and adding a matching amount to the register designated as the long durations timers accumulator you eliminate the cumulative scan errors that creep in when timers and counters are cascaded. Here is a way to do it in a ML1200 with a 32 long. Should be able to time for about 68 years. LongTimer_ML1200.RSS Edited by Alaric

Share this post


Link to post
Share on other sites
Alaric, The program looks good. The only thing I would change is the Greater than instruction. "GRT". I would put in a "GEQ", Greater than or Equal to, instruction in its place. With the current instruction, "GRT", the value must reach 1001 in order to execute. With the "GEQ" instruction, the value of 1000 will execute the rung. Just my 2 cents,

Share this post


Link to post
Share on other sites
Sorry, I thought that was more or less worked out and the issue was the 16 bit limitation. Here is an expanded program that shows how to convert the number of seconds stored in a Long into Hours, Minutes, and Seconds. I tested it on a ML1200 and everything appears to work. I used a preset of 100 hours, 360000 seconds and plugged in several different accumulator values. It doesn't provide any negative value or overflow checking, but it should be enough to get you going. If you improve on it show us your finished result. Good luck. edited to delete attachment and remove file - a newer version is below. Edited by Alaric

Share this post


Link to post
Share on other sites
Could you do an integer to string and then a concatenate? See attached example ST14:1 and 3 would contain : The last ST14:9 would be the full "hour:minute:second" STRING_TIME.RSS Edited by Gary Burton

Share this post


Link to post
Share on other sites
Good point Gary. It has the beauty of needing only a single tag. I modified my previous example and tested it. HMS_LONGPERIODTIMER_StringOutput.RSS edit: I see while I was making and testing my modification you added an example. Edited by Alaric

Share this post


Link to post
Share on other sites
Gary, When I downloaded and ran your program as is I got this as my result: "0000" When I put time vaules of 5 hours 10 minues and 15 seconds in N7:0-N7:2, I got: "510155" The strings ST14:1 and ST14:3 apparently needed to be predefined with a ":", so I added that and got: "5:10:155:" That still doesn't look quite right. When you ACN your Hour with a ":" you place it in ST14:5. Then you mix it up when you ACN the seconds with ST14:5. You should leave out this step as a colon is not needed after the seconds, and just concatenate ST14:5, ST14:7 and ST14:4. Numbers 0-9 should be padded with a zero in the minutes and seconds columns. You idea is a very good idea though. Edited by Alaric

Share this post


Link to post
Share on other sites
Yeah - I never ran it, just rattled it off. Should work with a few modifications like you have done though :)

Share this post


Link to post
Share on other sites
This would be useful in displaying variable-length strings... One thing I noticed in the panelview is the option to select between integer and unsigned integer. How would one use an unsigned integer on a ML1200?

Share this post


Link to post
Share on other sites
You have to use the carry bit and a bit of programming legedemain, but it can be done. Look for technote A45432954 in the AB Knowledge base (cripes I hate that we can't hyperlink directly to the tech notes now) or enter 25043 into the search text field and select search by ID.

Share this post


Link to post
Share on other sites
Check out this topic about direct linking, Alaric.

Share this post


Link to post
Share on other sites
Thanks Bob. This should link directly to the technote. Naturally it works for me because I am logged into the KB. Let me know if it works.

Share this post


Link to post
Share on other sites
The link worked for me after I logged into Rockwells Knowledgebase just fine.

Share this post


Link to post
Share on other sites
I modified the program to display weeks, days, hh:mm:ss. The machine displays when the current cycle will complete and when all cycles are estimated to complete. Below is the logic I used (untested). WDHMS_LONGPERIODTIMER_ML1200.RSS -Brian

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