12 Hr Clock

dyne2798

Member
Join Date
Mar 2011
Location
Ohio
Posts
35
Hello All,

I am looking for some help to understand how to develop a program for a 12 hour clock. I am taking a class at the local community college, and so far I have understood what we were learning. The last lab was a motor starter, which I am familiar with. Now we are to build a program for a 12 hour clock and I am kinda lost. I have gone over the notes, but I am still "clueless" for the most part. I have a LogixPro 500 simulator that I was hoping to be able to use the 24 hour clock program we went over in class and modify it, but I guess I'm just not understanding this enough.If anyone would care to offer an explanation that puts it more in plain english it would be greatly appreciated.
 
Last edited:
I am going over our example and the logixpro simulator wont let me change the time base from .1 to 1.0 to set this TON for seconds. any suggestions? The only thing it will let me change is the Timer and the Preset.
 
If you have a working 24 hour program then that is a good start.

You could leave the 24 hour program alone but work with the 'hours' portion of its output.

You will need to create two locations. One will hold the '12 hour' version of the hour. Another will hold an indication of 'AM' or 'PM'.

Now think about the modifications you will need. How will the 24 hour clock's 'hours' translate into the 12 hour clock's 'hours' plus AM/PM indicator?
 
Last edited:
Bernie,

What about using a toggle for the am/pm? Would you also use a Add and Subtract instructions to get the hours correct?
 
That's one approach. Remember, if you have an accurate '24 hour' version of the hours then the AM/PM setting is directly based on those hours. But if you are starting from scratch then a toggle may be ok.
 
I have put the 24 hour program on my simulator that I purchased from the learningpit.com and it seemed to operate fine.(other than the program will not let me change the base time to seconds.)
 
Here is what I have so far:
Seconds
-------------------------------------------------RTO--------------(EN)
Timer T4:0 (DN)
Time Base 1.0
Preset 60
Accumulated 0

Minutes
--T4:0/DN------------------------------------CTU------------------(EN)
Counter C5:0 (DN)
Preset 60
Accumulated 0

Hours
--C5:0/DN------------------------------------CTU-----------------(EN)
Counter C5:1 (DN)
Preset 12
Accumulated 0
T4:0/DN T4:0
--[ ]---------------------------------------------------------(RES)

C5:0/DN C5:0
--[ ]---------------------------------------------------------(RES)

C5:1/DN C5:1
--[ ]---------------------------------------------------------(RES)
 
Last edited:
I can understand everything I see so far, but I am not clear on how to modify it to a 12 hour clock using what I currently have.
 
Why does the 'hours' counter (C5:1) have a preset of 60? For a 24 hour clock it should be 24.

For a 12 hour clock you can change it to 12. Then you'll have to deal with the AM/PM toggle and the correction of the '0' hour to '12'.

The RTO is a bit useless since if the power is turned off the 'time' is going to be wrong anyway. This really wouldn't be practical for a 'real world' application.
 
Last edited:
Sorry, I typed it all out then had to go back and log in and when i did i lost what i typed. i had to go back and retype it all and i just copied and pasted the above and made some changes( obviously not enough)
 
i'm sure this is elementary to a seasoned programmer, but it seems like the class has taken a leap from week 5 to week 6. I hope all these questions aren't too annoying, I am just trying to assemble enough understanding to be able to try and understand how to make this work.
 
The seconds timer should be a TON then not a counter. My fingers are typing before my brain gets a chance to process the thought. sorry
 
No - the seconds needs to be a timer - it's just that making it an RTO instead of an ordinary TON didn't add anything. This 'clock' won't survive a power-off because it can't keep timing then. The 'time' will be wrong.

RTO is not a counter - it is a timer but whose accumulated value is not reset after a power off. But in this setting that added value is useless.

The RTC chip in real PLCs uses the battery power to keep the clock going.
 
Last edited:
Bernie,

How do you post attachments here? I wanted to post what I have so far for the clock I am working on.

Thanks,

Mike
 

Similar Topics

We recently purchased a IC693CPU352 module and it appears the internal time clock is static. I can set the time and date but once set it does not...
Replies
5
Views
166
Hello. I cannot change the SendClock settings for a PROFINET IO device. I need to slow down the CODESYS PROFINET IO controller. What am I doing...
Replies
0
Views
196
Hello everyone, I am not a programmer, but I can do some simple programming. So now I want the time to be recorded every time a pump turns on. I...
Replies
35
Views
2,692
Hello, I am trying to create an AOI that will retrive the clock datetime bits from a master plc through a generic message read instruction and...
Replies
2
Views
487
I was online a SLC5/04 yesterday and one thing I did was go to processor properties and set the date and time to get the PLC clock current. It...
Replies
4
Views
718
Back
Top Bottom