Spin Semiconductor Forum Index Spin Semiconductor
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Truncating a pot input

 
Post new topic   Reply to topic    Spin Semiconductor Forum Index -> FV-1 software questions
View previous topic :: View next topic  
Author Message
dkleinjans



Joined: 03 Dec 2015
Posts: 10

PostPosted: Wed Jan 25, 2017 12:10 pm    Post subject: Truncating a pot input Reply with quote

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
Back to top
View user's profile Send private message
Digital Larry



Joined: 12 Nov 2012
Posts: 260

PostPosted: Wed Jan 25, 2017 7:47 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
dkleinjans



Joined: 03 Dec 2015
Posts: 10

PostPosted: Thu Jan 26, 2017 6:19 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Digital Larry



Joined: 12 Nov 2012
Posts: 260

PostPosted: Thu Jan 26, 2017 7:56 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
dkleinjans



Joined: 03 Dec 2015
Posts: 10

PostPosted: Thu Jan 26, 2017 9:07 am    Post subject: Reply with quote

Got it. Thanks again. Now I have to play with it for a while to start understanding the implications.
Back to top
View user's profile Send private message
slacker



Joined: 01 Feb 2011
Posts: 114

PostPosted: Thu Jan 26, 2017 10:27 am    Post subject: Reply with quote

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/pgm_quick.html#Pot_inputs scroll down a bit.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Spin Semiconductor Forum Index -> FV-1 software questions All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group