News:

  • August 21, 2026, 01:50:31 AM

Login with username, password and session length

Author Topic: Monitoring the status of a series of bits  (Read 7771 times)

ElroyJetson

  • Full Member
  • ***
  • Posts: 36
Monitoring the status of a series of bits
« on: October 27, 2017, 09:18:21 AM »
How can I monitor the status of a series of C bits (C10-C55)? I want to set another bit if any of the C bits goes true. I would rather not have a rung with 45 "or" contacts. I know there has to be a simpler way, but I cant seem to find it.... ???

MikeS

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 268
    • Host Engineering, Inc.
Re: Monitoring the status of a series of bits
« Reply #1 on: October 27, 2017, 10:31:22 AM »
if you can move the C bits to a Word boundary ( in your case, C10-C55 to C16-C61 ) you could use three SUMBITS instructions
SUMBITS C16:w -> D0
SUMBITS C32:w -> D1
SUUMBITS C48:w -> D2

the use NotEqualtTo contacts to check the three values in D0, D1, D2, if any are not 0 then a bit is ON.
Good design costs a lot. Bad design costs even more.

ElroyJetson

  • Full Member
  • ***
  • Posts: 36
Re: Monitoring the status of a series of bits
« Reply #2 on: October 27, 2017, 11:13:09 AM »
So I just created a rung in the $TopOfScan system task with the MAPIO command that mapped C10-C55 to C100.

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: Monitoring the status of a series of bits
« Reply #3 on: October 27, 2017, 11:15:22 AM »
MATH C60 (C8:UW & 0xFFFC) || (C24:UW & 0xFFFF) || (C40:UW & 0xFFFF)

This will turn on C60 if any bit(s) C10-C55 is/are on.
But it sure isn't simpler if you are troubleshooting.
I'm sure there are other options, but I haven't looked yet.

I see you found one.

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: Monitoring the status of a series of bits
« Reply #4 on: October 27, 2017, 11:22:52 AM »
Better,

MATH C60 CountIfEQ(1, C10, 46)

ElroyJetson

  • Full Member
  • ***
  • Posts: 36
Re: Monitoring the status of a series of bits
« Reply #5 on: October 27, 2017, 11:38:29 AM »
Mike,

 Actually the MAPIO didn't work as expected... :-\
But I like what you did there. I was trying to use the math box, but I was stumped...

Thanks..... ;D