![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]() |
![]() |
#16 |
Lifetime Supporting Member
|
Clear the next month's total (which is also the oldest month's total), and increment the current month's total, every scan.
Either this routine will be executed only when DeltaHours is greater than 0, or DeltaHours will be 0 on most scans. January's total is in MotorRunHoursByMonth[0], February's in [2], ..., Decembers's in [11]. The previous ten months' totals are maintained; this month's total is in MotorRunHoursByMonth[ThisMonthOffset].
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. Last edited by drbitboy; August 13th, 2022 at 12:32 AM. |
![]() |
![]() |
#17 |
Lifetime Supporting Member
![]() ![]() Join Date: Dec 2014
Location: Tewkesbury
Posts: 1,301
|
Keep it simple.
1X RTO for your hour pulse. Which when .DN. increments a CTU then Resets. 1x CTU for each month in an Array of 13 (So you don't need to use[0]) Your PLC Month is your Counter Array Pointer. ie. C_Monthly_Hour_Count[PLC_Month] Reset the CTU at the start of a new month. No need to make it complicated. Last edited by janner_10; August 13th, 2022 at 05:13 AM. Reason: spelling! |
![]() |
![]() |
#18 |
Member
![]() ![]() Join Date: Feb 2014
Location: at work
Posts: 355
|
![]()
Hello I_Automation
I attached the sample PLC program and I have the run hours being stored to each of the month array tags. Now how would i add the reset to reset the monthly run hours each month? thanks for all your help |
![]() |
![]() |
#19 | ||
Lifetime Supporting Member
|
Quote:
Quote:
There will be only and exactly one scan in any month when SystemTime[1] will Not EQual Month_Stored at the start of this rung, and that will be the first scan executed in that month. Also note that, although they may be unequal at the start of this rung, at the exit of this rung, SystemTime[1] will always be equal to Month_Stored, whether they were equal at the start of the rung or not. Remember, it's about time:
The only reason for the program to do anything different from one scan cycle to the next is if external inputs change (e.g. SystemTime[1]), and/or its internal state changes (e.g. Month_Stored). The rung in view here ensures that, at the end of the rung execution, Month_Stored has the same value as the SytemTime[1] value current as the the current scan. So the only way for them to be unequal at the start of the rung's execution on the next scan, is if SystemTime[1] changes between the current scan and that next scan; and it should be obvious that will happen when the current scan executes in one month, and the next scan executes in the following month. Run Hrs Stored.png
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. |
||
![]() |
![]() |
#20 | |
Lifetime Supporting Member
![]() ![]() Join Date: Dec 2014
Location: Tewkesbury
Posts: 1,301
|
Quote:
If Current_Month NEQ Old_Month > (RES) Then MOV Current_Month To OLD_ Month. There is no need for reams and reams of lengthy code for something very simple. Last edited by janner_10; August 13th, 2022 at 01:29 PM. Reason: Clarification |
|
![]() |
![]() |
#21 | |
Lifetime Supporting Member
|
Quote:
What you're not realizing is the instruction NEQ checks that the 2 values are NOT the same. They will be equal every scan of a month EXCEPT the first scan, and that is the only single scan of the month where this rung will execute. To check if 2 value ARE the same use EQU.
__________________
ivanovaautomation.com Some Jobs Are Best Started With A Sawzall And A Dumpster On Castors |
|
![]() |
![]() |
#22 | |
Lifetime Supporting Member
|
Quote:
Finally got on a computer to see your file. The way you have it you will be writing the log every scan of the year, and never reset the main log DINT. Here it is using the NEQ so it only runs once per month, each month on a branch, then the last branch resetting the hours and recording the new month thus ensuring this rung will not run until next month. EDIT: Sorry for the burriness - had to reduce the image size of the screenshot on a 4K monitor so it's not huge on this forum. Any chance Phil can set a MAX Display Size for photo's that are too big? EDIT2: I just thought to save a tag and keep everything together, since you're not using Array[0] you could use that instead of creating Month_Stored. That way looking at the array values [0] would be the last stored month and [1] thru [12] the monthly values.
__________________
ivanovaautomation.com Some Jobs Are Best Started With A Sawzall And A Dumpster On Castors Last edited by I_Automation; August 13th, 2022 at 02:43 PM. |
|
![]() |
![]() |
#23 |
Lifetime Supporting Member
|
Hope this shows clearer and it includes my last idea.
__________________
ivanovaautomation.com Some Jobs Are Best Started With A Sawzall And A Dumpster On Castors |
![]() |
![]() |
#24 |
Member
![]() ![]() Join Date: Feb 2014
Location: at work
Posts: 355
|
Thanks Everyone for the detailed explanations, your time, and patience!
Its very much appreciated I was able to get this working on my emulator. thanks again |
![]() |
![]() |
#25 |
Member
![]() ![]() Join Date: Feb 2014
Location: at work
Posts: 355
|
Thanks so much @I_Automation for the screenshots. I do appreciate your help and patience here with me on this.
|
![]() |
![]() |
#26 |
Lifetime Supporting Member
![]() ![]() Join Date: Dec 2014
Location: Tewkesbury
Posts: 1,301
|
It’s simple and effective. Doesn’t need to be anything else.
|
![]() |
![]() |
#27 |
Lifetime Supporting Member
|
Is 27 instructions considered simple, when half a dozen would do exactly the same thing?
I am not trying to be a know-it-all, I am actually just asking.
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. Last edited by drbitboy; August 14th, 2022 at 08:46 AM. |
![]() |
![]() |
#28 | |
Lifetime Supporting Member
|
Quote:
I just added to his upload. Personally I would do math on the present month and have one branch MOV Hrs Array[Month_Calculated] instead of 12 branches followed by the reset. That could cut 13 branches down to 4.
__________________
ivanovaautomation.com Some Jobs Are Best Started With A Sawzall And A Dumpster On Castors |
|
![]() |
![]() |
#29 |
Lifetime Supporting Member
|
Nice! Seven instructions, same as mine but probably easier to follow.
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (but no longer ∞ ![]() vi) Hakuna matata. vii) Bookkeeping. |
![]() |
![]() |
#30 |
Lifetime Supporting Member
|
I was working on 3 branches, moving the 2 MOV's on the last branch, but Studio5000 threw a Windows C++ error and crashed at that time.
The MOV SystemTime[1] Month_Array[0] could go on the first branch and the MOV 0 up one branch after the actual logging on the third branch.
__________________
ivanovaautomation.com Some Jobs Are Best Started With A Sawzall And A Dumpster On Castors |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Reset PLC | orchey | LIVE PLC Questions And Answers | 5 | August 4th, 2014 05:01 AM |
Mitsubishi FX3UC PLC and A/B phase counter | vidarlo | LIVE PLC Questions And Answers | 0 | November 29th, 2010 02:47 AM |
Mitsubishi reset PLC A-Series | mkac | LIVE PLC Questions And Answers | 3 | September 16th, 2010 10:04 AM |
GPS Clock Synch - Redlion G3 / A-B SLC PLC | Marc_U | LIVE PLC Questions And Answers | 9 | September 10th, 2010 05:39 AM |
measuring RPM - Siemens S7200 | mjamil | LIVE PLC Questions And Answers | 28 | July 11th, 2005 11:03 AM |