Ataw

How to use plc clock in programming

12 posts in this topic

Hi. I am very very new to plc. Whatever i know is through google and youtube only (so very limited knowledge). I need help about how to use plc clock or real time in a plc. I am using cpm2a with cx-programmer. I need to unlatch a door at a certain time everyday. The door needs to b unlatched for 30 min at a specific time 5 days a week (mon to fri). Is it possible?

Share this post


Link to post
Share on other sites

The real time clock in a CPM2A is contained in these addresses:

+4R+QnJws7xERRTcGPIiIiIiIiIgo6rAPDyIiIiI

 Your code might look like this:

First determine if the time range is correct (This example check from 5:00 to 5:30 pm):

LO419GvH2W316HAEAAMAQEAZBHy++fDiELJdregU

Then determine if the day is correct (this example does Monday through Friday):

oGsK0X59atduWEN9K7KxT1ZfPSZEMcCAAAAAADAS

Share this post


Link to post
Share on other sites

You might want to check out the MOVD instruction in case you want the format different. For example if you would like the hour to be first and then the minute be last in the word. Or if you would like to just have the minute only or hour only displayed in a word. The example i have would transfer just the hour into DM0.

cxp.JPG.9c3262cc8ca967232fb47f6518a49429

Edited by b.k.n.

Share this post


Link to post
Share on other sites

Use ANDW as a mask - ANDW #00FF or #FF00  AR19 D0 - easiest way to separate hours/minutes/days/month/seconds.

Share this post


Link to post
Share on other sites

Thanks i agree easier way thanks. Now i have one question am I correct that if i mask it with #FF00 and for example if AR19 = #1925 the results in DM0 would be #1900. I would tend to think most people would like those results over in the right two digits and not the left two. I guess you could divide DM0 by 100 and get them moved over to the right two digits. Let me know if I'm wrong and thanks again for that ANDW idea.

Share this post


Link to post
Share on other sites

b.k.n.,

You are correct in your statement that a BCD divide by #100 after the ANDW instruction would also do it. 

This is CJ2M Code so that I could simulate, but would be very similar in the CPM2A PLC:

DjIhl+D8LO8AAAAASUVORK5CYII=

Ataw,

Also, I wanted to point out in my original example that the upper 3 bits of A21 are in fact used, but it seems that they are output bits, so unless you assign a coil to them, they should all be off.

Share this post


Link to post
Share on other sites
21 hours ago, Michael Walsh said:

The real time clock in a CPM2A is contained in these addresses:

 Your code might look like this:

First determine if the time range is correct (This example check from 5:00 to 5:30 pm):

Then determine if the day is correct (this example does Monday through Friday):

Thank you Michael Walsh I will try to do this at work today then lets see how far I can go. 

Share this post


Link to post
Share on other sites
14 hours ago, b.k.n. said:

You might want to check out the MOVD instruction in case you want the format different. For example if you would like the hour to be first and then the minute be last in the word. Or if you would like to just have the minute only or hour only displayed in a word. The example i have would transfer just the hour into DM0.

cxp.JPG.9c3262cc8ca967232fb47f6518a49429

Thanks b.k.n .

Share this post


Link to post
Share on other sites
4 hours ago, b.k.n. said:

Thanks i agree easier way thanks. Now i have one question am I correct that if i mask it with #FF00 and for example if AR19 = #1925 the results in DM0 would be #1900. I would tend to think most people would like those results over in the right two digits and not the left two. I guess you could divide DM0 by 100 and get them moved over to the right two digits. Let me know if I'm wrong and thanks again for that ANDW idea.

That is why I prefer the ANDW instruction. 

1 instruction instead of 2.

Share this post


Link to post
Share on other sites

They go into the right 2 digits for hours anyway. I generally only have to extract hours. If you are extracting the left 2 digits Michael's solution is the way to go. ANDW just makes life easy.

One of my favourite instructions along with BCNT and APR - so useful and nor available in most PLCs.

Share this post


Link to post
Share on other sites
On 6/9/2016 at 2:35 PM, Michael Walsh said:

The real time clock in a CPM2A is contained in these addresses:

 Your code might look like this:

First determine if the time range is correct (This example check from 5:00 to 5:30 pm):

Then determine if the day is correct (this example does Monday through Friday):

thank you Michael Walsh and everybodr ru

Share this post


Link to post
Share on other sites

thank you Michael Walsh and everybody else. very busy at work so only yesterday got a chance to look into this project. it works perfect according to our needs. this place is certainly a great help for guys like me who dont have any back ground qualification for plcs and are just getting started. I will certainly keep coming back to learn from you guys. once again i thank you all. 

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