Truncating a pot input

Software questions and issues with the FV-1

Moderator: frank

Post Reply
dkleinjans
Posts: 10
Joined: Thu Dec 03, 2015 11:55 am

Truncating a pot input

Post by dkleinjans » Wed Jan 25, 2017 12:10 pm

I got this code from one of the sample programs. I've tested it, and it works (of course), but I can't figure out why. Pot0 gets multiplied by 2, saved, then used to multiply the input, but the max multiplication is 1, not 2. Where/when does the 2 get truncated to 1? It's a nice trick. Thanks for any help.

equ kmix reg0

rdax pot0, 1.999 ;get pot0, clip the upper half of pot0's range
wrax kmix, 0 ;

rdax adcl, 1
mulx kmix
wrax dacl, 0

Digital Larry
Posts: 279
Joined: Mon Nov 12, 2012 12:12 pm
Contact:

Post by Digital Larry » Wed Jan 25, 2017 7:47 pm

The clipping occurs right here:

rdax pot0, 1.999 ;get pot0, clip the upper half of pot0's range

It is the "saturating math" feature that clips any result to 1.0 or maybe it's 0.9999-something but very close to 1.0.

dkleinjans
Posts: 10
Joined: Thu Dec 03, 2015 11:55 am

Post by dkleinjans » Thu Jan 26, 2017 6:19 am

Thanks, DL. I know that's the line in code that does it, but what is "saturating math"? Is there a register or an operation or something that's limited to 0.999...? The rdax instruction allows an S1.14 coefficient, but that is apparently being changed to S.?? at some point, and I'm wondering where that is. On page 23 of the manual, it says multipliers are S1.14 or S1.9, for a coefficient range from -2.0 to 1.9... Is it the next paragraph about the "saturation limiter" limiting the result to S.23? That sounds like it.

Seems like another concept to wrap my mind around.

Digital Larry
Posts: 279
Joined: Mon Nov 12, 2012 12:12 pm
Contact:

Post by Digital Larry » Thu Jan 26, 2017 7:56 am

Saturating math is like controlled hard clipping for audio. If you multiply or add, the result is limited to +/- 1.0 (or very close). The coefficients for multiplication need to allow for > 1.0 or else there would be no way to "turn it up to 11". The saturation can also be used when processing control signals as you have seen.

Take a 0.0 to 1.0 control signal. Multiply it by 2. Well, it WOULD go from 0.0 to 2.0, except saturating math clips it to 1.0 when the input is 0.5. Sometimes it takes several steps of SOF statements to get a control signal just the way you want it.

dkleinjans
Posts: 10
Joined: Thu Dec 03, 2015 11:55 am

Post by dkleinjans » Thu Jan 26, 2017 9:07 am

Got it. Thanks again. Now I have to play with it for a while to start understanding the implications.

slacker
Posts: 116
Joined: Tue Feb 01, 2011 12:13 pm

Post by slacker » Thu Jan 26, 2017 10:27 am

There's some useful examples of manipulating pot inputs, including nice graphs to help visualise whats going on in the knowledge base.
http://www.spinsemi.com/knowledge_base/ ... Pot_inputs scroll down a bit.

Post Reply