[sdiy] Rotary encoder reading.. hardware solution (fast & accurate)

Michael E Caloroso mec.forumreader at gmail.com
Thu Aug 12 03:28:29 CEST 2021


My schematics are buried in storage, but that circuit doesn't look too
far from the Moog Source.

MC

On 8/11/21, Jean-Pierre Desrochers <jpdesroc at oricom.ca> wrote:
>> Typically I'd use a 1 ms timer to poll the switch and run a state
>> machine.
> State machine would look for the encoder changing, start a count down timer
> for
>> debouncing, when timer is 0 read encoder and compare it to last stable
> value to see if it has changed.
>
> That’s exactly what I had coded before the hardware ‘solution’.
>
> Polling the 3 encoder pins.  Everything was working fine until I added some
> code to process the encoder changes. Then BOOM..
> Many missed counts everywhere (increments/decrements).
> The interrupt style was even harder to implement since there were
> 4 different states to read before any final counts.
> A $2 bucks chips solution makes me spend my  time
> elsewhere in my  project releasing.
> Again..
>
> Any simple, fast and reliable interrupt driven code to suggest ??
>
> Managing all the encoder 4 steps with debouncing too ?
>
>
>
>
>
> De : Synth-diy [mailto:synth-diy-bounces at synth-diy.org] De la part de Jay
> Schwichtenberg via Synth-diy
> Envoyé : 11 août 2021 20:14
> À : synth-diy at synth-diy.org
> Objet : Re: [sdiy] Rotary encoder reading.. hardware solution (fast &
> accurate)
>
>
>
> I agree with Tom, this is a trivial uC problem that can be solved with
> about
> a page of firmware.
>
> Don't know where there is any code out there for this. Might check out in
> Arduino land or MicroChip.
>
> I can think of 4-6 ways of doing this, depends on what else the uC needs to
> do.
>
> Typically I'd use a 1 ms timer to poll the switch and run a state machine.
> State machine would look for the encoder changing, start a count down timer
> for debouncing, when timer is 0 read encoder and compare it to last stable
> value to see if it has changed.
>
> Jay S.
>
>
>
> On 8/11/2021 3:53 PM, Jean-Pierre Desrochers wrote:
>
> Any simple, fast and reliable interrupt driven code to suggest ??
>
> Managing all the encoder 4 steps with debouncing too ?
>
>
>
> De : Tom Wiltshire [mailto:tom at electricdruid.net]
> Envoyé : 11 août 2021 18:38
> À : Jean-Pierre Desrochers
> Cc : SDIY
> Objet : Re: [sdiy] Rotary encoder reading.. hardware solution (fast &
> accurate)
>
>
>
> Gagh! Two whole chips to save writing a few lines of code! Heresy! ;)
>
>
>
> Tom
>
>
>
>
>
>
>
>
> On 11 Aug 2021, at 21:27, Jean-Pierre Desrochers <jpdesroc at oricom.ca>
> wrote:
>
>
>
> For anybody who could be interested..
>
> Just found this video yesterday and tried the circuit..
>
>  <https://www.youtube.com/watch?v=UlehqasO-fo&t=1471s>
> https://www.youtube.com/watch?v=UlehqasO-fo&t=1471s
>
>
>
> Outputs A and B (CD4013) connected to PORTB of a PIC16F1783
>
> (RB0 and RB1) using interrupts on change (rising edges).
>
> Now I only have to check one incoming pulse on each RB0 & RB1
>
> to increment or decrement a counter.
> Much faster than computing  all the 4 possible states in each encoder step
> to finally get a result.
>
> My interrupt uses TIMER1 (1msec steps), RB0 & RB1 on change.
>
> No missing counts anymore even rotating fast, on both direction.
>
>
>
>
>
> <image001.jpg>
>
> _______________________________________________
> Synth-diy mailing list
>  <mailto:Synth-diy at synth-diy.org> Synth-diy at synth-diy.org
>  <http://synth-diy.org/mailman/listinfo/synth-diy>
> http://synth-diy.org/mailman/listinfo/synth-diy
> Selling or trading? Use  <mailto:marketplace at synth-diy.org>
> marketplace at synth-diy.org
>
>
>
>
>
>
>
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at synth-diy.org
> http://synth-diy.org/mailman/listinfo/synth-diy
> Selling or trading? Use marketplace at synth-diy.org
>
>



More information about the Synth-diy mailing list