Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

DSP "Not Equal To" not acting consistant? (plus help)

DSP related issues, mathematics, processing and techniques

DSP "Not Equal To" not acting consistant? (plus help)

Postby aronb » Sun Jul 29, 2018 11:14 pm

Hi,

I cannot get the DSP "Not Equal To" working.

I have 2 signals which start off unequal and become equal, and yet the output of the DSP "Not Equal To" operator (!=) is incorrect, as far as I can tell in one DSP Code module, but working in another :?

I have been looking at this way toooooo long :oops:

Here is the FSM, can someone please take a look?
Ramp_Help_01.fsm
"Not Equal To" issue?
(78.02 KiB) Downloaded 1166 times

Also, can someone help me solve my other needs, which again I cannot seem to figure out - mainly how to initialize the ramp value to 1, after the trigger occurs (only), that way the ramp can count down (NOTE: the ramp resting / final value must be 0, so I cannot change it at the end of the function), and since it is after a trigger, I cannot use stage(0) :(

Thank you,

Aron
User avatar
aronb
 
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA

Re: DSP "Not Equal To" not acting consistant? (plus help)

Postby Spogg » Mon Jul 30, 2018 10:43 am

Hi Aron

This needs a greater mind than mine to explain, but it appears to be the way the != operator deals with bools.

I’ve changed the test1 output evaluation to take this into account. You can now get the pulse at the start and the end from test1 output.

Also I changed your demo DSP box to illustrate the situation. If either bool is true it works but if both are true it doesn’t, and you still get an “incorrect” output of 1 in this situation.

Maybe Martin can explain the proper way to compare bools in DSP and why we get this counterintuitive behaviour. I'm sure he could help with the other points too.

Cheers

Spogg
Attachments
Ramp_Help_01-1 spogged 1 .fsm
(238.62 KiB) Downloaded 1123 times
User avatar
Spogg
 
Posts: 3318
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England

Re: DSP "Not Equal To" not acting consistant? (plus help)

Postby KG_is_back » Mon Jul 30, 2018 11:20 am

It's actually very simple. "=!" operator in DSP is specifically made to compare float in point NUMERIC values ie actual numbers. It behaves differently for nonnumeric values, which include +infinity, -infinity, various forms of NaN (Not a Number). Boolean true happens to be one of those values (boolean false happens to be identical to 0). If you want to compare boolean values using "=!" you should do something like this:

Code: Select all
result=(boolX & 1) != (boolY & 1);

This will ensure that you always compare numbers, instead of some weird non-numeric values that boolean variables can acquire.

Also another tip: Don't use streamboolean. Its behaviour is very incosistent - it is pretty much identical to stream except the connector restrictions (which you can override by holding ctrl). This is especially confuising when connecting green booleans to stream. green bool true value actually gets converted to float value 1 when connected to stream boolean, instead of the expected "true" value.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia


Return to DSP

Who is online

Users browsing this forum: No registered users and 21 guests