You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old August 13th, 2022, 12:09 AM   #16
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 7,005
Clear the next month's total (which is also the oldest month's total), and increment the current month's total, every scan.

GSV WallClockTime LocalDateTime YmdHMS MOV YmdHMS[1] NextMonthOffset SUB NextMonthOffset 1 ThisMonthOffset GRT NextMonthOffset 11 CLR NextMonthOffset
CLR MotorRunHoursByMonth[NextMonthOffset] ADD MotorRunHoursByMonth[ThisMonthOffset] DeltaHours Motor RunHoursByMonth[ThisMonthOffset]


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.
  Reply With Quote
Old August 13th, 2022, 05:11 AM   #17
janner_10
Lifetime Supporting Member
United Kingdom

janner_10 is offline
 
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!
  Reply With Quote
Old August 13th, 2022, 11:40 AM   #18
Ones_Zeros
Member
United States

Ones_Zeros is offline
 
Join Date: Feb 2014
Location: at work
Posts: 355
Question

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
Attached Files
File Type: zip Motor_Run_Hrs.zip (358.1 KB, 5 views)
  Reply With Quote
Old August 13th, 2022, 12:43 PM   #19
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 7,005
Quote:
Originally Posted by Ones_Zeros View Post
Now how would i add the reset to reset the monthly run hours each month?
Exactly as you showed in a previous post (See instruction (6) MOV 0 Month_Run_Hrs_Total below).


Quote:
Originally Posted by Ones_Zeros View Post
...when the systemtime[1] which is August gets moved to the tag "Month_Stored" won't this will always be equal? This is the part that i'm confused on.
I think you still do not understand the scan cycle. I annotated the code you posted earlier to try to clear this up; see below.

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:
  • Instruction executions are discrete events, executed in a time-ordered sequence left-to-right and top-to-bottom, within the execution of the rung they are on.
  • Rung executions are discrete events, executed top-to-bottom, within the execution of a single scan.
  • Scan cycle executions are discrete events, executed in a time-ordered sequence, one after the other in time, with breaks for I/O scans and other housekeeping.
The point here is that we need to "think" like the PLC, and play the instructions, rungs, and scan cycles in our heads, but to do that we need to understand the scan cycle.

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.
  Reply With Quote
Old August 13th, 2022, 01:15 PM   #20
janner_10
Lifetime Supporting Member
United Kingdom

janner_10 is offline
 
Join Date: Dec 2014
Location: Tewkesbury
Posts: 1,301
Quote:
Originally Posted by Ones_Zeros View Post
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
Again keep it simple.

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
  Reply With Quote
Old August 13th, 2022, 01:41 PM   #21
I_Automation
Lifetime Supporting Member
United States

I_Automation is offline
 
I_Automation's Avatar
 
Join Date: Jun 2020
Location: Detroit, Michigan USA
Posts: 1,385
Quote:
Originally Posted by Ones_Zeros View Post
.but when the systemtime[1] which is August gets moved to the tag "Month_Stored" won't this will always be equal. This is the part that i'm confused on.

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
  Reply With Quote
Old August 13th, 2022, 02:34 PM   #22
I_Automation
Lifetime Supporting Member
United States

I_Automation is offline
 
I_Automation's Avatar
 
Join Date: Jun 2020
Location: Detroit, Michigan USA
Posts: 1,385
Quote:
Originally Posted by Ones_Zeros View Post
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

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.
Attached Images
File Type: png Capture.PNG (46.3 KB, 43 views)
__________________
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.
  Reply With Quote
Old August 13th, 2022, 03:05 PM   #23
I_Automation
Lifetime Supporting Member
United States

I_Automation is offline
 
I_Automation's Avatar
 
Join Date: Jun 2020
Location: Detroit, Michigan USA
Posts: 1,385
Hope this shows clearer and it includes my last idea.
Attached Images
File Type: png Capture.PNG (30.9 KB, 44 views)
__________________
ivanovaautomation.com


Some Jobs Are Best Started With A Sawzall And A Dumpster On Castors
  Reply With Quote
Old August 13th, 2022, 03:22 PM   #24
Ones_Zeros
Member
United States

Ones_Zeros is offline
 
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
  Reply With Quote
Old August 13th, 2022, 09:48 PM   #25
Ones_Zeros
Member
United States

Ones_Zeros is offline
 
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.
  Reply With Quote
Old August 14th, 2022, 08:24 AM   #26
janner_10
Lifetime Supporting Member
United Kingdom

janner_10 is offline
 
Join Date: Dec 2014
Location: Tewkesbury
Posts: 1,301
It’s simple and effective. Doesn’t need to be anything else.
  Reply With Quote
Old August 14th, 2022, 08:41 AM   #27
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 7,005
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.
  Reply With Quote
Old August 14th, 2022, 03:05 PM   #28
I_Automation
Lifetime Supporting Member
United States

I_Automation is offline
 
I_Automation's Avatar
 
Join Date: Jun 2020
Location: Detroit, Michigan USA
Posts: 1,385
Quote:
Originally Posted by drbitboy View Post
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.

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.
Attached Images
File Type: png Capture.PNG (64.6 KB, 31 views)
__________________
ivanovaautomation.com


Some Jobs Are Best Started With A Sawzall And A Dumpster On Castors
  Reply With Quote
Old August 14th, 2022, 03:30 PM   #29
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 7,005
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.
  Reply With Quote
Old August 14th, 2022, 03:37 PM   #30
I_Automation
Lifetime Supporting Member
United States

I_Automation is offline
 
I_Automation's Avatar
 
Join Date: Jun 2020
Location: Detroit, Michigan USA
Posts: 1,385
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
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
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


All times are GMT -4. The time now is 05:54 PM.


.