Sign in to follow this  
Followers 0
gleblanc

Daylight Savings Time

10 posts in this topic

Attached is a small program to turn on a memory bit when we're in daylight savings time mode. I've simulated it, and it seems to work fine, but I'm not sure how to change dates and verify that it will continue to work. Anybody want to take a look, and let me know if you see obvious bugs? File is from GXWorks 2, zipped. Thanks, DST ON FLAG.zip

Share this post


Link to post
Share on other sites
Hello, I made some changes to the logic. This is how I would do it. Also, in your program you posted at the end where you would keep the DST flag on after March and before Nov, it is written as before March and after November. I haven't tested this but looks pretty straight-forward. Let me know what you think. I couldn't upload the program file from GX Works2 for some reason so I made it a PDF. Dave DST for mrplcpdf.pdf

Share this post


Link to post
Share on other sites
Hmm, I'm on round two of my program, but yours is clearly much cleaner than what I wrote. The root cause of writing this code is that I've got two controllers that I need to keep in sync, so I have them syncing with a central NTP server every day. This means that I have to adjust the time on those two controllers by an hour every day during DST. Thanks for the note on March and November, I caught that when I started doing testing by changing the date on my PC, and using the simulator in GXworks2. This new logic sets the clock back an hour at 2:02 AM during DST. I did some testing, and I didn't find a way to break it. I borrowed some of the logic from Crossbow's file at http://forums.mrplc.com/index.php?app=downloads&showfile=669 Also, this forum only allows a few file types. I found .zip to be a little easier to create and share (right click menu on windows), but PDF gets all the essential information across. DST ON FLAG.zip

Share this post


Link to post
Share on other sites
http://forums.mrplc.com/index.php?showtopic=18437&st=0&p=88158&hl=daylight&fromsearch=1entry88158

Share this post


Link to post
Share on other sites
Greg, I took a look at the second attempt, and your method for determining when it is DST looks sound. However, I usually set my clock forward an hour during DST.... I think you need to change the DECP to INCP. That also means you won't need the logic with M11. Jeremy

Share this post


Link to post
Share on other sites
Right you are. I've got everything rolled out to both the Q and FX PLCs here at the plant, and it all works (though I guess the final test will be in November!). I've attached both the Q and FX versions of the program, for reference. DST ON FLAG FX.zip DST ON FLAG.zip

Share this post


Link to post
Share on other sites
Of all programs, you published, I've looked through pdf only. Just in case, would like to note that serious shortcoming of the code, proposed by Crossbow, is its incorrect working, if at the DST transition point the PLC is in Stop mode.

Share this post


Link to post
Share on other sites
I don't think it's a serious shortcoming, more of an assumption that he chose to make. My code assumes that the PLC updates it's time via SNTP every day at 2:00 AM, and fixes the clock 2 minutes later. Neither of these are idea solutions, but I think there's less worry about having monotonically increasing times in a PLC than in some other systems.

Share this post


Link to post
Share on other sites
If the solution you described is suitable for the application, then no problem. The code I published for FX-series is working the similar way, but without external syncronization and RTC always show a correct time. Someone who need in DST procedure for Q-series could make attempt to rewrite it for this type of PLC. It's more than real.

Share this post


Link to post
Share on other sites
My code is simply usable when the PLC is powered up and running when the time shift occurs. I never claimed it was a final solution which would work if the PLC was powered off or stopped. That's far more complex logic, and my program was designed to be an example of how to work with the real time clock.

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