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
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
DSP "Not Equal To" not acting consistant? (plus help)
3 posts
• Page 1 of 1
DSP "Not Equal To" not acting consistant? (plus help)
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
Here is the FSM, can someone please take a look?
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
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
Here is the FSM, can someone please take a look?
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
-
aronb - Posts: 154
- Joined: Sun Apr 17, 2011 3:08 am
- Location: Florida, USA
Re: DSP "Not Equal To" not acting consistant? (plus help)
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
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 1276 times
-
Spogg - Posts: 3358
- Joined: Thu Nov 20, 2014 4:24 pm
- Location: Birmingham, England
Re: DSP "Not Equal To" not acting consistant? (plus help)
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:
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.
- 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
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 58 guests