
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.