
WatchThis1383 (Customer) asked a question.
ADD iBox
I have a daily counter (CTA35) and want to add my daily total to a month total.
I have it written: LD CTA35, ADD V1552, OUT CTA35. Pulses at oo:01 nightly.
Can't seem to make it work and pretty sure I'm making it harder than it is.
Appreciate the forum help.
I assume V1552 is your "month total" value, and CTA35 is your "daily count", so I believe you want to "OUT" the sum back to V1552 (OUT V1552, not OUT CTA35) to accumulate the day totals into the month total. You are sure that it is "Pulses at 00:01 nightly"? And then you save the month total, say for March, and then reset the month total back to zero for the April? (above assumes monthly total < 9999)
Be sure that your numbers do not exceed 9999
As implied, make sure you are looking at V1552 in Data View with format BCD/Hex because DL Timers/Counters utilize BCD (same with the ADD instruction).
If it can exceed 9999, you can use a double V (BCD double).
LDD V1552 (make sure V1553 is free, otherwise use 2 contiguous free V's)
ADD CTA35 (this 16 bit ADD works with the 32 bit value in the accumulator)
OUTD V1552
So if V1552/V1553 as a BCD DWORD is 9987, and you added daily count of 100 to it, you will end up with 10087 in V1552/V1553.
HOWEVER, this data change affects how you are then utilizing V1552 (Modbus? Calculations? Relational Contacts?) and complicates THOSE scenarios. Let us know if you have any questions about any of those.
Greetings and thank to all for the answers! I am out on a commissioning and will get back to the "challenge" later next week. Supposed to fly home Thursday the 16th.
I'll let all know planning for solutions by Saturday.😎
YES, works as I needed. Thanks to all for the help. I had the order all messed up.
And good to see Mr. Carlton on here too. (Yep, I'm old)
Again, thanks to all for the quick answers and getting me moving again!
John
The saga continues:
Worked as we suspected it should for 44 days. Now it may count or may not. I take the daily (V1002 or CTA2) add it to the monthly (V1030 or CTA30).
It works well i testing with single digits thru three digits. Just randomly becomes incorrect.
Yes, I know it shouldn't be this difficult and appreciate the forum's help
Answer this question. Do you expect results > 9999 in CTA 30? This is necessary when adding 3 digit numbers. Specifically, you don't have anything close to 9999 in CTA30, correct (nothing like 9765 and then adding 345)
BTW CTA30 is for Counter 30. Since you are "calculating" a value, do not use Counter Accumulator registers, just user User V (e.g. V2000). If you have logic that ever uses CNT CT30, you will break your code (because CTA30 is the output of CNT CT30, not your code).
Good questions and no I never ex[ect this to even get past 300 on a daily basis. Monthly (CTA30) maybe 2000. I am only moving the product of the addition to this accumulator. As noted in my attached logic (Time_Test) I am using the V registers with the same issues.
I appreciate the help on this.
Please provide actual numbers when it is incorrect. Are they wildly incorrect? What is the expected range of values in CTA2?
The values leading to the one shot don't correspond to your description of the condition given previously.
Please verify the usage or non usage of counters CT2 and CT20. If used please display their rungs.
Obviously the addition will only be valid at the firing of the one shot.
Thanks for quick replies!
And the numbers aren't ever over 150 per period being measured. Let me rewrite to a V2000 register and see if I ge the same issue.
As I mentioned it counted reliably for 44 days. Then it showed 0 for the previous days and in further logic the monthly total also moved to 0. I moved the pictured above the LD CTA2 OUT CTA20as I thought maybe it was a scan order issue.
Let me write it to do the CTA2 into v2000 and see if it a counter behind-the-scenes issue.