Truncating a pot input

Software questions and issues with the FV-1

Moderator: frank

Post Reply
dkleinjans
Posts: 13
Joined: Thu Dec 03, 2015 12:55 pm

Truncating a pot input

Post by dkleinjans »

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: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Post by Digital Larry »

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: 13
Joined: Thu Dec 03, 2015 12:55 pm

Post by dkleinjans »

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: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Post by Digital Larry »

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: 13
Joined: Thu Dec 03, 2015 12:55 pm

Post by dkleinjans »

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 1:13 pm

Post by slacker »

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