Progressive resolution for a rotary encoder - Page 1
Forum section: electronics / projects

author: ataradov
author_rank: Super Contributor
timestamp: April 13, 2017, 12:09:11 am
content: I have a project in mind, where I would need to adjust output frequency in the range 1 Hz - 100 MHz. The input will be done using a standard rotary encoder.Is there a "standard" algorithm for progressive change of step resolution with knob velocity/acceleration? I'm trying to figure out if there are standard rule of thumb parameters for an algorithm like this? Something that feels good and natural to an average human being, but not to twitchy or takes thousands of turns to sweep the full range.

author: BrianHG
author_rank: Super Contributor
timestamp: April 13, 2017, 01:07:22 am
content: There are a few pointers here posted in a similar thread:https://www.eevblog.com/forum/microcontrollers/rotary-encoder-speed-control-is-encoder-turning-fast-update-the-counter-10/You can use my example in the middle of the thread & multiply the acceleration factor to what you like.There is also someone else's library posted at the end of the thread.

author: BravoV
author_rank: Super Contributor
timestamp: April 13, 2017, 01:21:59 am
content: Subbed, Alex, please share the progress and how this ended up will you ?

author: BravoV
author_rank: Super Contributor
timestamp: April 13, 2017, 01:39:16 am
content: I do have some thought, although its still just an idea, as I got this idea from TTi psu, for the voltage adjustment its linear, while for current, it uses logarithm pot which is quite useful when cranking up the value.So my thought is to use just a single encoder but has two modes, linear and logarithm, and both modes can be toggled using the encoder push button, maybe an indicator like a led to indicate which mode is currently activated.In linear, its obvious to give finer resolution, user still can turn it slow or fast with constant linearly change that feels natural. But when user want to change much wider range with much less angular turn at the knob, here the logarithm mode comes in, also with added velocity in the log mode, this really improves the speed for user to reach the nearby wanted value, and then switch to linear mode back to fine tune it.Of course, velocity also can be used in linear mode, with faster angular turn, the higher multiplier is used to increment the counter.Just an idea, take it with a grain of salt.

author: BrianHG
author_rank: Super Contributor
timestamp: April 13, 2017, 02:07:01 am
content: Ok, do you have your example code for the linear acceleration.With my original code, I scan the encode inputs by a fixed time interval, say 200 samples a second, which allows the generation of a timer 'time_between_each_pulse', whose count is limited to 'Max_time' (I use 100), of the encoder.Basically, every scan of the encoder input, I increment 'time_between_each_pulse' if it is less than 'Max_time'If the encoder moved since the last scan, I clear 'time_between_each_pulse'.This factor generates the acceleration factor 'Speed_factor' which sets the step size.Speed_factor = Max_time + 1 - (time_between_each_pulse);Next, depending on the direction of the encoder, ADD, or SUBTRACT 'Speed_factor' to your user set counter.Now, if you want an exponential acceleration instead, all you would have to do is ADD, or SUBTRACT:(Speed_factor * your_choice) ^2. orSpeed_factor^2 * your_choice or((Speed_factor-1) * your_choice) ^2 + 1 ... This one allows for an increment and decrement of exactly 1 at the slowest speed(Note that the 'your_choice' might be something like 0.5 since 100^2, at 10000 steps per count, may be too big, or, you can change that to 10 making the max speed 1000000 per step...)You can also change 'Max_time' to something like 10. This will give you a very slow linear acceleration, you can call this your 'Log' mode, and use the exponential mode for that wide speed swing.I hope this helps...

author: sleemanj
author_rank: Super Contributor
timestamp: April 13, 2017, 05:47:12 am
content: Don't forget about the physical aspect - a big knob is better than a small knob. For a large range you want to be able to "jog dial", if you have to grab the knob between your fingers to manipulate it, it's too slow to get it up to where you want it. 30mm is barely adequate, 40mm much better.

author: ataradov
author_rank: Super Contributor
timestamp: April 13, 2017, 05:50:42 am
content: Quote from: sleemanj on April 13, 2017, 05:47:12 amWell, the knob will be a typical plastic stuff from eBay. I'm not to happy with detented rotary encoders I have on hand, so I'll order some of different types to see what feels best.Thanks, everyone, I got some ideas, and I will be trying this stuff out over the weekend.

author: BravoV
author_rank: Super Contributor
timestamp: April 13, 2017, 06:01:24 am
content: Quote from: sleemanj on April 13, 2017, 05:47:12 am+1 , I love knob like this when it comes to rotary encoder that has the finger hole, as swirling single finger at that hole is really effective at high speed turn.

author: David Hess
author_rank: Super Contributor
timestamp: April 13, 2017, 12:17:53 pm
content: Another system I have seen uses the encoder to simulate coarse and fine controls. There is a fine "window" of so many degrees which gets dragged by coarse operation. So the encoder is coarse while turning in one direction and when reversed, there is a limited fine window and once past that it becomes coarse going in the opposite direction. No velocity calculations need to be made for this to work.It may seem to be worse than true acceleration however it is a lot easier to get right.

author: PointyOintment
author_rank: Frequent Contributor
timestamp: April 14, 2017, 04:53:42 am
content: Quote from: David Hess on April 13, 2017, 12:17:53 pmThat sounds equivalent to mounting a low-value, low-friction pot onto the shaft of a high-value, high-friction pot, and putting the knob on the shaft of the low-value pot. I usually don't like hysteresis/backlash in UIs, but that particular example of it might actually be okay.

author: ataradov
author_rank: Super Contributor
timestamp: April 14, 2017, 05:01:03 am
content: Well, I tried some of the things proposed here, and some other stuff I managed to google.And I came to a firm conclusion that encoder is just not the right solution here. This is why professional equipment makes you select the digit (order of magnitude) you want to change.I will simply use 2 buttons, it sounds more manageable.

author: David Hess
author_rank: Super Contributor
timestamp: April 14, 2017, 10:19:15 am
content: Quote from: PointyOintment on April 14, 2017, 04:53:42 amThat is a really good description.One place where this method is needed is with absolute single turn encoders. Otherwise turning the encoder fast one way and then slow the other would result in wandering out of range.Tektronix used this method on the 4 channel 22xx and 24xx series analog oscilloscopes.

author: mrflibble
author_rank: Super Contributor
timestamp: April 14, 2017, 12:26:43 pm
content: Quote from: sleemanj on April 13, 2017, 05:47:12 amAgreed. Those dials are much more pleasant to work with than those fiddly small diameter knobs. Just for reference I measured the jog dial on my HP scope ... 37 mm diameter. Incidentally, does anyone know a cheap source for say 10 dials of around 40 mm diameter? The prices on ebay I could find were a bit silly...As for the OP: also looking for a suitable library. Ideally one that used time stamps as opposed to fixed interval sampling. For the dial jog readout the accuracy is probably not that demanding, so the fixed time interval sampling that most code out there uses is probably okay. But for motion estimation throwing away all that precious information by using fixed interval sampling is a bit ...

author: rstofer
author_rank: Super Contributor
timestamp: April 14, 2017, 03:39:37 pm
content: Quote from: ataradov on April 14, 2017, 05:01:03 amI figured it would work out like this because the range is so high. You want to change by as much as 10s of MHz per click down to 1s of Hz per click. Selecting the digit doesn't have to be ugly if you use the push button on the encoder. I'm not sure how you display which decade you are changing but it should be manageable on the display. Maybe you begin a sequence by pressing the button and it starts the MSD blinking. Successive presses move the digit to the right. After some delta T, the blinking goes away because it would be distracting.Maybe when no prior adjustment has been made lately, the encoder itself moves the digit back and forth. The pushbutton locks it in and successive encoder operations increment or decrement the count from that digit.Something like that...

author: ebastler
author_rank: Super Contributor
timestamp: April 15, 2017, 07:15:45 am
content: Quote from: ataradov on April 14, 2017, 05:01:03 amA row of thumbwheel BCD switches, one for each digit, would be my personal favorite for fast entry and adjustment. But a bit outdated these days... Assuming that your device has a display for the selected frequency anyway, couldn't you use a small touchscreen which simulates a row of thumbwheels?http://www.surplussales.com/Images/Switches/Thumbwheel/swb-8872-501-6_1_lg.jpg

author: ataradov
author_rank: Super Contributor
timestamp: April 15, 2017, 07:20:22 am
content: Quote from: ebastler on April 15, 2017, 07:15:45 amNope. It was not going to have any indication except for one way UART.Now it was "upgraded" to 0.91" OLED display. No chance for touch screen.

author: ebastler
author_rank: Super Contributor
timestamp: April 15, 2017, 07:40:46 am
content: Quote from: ataradov on April 15, 2017, 07:20:22 amSounds like a cute display!Never mind; the touchscreen thumbwheel probably would have meant too much development effort anyway. Hard to justify, unless frequency entry is the main thing the user keeps doing...Maybe a little joystick? Push left/right to select digit, up/down to change value?

author: ratio
author_rank: Regular Contributor
timestamp: April 15, 2017, 07:12:11 pm
content: I've used in the past a knob, spring return to center, the further you turned it from the center the faster it moved. IOW, you're changing the rate-of-change with the knob. As long as the span is wide enough, you could have it stepping by Hz/sec to GHz/sec, up or down.

author: PA0PBZ
author_rank: Super Contributor
timestamp: April 15, 2017, 07:30:56 pm
content: Thinking about the select digit thing I'm wondering if you could select more than one digit. I don't think I've ever seen it but how about selecting the 3 MHz, KHz or Hz digits?

author: ataradov
author_rank: Super Contributor
timestamp: April 15, 2017, 08:19:40 pm
content: Quote from: PA0PBZ on April 15, 2017, 07:30:56 pmSiglent signal generators let you do basically this. You select the lowest digit and then all other digits change in increments of the selected position.It works, but I would not say it is the best solution.

author: timb
author_rank: Super Contributor
timestamp: April 15, 2017, 09:12:56 pm
content: Quote from: BravoV on April 13, 2017, 06:01:24 amI wish I could find a reasonably priced source of these. The only ones I can find on Digi-Key are apparently made out of an alloy of 24k gold, platinum and titanium (with a tellurium plating for low noise). At least I assume they are based on the price! (Were talking $20-$50 each!)There has to be an inexpensive source for them. They don't need to be machined aluminum (which the ones on Digi-Key actually are), plastic would be fine... I just don't get it.

author: Nusa
author_rank: Super Contributor
timestamp: April 15, 2017, 09:31:40 pm
content: Quote from: timb on April 15, 2017, 09:12:56 pmhttps://www.aliexpress.com/item/32-13mm-Audio-Multimedia-Speakers-Aluminum-Knob-Knob-Guitar-Knob/32744452805.htmlhttps://www.aliexpress.com/item/High-Quality-Knob-Audio-Volume-Control-Knob-Potentiometer-Knob-40x17mm-Round-6MM-Silver/32748541803.htmlThere's probably more. I only spent a minute looking.

author: prasimix
author_rank: Unknown
timestamp: April 15, 2017, 09:32:07 pm
content: Maybe you can try TME (they are shipping worldwide)CLIFF CL71660Athat looks similar to that on the picture. I still have one and can say that is pretty good.

author: timb
author_rank: Super Contributor
timestamp: April 15, 2017, 09:33:44 pm
content: Quote from: Nusa on April 15, 2017, 09:31:40 pmThose are still really expensive. $4 and $7! Where are the sub-$1 plastic ones?

author: timb
author_rank: Super Contributor
timestamp: April 15, 2017, 09:34:47 pm
content: Quote from: prasimix on April 15, 2017, 09:32:07 pmHey, that's something. Thanks!

author: ataradov
author_rank: Super Contributor
timestamp: April 15, 2017, 09:36:53 pm
content: Quote from: timb on April 15, 2017, 09:34:47 pmAgreed! I'll order a few just to have them on hand.

author: Nusa
author_rank: Super Contributor
timestamp: April 15, 2017, 09:40:52 pm
content: Quote from: timb on April 15, 2017, 09:33:44 pmhttps://www.aliexpress.com/item/VK-Potentiometer-encoder-band-switch-plastic-knob-cap-32-5-13MM-flower-shaft-hole/32773845457.htmlHere ya go, about 45 cents each shipped to US. But you gotta buy 100 of them for that price.

author: ataradov
author_rank: Super Contributor
timestamp: April 15, 2017, 10:27:19 pm
content: Quote from: Nusa on April 15, 2017, 09:40:52 pmYep, ordered those.

author: Cerebus
author_rank: Super Contributor
timestamp: April 15, 2017, 11:23:05 pm
content: Quote from: timb on April 15, 2017, 09:12:56 pmCliff K18, available with or without added weights to make them 'spinable' and give them a range of feels.http://www.cliffuk.co.uk/products/knobs/rotary.htm

author: Cerebus
author_rank: Super Contributor
timestamp: April 15, 2017, 11:29:10 pm
content: Quote from: rstofer on April 14, 2017, 03:39:37 pmI've tried something similar in the past and found that using the press switch on the encoder had a tendency to jog a digit or two as you pressed the switch. I tried a reverse dead time to avoid this and I found that made the encoder seem unresponsive.

author: ataradov
author_rank: Super Contributor
timestamp: April 17, 2017, 05:50:17 am
content: Just an update on the final (so far) design, just in case anyone stumbles on this later.It is basically the same stuff Siglent and others do, but without an encoder. I have 4 buttons - left, right, up and down. Left and right select a position (digit), and up and down change values starting from that position.With this method, the rate of change can be predictable and reasonably slow. If you want to go faster - just go to a higher order of magnitude.Another major benefit, which I actually use quite a bit - it allows for monotonic manual sweeps with arbitrary step.

author: ataradov
author_rank: Super Contributor
timestamp: May 07, 2017, 10:27:20 pm
content: Just in case anyone interested why this question came up. Here is the actual project. This is is a signal generator up to 105 MHz (square wave only, lower frequencies have adjustable duty cycle) and frequency counter up to ~30 MHz.This thing abuses SAM D11 in every possible way, but it still performs nicely. Most of the abuse is in the over-clocking peripherals by a lot, so obviously use at your own risk, and operation outside of normal temperatures is not guaranteed. It is still a nice project for home and hobby use.All project files (hardware and firmware) are available athttps://github.com/ataradov/siggenand PCBs can be ordered from OSHParkhttps://oshpark.com/shared_projects/lv69ij3V

author: android
author_rank: Regular Contributor
timestamp: May 08, 2017, 11:40:51 am
content: And here's how to convert the cheap unweighted variety into the expensive weighted variety.(Yes, I'm a cheap bastard)

author: CJay
author_rank: Super Contributor
timestamp: May 08, 2017, 12:10:34 pm
content: Too late I'm sure but I'm thinking video recorder jog dial which typically had two switches per direction, first switch per direction was activated with a small turn CW or CCW and selected something like 2x speed play then the second switch was actuated if the dial was turned further and selected 4x or whatever speed play, would probably be fairly easy to make or even source

author: ataradov
author_rank: Super Contributor
timestamp: May 18, 2017, 06:36:47 pm
content: One more update. Those encoder knobs from aliexpress have arrived. They are very well made and look and feel great. I can absolutely recommend them.