News:

  • November 24, 2026, 03:47:20 AM

Login with username, password and session length

Author Topic: Increment Instruction (Do-more) and UDC (DL6)  (Read 108 times)

Saturn_Europa1

  • Jr. Member
  • **
  • Posts: 19
Increment Instruction (Do-more) and UDC (DL6)
« on: November 23, 2026, 08:34:48 AM »
I am setting up hour meter counters on some Do-more PLCs using the Increment and the UDC on Direct Soft PLCs.  I was wondering if these counters hit the upper limit of their range will the PLC go into a major fault or if it will just show an Overflow or roll back to 0?



franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3858
    • Host Engineering
Re: Increment Instruction (Do-more) and UDC (DL6)
« Reply #1 on: November 23, 2026, 09:03:29 AM »
Do-more, INC instruction on signed 2's complement D will go from 2,147,483,647 hours (over 245,000 years) to -2,147,483,648 (0x7FFFFFFF to 0x80000000).

Not sure about behavior of UDC in DirectLOGIC, which utilizes a 32 bit BCD counter.  So it can go up to 99,999,999 hours BCD, so after 11,000 years.

Remember to use Retentive Memory and to replace the battery at the recommended intervals.
:-D


Saturn_Europa1

  • Jr. Member
  • **
  • Posts: 19
Re: Increment Instruction (Do-more) and UDC (DL6)
« Reply #2 on: November 23, 2026, 09:06:56 AM »
Thanks!   I faulted out a Compact Logix a few years ago by entering a number larger than the instruction could take.  It shut down production for hours.
Then an operator accidently put in a negative number on a different Compact Logix and it faulted that PLC.  Just wanted to double check!

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3858
    • Host Engineering
Re: Increment Instruction (Do-more) and UDC (DL6)
« Reply #3 on: November 23, 2026, 10:35:40 AM »
For Do-more PLCs Fatal errors/faults are truly that.  If you divide by 0, or increment beyond the range of an integer, it shows grace.  It may roll over (or 2's complement version of rolling over), but the firmware won't flag that as fatal.  It will issue warnings, and sometimes you can ignore them, sometimes you shouldn't.  That's all up to you.

I just checked Do-more INC.  It clamps at 2147483647.  But if you are using a smaller sized integer other than 32 bit signed int, it WILL do the "roll over" thing.  Unsigned 16 bit V rolls over from 65535 to 0 (no status bits come on).  Signed 16 bit N does the 2's complement roll over from 32767 to -32768 (no status bits come on).

I also checked that INC does set the ST133 ($Overflow) bit when attempting to increment 2147483647.  However, it does NOT set ST133 when doing INC on V or N (the overflow flag is set based on the width of the internal architected 32 bit math stack, not the data type of the parameter in the INC instruction).