Monthly reset--Control Logix

Join Date
Jan 2014
Location
VA
Posts
27
Hello All

This seems like a fairly simplistic question, but I've never used the GSV instruction before. Will the logic in the attached image be an efficient method to fire a monthly reset?

I have this GSV inside of a slow (2000 ms) task so it doesn't bog down the processor.

Any comments are welcomed.

deleteme.jpg
 
I have only started with programming in the last few months so take what I say with a grain of salt. I did however use the GSV instruction recently. From what I recall the LocalDateTime it grabs needs to fill out a DINT, which I assume you have with CLOCK.MONTH however this will only fill in the year. You need to make it an array of 7 DINTS where it then filters through all fields of the array filling in the following information into each field:

Year
Month
Day
Hour
Minute
Second
Microsecond

In the GSV you then reference the first field of the array so it should be CLOCK.MONTH[0] (the first field of the array) instead of CLOCK.MONTH

To then set a bit every month I would then have an array where the month field scales up every time you get an equal comparison. to do this I would:

Make an array of 7 DINTS filling in each one for when you want the next reset to be.
Use an FSC instruction to compare the CLOCK.MONTH array to the preset array.
When there is a full array match use an ADD instruction to scale the preset array to next month, also set your MONTHLY_RESET bit.

Look at page 467 for info on the FSC instruction:

http://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1756-rm003_-en-p.pdf

There is probably a better way to compare the arrays. FSC seems to compare individual fields instead of the Full array.

Hope this gets you a step closer.
 
It looks as though you have created a CLOCK UDT for your WallClock data with the following members....

.YEAR
.MONTH
.DAY
.HOUR
.MINUTES
.SECONDS
.uSECONDS

Providing they are all DINT members, this is fine, and much better than using a DINT Array tag, and having to remember that, say, CLOCK[4] is the minutes...

So your GSV of the WallClock's LocalDateTime, will "fill in" 7 DINT values into your UDT tag, but you need to specify the starting member, so your GSV Destination needs to be CLOCK.YEAR, then everything else falls in line...

I don't know what the Timer in your code is intended to do, you don't need it. If you want to trigger some code to occur Monthly, e.g. the 15th of every month at 0300 hrs, all you will need is something like the pic, which generates a one-shot trigger "Report_Now" at the prescribed day and time....

I wouldn't worry about putting this code in a Periodic Task, it will execute in a few microseconds, and will not have a detrimental effect on your scan time...

2017-06-20_094100.jpg 2017-06-20_100341.jpg
 
I wanted to be able to fire off the reset anytime the month changed. Because of the differing lengths of the months, I can't use a hard compare point. I'm taking clock.month and moving it to a holding register every three seconds. I then take the value in the holding register and compare it to clock.month. Whenever the month changes, for three seconds those two values will not be equal, which will satisfy the NEQ.
 
I would just leave the task scheduled normally, as daba said it's a very minor task. Instead of using the timer and a compare, I would just look at your CLOCK.DAY value every scan with an EQU statement, and when EQU to 1, fire a ONS to activate the MONTHLY_RESET.

That way you will get the reset at 12:00:01 AM the first day of every month without having to muck about with timers or shifting values into other tags to compare them.
 
I wanted to be able to fire off the reset anytime the month changed. Because of the differing lengths of the months, I can't use a hard compare point. I'm taking clock.month and moving it to a holding register every three seconds. I then take the value in the holding register and compare it to clock.month. Whenever the month changes, for three seconds those two values will not be equal, which will satisfy the NEQ.

All you need to do then, is choose a day of the month you want it to clear, and use Clock.Day = 1, 2, 3, etc. That along with some sort of one shot will clear it on that day. You can even set it to trigger at a certain time, as Daba suggested. Thats how i setup all of my production reporting as well.
 
All you need to do then, is choose a day of the month you want it to clear, and use Clock.Day = 1, 2, 3, etc. That along with some sort of one shot will clear it on that day. You can even set it to trigger at a certain time, as Daba suggested. Thats how i setup all of my production reporting as well.

If you take the second EQU off my first rung, and change the first EQU to EQU CLOCK.Day 1, then the one-shot bit will occur at exactly 00:00 hours on the first day of every month.

You can use the one-shot bit to call a subroutine to do your resets.

I don't know why you want to keep your "do it now" bit on for 3 seconds, it really isn't necessary.
 

Similar Topics

Hi all, I have a project where we'd like to use InTouch for the HMI for a water plant. The water plant needs to provide monthly reports to the...
Replies
7
Views
2,222
I was loading a program onto an XE1e2 PLC and it got stuck on these two windows and won't progress. It won't let me connect from the PC to reload...
Replies
0
Views
62
Hi all, i have recieved some 4RF Aprisa SR+ ethernet radios from a customer to configure. Issue is that they are used and have non-default...
Replies
0
Views
65
Hi Guys, I have a 1769-L24-QBFCB1 that has the OK light flashing on the embedded counter module. The manual states it is a resettable fault, but...
Replies
0
Views
98
We are using RED LION HMI Since las 15 years. To day we have found that My log file has data up to 22 Mar 2024 1:16. Then After new Log File is...
Replies
22
Views
1,180
Back
Top Bottom