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

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

masking stream errors

For general discussion related FlowStone

masking stream errors

Postby tester » Sat Feb 09, 2013 2:50 pm

How to mask stream error, so that the output sends a constant value instead of error code?
In blue.

//edit:

okay, found it:

Code: Select all
streamin in;
streamout out;

out = (in<=0)&0 + (in > 0)&in;


For positive code values is enough
Attachments
masking.fsm
(945 Bytes) Downloaded 1005 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: masking stream errors

Postby trogluddite » Sat Feb 09, 2013 3:20 pm

You can also exploit the fact that plus and minus infinity are discrete values in the float number system, which you can test for equality...
Code: Select all
stage(0)
{
infinity = 1/0;
}
x = x & (x != infinity)  //turns infinities into zero.


#NaN's can be tested for easily too, because a NaN never returns equal to anything, not even itself...

Code: Select all
x = x & (x==x);  //turns NaN's into zero
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: masking stream errors

Postby tester » Sat Feb 09, 2013 4:06 pm

Thanks, I'm still confused with these !&$#%@whatever markings and their actual meaning ;-)
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: masking stream errors

Postby trogluddite » Sat Feb 09, 2013 4:18 pm

There's only really three that you need to worry about...

#INF = positive infinity. It has a particular bit pattern and so can be tested with equals.
#-INF = negative infinity. Likewise.
#QNaN = means "Not a Number", you get this when there is no mathematically defined answer that is a real number - e.g. square root or logarithm of a negative number.

The infinities behave correctly in a mathematical sense where possible. (e.g. 1/infinity = 0; infinity * -1 = -infinity).
NaNs on the other hand will propagate - if you do maths on a NaN, you will get another NaN as the result - so they must be avoided at all costs inside feedback loops, because they will lock-up the algorithm.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: masking stream errors

Postby tester » Sat Feb 09, 2013 4:34 pm

I mean masks.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: masking stream errors

Postby trogluddite » Sat Feb 09, 2013 5:46 pm

tester wrote:I mean masks

It's really just a simple boolean function - only processed seperately for each bit of the value.

When you do a comparison, one of two values is returned...
FALSE = every bit is off - this is the same as positive zero (there is a negative zero too!)
TRUE = every bit is on - this is not equivalent to any number - it looks like a NaN if put into a mono readout.

If you look at a truth table for and...
0 and 0 = 0
0 and 1 = 0
1 and 0 = 0
1 and 1 = 1
You can see that...
1 and x = x
0 and x = 0

When you apply that to each bit at a time of a bigger value...
1 0 1 0 1 0 1 0 (a value)
&
0 0 0 0 0 0 0 0 (FALSE)
equals
0 0 0 0 0 0 0 0 (FALSE or ZERO)

1 0 1 0 1 0 1 0 (a value)
&
1 1 1 1 1 1 1 1 (TRUE)
equals
1 0 1 0 1 0 1 0 (the value)

It's done this way because of the way that poly and mono4 work - they are effectively "parallel processing" four values at once using the same instructions. This means that conditional jumps (if a=b then...) would always jump the same way for all four streams - which isn't what we want; we need each of the four to make decisions independently.
So conditional logic is done using bitmasks instead - because, like float values, they can be independent for each stream.
Although it's harder to program that way, it is still worthwhile because of the big CPU savings from the "parallel processing"., and explains why the DSP code instruction set seems rather limited in comparison to most other programming languages.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: masking stream errors

Postby tester » Sat Feb 09, 2013 6:14 pm

Now you made it very complicated :-)

Trog - consider two things when writing manuals and explaining things (to newbies, kids, but also to folks after 10 hours of SM/FS semi-automated work): one is the content, another is the way it's served and organized. The more you must navigate/think through elements (and the bigger they looks like), the less attention goes towards understanding. As you know, human attention can process only a few threads at one time, and dynamic memory (buffers) is also limited, plus - it's difficult to switch attention under higher mono128 load.

As an example of approaching topics. "If then else" routine, emphasized in modular way - is simple to understand, because it involves ordinary life processing; "if I have money, then I go shopping, else I go sleep"; each equation/feature has it's own "color" so to speak. Quantum qbit: "I'm probably here, but need to check it first...?". Digging bits kicks my eyes. :-)

p.s.: still don't know/understand what for is "!" for and what other things are in code to use?

p.s.: sorry if I sound somewhat cold, it's not intentional; my mono128 is under high load, and I'm simply unable to... speak. ;-)
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: masking stream errors

Postby trogluddite » Sat Feb 09, 2013 7:13 pm

tester wrote:Now you made it very complicated

I didn't MAKE it complicated - your question was in the form of an open question "I don't understand masks" - so I told you exactly how they work in as broad terms as possible (which IS complicated - and therefore takes a bit of explaining).
If what you mean is "show me some code that is equivalent to this", or "what exactly does this symbol mean?", then say so, and that is the answer you shall receive - but would you really learn very much from a single unexplained example?

To try and describe what is happening in terms of "if...then...else"...
Code: Select all
if (comparison) then x = a else x = b

..is equivalent to...
Code: Select all
x = (comparison) & a + (opposite of comparison) & b;

When the comparison is an "==", the opposite is "!=" meaning "is not equal to" - in general the symbol "!" means 'not' or 'swap true and false' in most programming languages.

Great, so now you have "if...then...else" understood - but without knowing how it works under the hood, you will never spot the many optimisations, special cases and traps for the unwary. In reality, it is not "if...then...else" that happens in DSP code, and experience tells me that it is unwise to think of it in those terms.

If I add too many asides (and things is brackets) then I apologise - but I include extra information because it is a public form, and it may be of interest to other readers.
You don't have to read it all if you don't want - you could always wait for another user to answer in a way that you find easier to understand!
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: masking stream errors

Postby tester » Sat Feb 09, 2013 10:09 pm

Thanks.

I'm not against your methods, on the contrary, I like your posts. I just pointed to some aspect related to the ways of teaching.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: masking stream errors

Postby trogluddite » Sat Feb 09, 2013 11:17 pm

That's cool, no forum guru is beyond a bit of constructive criticism. ;)

As you said yourself...
tester wrote:but also to folks after 10 hours of SM/FS semi-automated work)

For the teacher too - I have my own stuff I'm building for hours, and am exhausted enough after my day job - my posts this afternoon have been my little breaks from working all day to meet a work deadline, as I shall be tomorrow (no cool attachments this weekend!).
A tired teacher teaching a tired pupil doesn't make for a good learning environment, I guess. ;)

FWIW, I know I do go on a bit sometimes - I'm not trained in any way as a tutor, and my style is certainly a reflection of my own chaotic, rambling inner thought processes.
I very much admire your determination to get your project working just as you want - though I make plenty of modules, my own projects are much like my posts... lots of (ooh, there's another one) ideas, that (oh hang on ,I could make one of these) I very rarely (oh wow, I never saw that primitive before) finish because I (silly asteroids game, cool!) I just can't stop getting distracted.
But hey, I do it for the enjoyment, and I am enjoying it! :D

And you're quite right to say so if something hasn't been explained clearly enough, I wouldn't take offense at that - and I do often forget that I am fortunate that, on the forum, we use my native language. (well almost - the Yorkshire dialect would confuse the hell out of Google translate!!).
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Next

Return to General

Who is online

Users browsing this forum: Google [Bot] and 16 guests