News:

  • October 03, 2025, 06:54:59 PM

Login with username, password and session length

Author Topic: Filtering and non real numbers  (Read 899 times)

Bolt

  • Hero Member
  • *****
  • Posts: 591
Filtering and non real numbers
« on: October 02, 2025, 02:43:30 PM »
I have a DmD (v2.11.1) project, and I have some IO-Link RTD modules sending data into my analog structures. With the sensors unhooked, they return #INF00 into the UDT's input field. Once connected, it shows the true value. However, If I filter the values, the filtered value continues to shows #QNAN0. If I manually write a 0 to the filtered value in a data view, it then starts to filter fine. Is there a clean way to write some logic to jump start the sequence? How would I reference #INF00 or #QNAN0 values in a comparison contact or math instruction?

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6126
  • Yes Pinky, Do-more will control the world!
Re: Filtering and non real numbers
« Reply #1 on: October 02, 2025, 04:52:43 PM »
That's a great question. I don't know that I have a great answer. We probably need to talk about that here and come up with a real solution...because I'm not sure there is one.

A hack would be to cast the float as a DWORD and look for the NAN and INF bit patterns. 0x80000000 is the sign bit. 0x7F800000 (8 bits) is the exponent. When all bits are high it is either NAN or INF. The difference between INF and NAN is in the lower 23 fraction bits...0=INF and !0=NAN.

So...if (R0:D & 0x7F800000) == 0x7F800000 you need to clear R0.
"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

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 702
  • Hmmm...
    • Host Engineering, Inc.
Re: Filtering and non real numbers
« Reply #2 on: Today at 10:21:41 AM »
You might could use the TESTNUM instruction? It tests a number and tells you whether or not it is NAN, INF, zero, subnormal, or normal. Then based on its result, you could zero out R0.
There are two types of people in the world; those that can extrapolate from incomplete data sets.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6126
  • Yes Pinky, Do-more will control the world!
Re: Filtering and non real numbers
« Reply #3 on: Today at 11:48:11 AM »
Man...I'm too old for this. Yes, TESTNUM. I completely forgot we added this.

Edit: Apparently in version 2.8.
« Last Edit: Today at 11:54:01 AM by BobO »
"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