electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Microcontrollers and Programmable Logic
Smooth parameter sweep with encoders?
Post new topic   Reply to topic Moderators: State Machine
Page 1 of 1 [5 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
rhdf



Joined: Jul 11, 2014
Posts: 39
Location: Sweden

PostPosted: Fri Mar 24, 2017 2:14 pm    Post subject: Smooth parameter sweep with encoders? Reply with quote  Mark this post and the followings unread

With a N pulses/Rev encoder you obviously get stepped parameter increments/decrements. What is the smartest way to get a encoder to act somewhat like a potentiometer?

Most of the parameters in my project I can live with some steps, like oscillators semitone and maybe detune. But for filter cutoff etc I would like to have some kind of more potentimeter-like response.
Back to top
View user's profile Send private message
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 22503
Location: The Netherlands, Enschede
Audio files: 219
G2 patch files: 319

PostPosted: Fri Mar 24, 2017 3:12 pm    Post subject: Reply with quote  Mark this post and the followings unread

Easiest way would be to just slew the signal with an exponential averaging filter (for float values: NewValue = NewValue * n + OldValue * (1 - n) with 0<=n <1> no filtering, 0 -> frozen, no change).

Another possible thing to do, but more complex, is to measure the time between changes (and calculate the speed of change from that) and use this to do a linear interpolation between values - with this the changes will come trough a bit late, or some additional filtering will be needed (as to do real time changes would need a turning speed guess for the current step (from the previous one) which would never 100% correct). I've succeeded in making this working as well (for interpolation between sequencer steps) - but as said -more complex, and probably not worth the trouble here.

Then a 3rd way could be to use the first method and change n depending on the current rotation speed. I've never tried this one though, it just bubbled up as a possible way to do it.

For integer math it is also possible to use the formula for method 1, but it needs to be scaled up a bit..with 0 <=n<= SomeValue and then divide the result by SomeValue afterwards (your intermediates may need a typecast to long int then depending on the value of SomeValue and the range of possible values). NewValue = ( NewValue * n + OldValue * (SomeValue - n)) / SomeValue :: with 0 <= n <= SomeValue

_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1611
Location: West Red Spot, Jupiter
Audio files: 191

PostPosted: Fri Mar 24, 2017 4:23 pm    Post subject: Reply with quote  Mark this post and the followings unread

While a filter or interpolation can remove the step-ness by sort of filling in the values between what would otherwise be steps, the output of such methods will still ultimately be quantized. That is, with a filter or interpolation, given an input that goes from 43 to 44, can go 43, 43.1, 43.2, etc. until it reaches 44, but the value cannot be made to stay at 43.5 for example - it is quantized. To mitigate that, you will need to increase the resolution of the counter driven by the encoder. If you currently use 256 steps (with an 8 bit counter), you could increase the counter to say, 1024 steps. Then each step can represent 1/4 of the voltage difference that it previously represented. With enough resolution, you don't even notice that the steps are there and no filter or interpolation would be necessary. Of course, doing such a thing means that you now have to turn the knob 4 times as many turns to get the same result. I've had this problem myself (for an FPGA project). The encoder I had on the board had a knob that both turned the encoder and could be pushed. I used the button to tell the board whether I wanted coarse or fine control. Pushed in, each click of the encoder bumped the counter by 16 and unpushed, it bumped by one. So if I wanted to move the value quickly, I would push and turn until it was close to what I needed and then released the button and used fine control to get the precise value I wanted. Of course, it isn't required that the encoder have a such a pushbutton knob, alternatively, you could use another switch to select coarse/fine action.
_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 22503
Location: The Netherlands, Enschede
Audio files: 219
G2 patch files: 319

PostPosted: Fri Mar 24, 2017 5:39 pm    Post subject: Reply with quote  Mark this post and the followings unread

Ah yes Scott, true that . .and then you could use the accelerated mouse trick .. when moved fast it could go faster through the steps .. so no need then for a fine coarse selector.
_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
JovianPyx



Joined: Nov 20, 2007
Posts: 1611
Location: West Red Spot, Jupiter
Audio files: 191

PostPosted: Fri Mar 24, 2017 6:59 pm    Post subject: Reply with quote  Mark this post and the followings unread

ah, yes, so you'd just twist a bit faster to go into coarse.
_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: State Machine
Page 1 of 1 [5 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Microcontrollers and Programmable Logic
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
You cannot attach files in this forum
You can download files in this forum
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use