
AD-PLC (Customer) asked a question.
Using Set Time in ladder logic
Hi,
I'm a little stumped on how to use the internal clock in my ladder logic. I have the SETTIME already setup. I'm almost certain I'll be using SDT time structure. Is this similar where I have to designate memory location so I can properly use it in my ladder logic? I saw examples where the $Now.Minute is in the ladder code but this is stumping me.
My application is to have an HMI where someone can choose what dates and times they can run their motor. Monday - Sunday 12am - 12pm. I've seen examples where the MEMCOPY is used then MATH function. I've seen some people covert to EPOCH. I'm just trying to wrap my head around it.
Please post a simplified version of what you have initially. The $Now structure can be used in a comparator to do what you're asking.
Here is what I have initially. I don't mind doing the leg work. I just been stumped. Need the expert guidance. Thanks!
SETTIME sets the RTC on the PLC. This is not what you're trying to do (I don't think). Remove the SETTIME and the MEMCOPY.
For example:
If you want a motor to turn on on the 7th day of the month:
|------$Now.Day=7--------OUT (C10)----|.
Here is my game plan. I will have a remote HMI. End-user chooses, for example; M-W-F 8a-1p to run their motor. I was looking at similar examples where people were talking about when lights would come on during a work week. I assuming what will happen is the data from the HMI gets read into a readable format for the PLC and I take that stored memory location to use in my ladder logic.
I will have to compare dates/times thus giving my contact bit a true statement to run my output coil. I been scratching my head how you even put the $Now.Day in the ladder logic. I attached another example in the attachment that I seen someone do.
Not knowing how much flexibility you need, the attached shows an example that would allow the same motor to run on either Monday or Tuesday at two different time periods (specified at hour level fidelity) on either day that would be specified in the HMI.
Hi @AD-PLC (Customer)
Here is a post using the $Now.Day and adjusting for daylight savings time in the BRX.
https://accautomation.ca/adjusting-daylight-savings-time-in-do-more/
It will show you using the calendar clock functions in the ladder.
In your case, the HMI would turn on/off 7 different internal bits. Each of these bits would correspond to a day of the week.
Your ladder would include this bit and the comparison bit for that day of the week.
The hour is 0 to 23. Compare the hour entered greater or equal to the current hour, and the current hour less than the entered stop hour.
I hope this helps you out.
Regards,
Garry
https://accautomation.ca/series/brx-do-more-plc/
Thank you RB and Garry,
I'm going to dive back into this today in the afternoon. I'll update as I dive into this. Much appreciated. Thanks.
RBPLC and Garry,
I see what I was missing. I'm going to continue on and setting up the the ladder logic right now and messing with the HMI to get what I want accomplished. I ran it through the simulator and the time frame is working like it should be for the day. Now I'm going to work on setting up run times for Hour and Minutes. A million thanks.
Just for any future reader / programmer:
My mistake was trying to find the $now structure. This what I was stumped on. Download the Daylight Savings program code and you can see how the time structures work. I added the |=| contact in but I took the "long" route of find the time structure. You can type it in the field too. Use F1 to see what numeric numbers correspond to the days of the week.
FYI, I like to use Symbolic Constants (just nickname/tag for any constant value, not element - see Documentation View) and assign 0 to Sun, 1 to Mon, 2 to Tue, ... 6 to Sat. Then use the symbolic constant in your ladder logic instead of the hard constant, and it reads MUCH better:
Note how the value for Mon and Thu show up in the Extra Info, so you get the best of both (i.e. the symbolic name "Mon" and its value, 1)
Oh wow. I did not know of this feature. I agree that it does read much better. Thanks for the tip.