News:

  • September 27, 2026, 09:35:29 AM

Login with username, password and session length

Author Topic: Divide by zero errors.  (Read 8204 times)

PLCwannabe

  • Hero Member
  • *****
  • Posts: 208
Divide by zero errors.
« on: March 12, 2021, 02:43:20 PM »
Is there a way to make BRX ignore divide by zero errors?

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 702
  • Hmmm...
    • Host Engineering, Inc.
Re: Divide by zero errors.
« Reply #1 on: March 12, 2021, 03:24:08 PM »
When a divide-by-zero happens, ST141 ($DivideByZero) bit gets set. So, in the rung immediately following a calculation you could put:

STR ST141
RST ST141

But, then you'd never know. So, you could count the ST141s before you reset it.
There are two types of people in the world; those that can extrapolate from incomplete data sets.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Divide by zero errors.
« Reply #2 on: March 12, 2021, 03:29:48 PM »
Kinda. $InhibitErrors (DST39).

Set the appropriate bit of the error you want to ignore. It doesn't really eliminate the error, but it does mask the error/warning flag.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

PLCwannabe

  • Hero Member
  • *****
  • Posts: 208
Re: Divide by zero errors.
« Reply #3 on: March 12, 2021, 03:40:14 PM »
Great. So just reset st141 with an always on. I should have thought of that.

PLCwannabe

  • Hero Member
  • *****
  • Posts: 208
Re: Divide by zero errors.
« Reply #4 on: March 13, 2021, 08:48:06 AM »
I can't find a help file on $InhibitErrors (DST39). Where in the help section is the list of the associated bits?

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 702
  • Hmmm...
    • Host Engineering, Inc.
Re: Divide by zero errors.
« Reply #5 on: March 13, 2021, 08:55:34 AM »
@PLCwannabe, I looked for that as well. I don't think we've put that in the Help file.

@BobO, do you have the bit IDs for DST39?
There are two types of people in the world; those that can extrapolate from incomplete data sets.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Divide by zero errors.
« Reply #6 on: March 13, 2021, 10:19:43 AM »
$Info, $Warnings, $Errors, and $InhibitErrors are all 32 bit masks of the 32 ST bits that start at ST128. Easiest thing to do is put all of those in a data view, display DSTs in hex, and see which bits turn on for your issue. I think divide by zero is 13, so you should see 0x00002000 (hex) or 8192 (dec) in $Warnings. So setting $InhibitErrors:13 will block it.

I never made it publicly visible, but there are also masks that determine the level of an ST bit, whether it is info, warning, or error. I had planned to make it configurable. Some folks may consider divide by zero perfectly ok, while others view it as show stopping. The plan was to let them adjust it. Sometimes plans are victims of time realities. :o
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO