2018-03-24 10:23 AM
I understand that a timer (that supports encoder mode) can be used for keeping track of a rotary incremental encoder, but is there a good way of making the value saturating? So that when turned 'forward' the value increments to a given value and stops incrementing even if the knob is turned further, and the same way when turned 'backward' - the counter value saturates to zero.
#encoder-mode #rotary-encoderSolved! Go to Solution.
2018-03-30 03:01 AM
I know of no simple way of making the timer 'saturate', but you could do this easily in software when reading out the timer value, something along these lines:
global:
#define DIAL_VALUE_MIN 12#define DIAL_VALUE_MAX 4253uint16_t dialValue = DIAL_VALUE_MIN;local:uint16_t t;static uint16_t oldt;int32_t delta;t = TIM3->CNT;delta = (int32_t)(int16_t)(t - oldt);delta += dialValue;if (delta < DIAL_VALUE_MIN) delta = DIAL_VALUE_MIN; else if (delta > DIAL_VALUE_MAX) delta = DIAL_VALUE_MAX;dialValue = delta;JW
2018-03-24 01:29 PM
Yes, you would need to enable the interrupts and test/block it manually.
the nature of rotary encoders is endless counting.
2018-03-24 02:00 PM
OK, thanks. So there is no HW-setting. I think I'll then need to poll the counter value often enough so that the value doesn't change too much (maybe about +/- quarter of the full range to tell the difference between positive and negative change) and keep record of the value in SW adding/subtracting the read counter value - as long as the total is within the allowed range. I guess interrupts don't help me here, because when saturated, the counting needs to continue immediately if the knob is turned in the opposite direction.
(BTW, why does the site show stars in place of the word 'k n o b'?)
2018-03-24 02:32 PM
Well, does anyone know a politically correct word to use instead?
(I'm a Finn, English is not my native language.)
2018-03-24 03:11 PM
turboscrew wrote:
(BTW, why does the site show stars in place of the word 'k n o b'?)
NSFW:
https://www.urbandictionary.com/define.php?term=knob
EDIT
Ha ha - it even censored the web link!
2018-03-24 03:17 PM
Hmm, I think I could get used to 'dial'...
2018-03-24 03:42 PM
spindle?
dial?
EDIT
And yet it allowed 'knobs' (plural) in the title
EDIT
2018-03-24 04:02 PM
Jog shuttle is used in tv production.
In this case it's a jog dial.
2018-03-24 05:45 PM
You chose the correct word - why 'k n o b' is censored is beyond me...bad software?
2018-03-24 05:55 PM
Because, in certain contexts, it is used as a rude word - see
https://www.urbandictionary.com/define.php?term=knob
[NSFW]
Presumably, the censor is just using a simple dictionary lookup - with no context awareness.