Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: ElroyJetson on October 27, 2017, 09:18:21 AM

Title: Monitoring the status of a series of bits
Post by: ElroyJetson 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.... ???
Title: Re: Monitoring the status of a series of bits
Post by: MikeS 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.
Title: Re: Monitoring the status of a series of bits
Post by: ElroyJetson 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.
Title: Re: Monitoring the status of a series of bits
Post by: Mike Nash 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.
Title: Re: Monitoring the status of a series of bits
Post by: Mike Nash on October 27, 2017, 11:22:52 AM
Better,

MATH C60 CountIfEQ(1, C10, 46)
Title: Re: Monitoring the status of a series of bits
Post by: ElroyJetson 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