Hi
Does anyone have experience with hooking up this encoder? It appears to have added circuitry which I hope is for debounce.
How to connect "Switch, Data, Clock" to these terminals?
Thanks
Zim
Rotary encoder hookup
Rotary encoder hookup
You do not have the required permissions to view the files attached to this post.
-
- Posts: 341
- Joined: Tue Jun 21, 2022 2:17 pm
- Location: South coast UK
- Has thanked: 178 times
- Been thanked: 110 times
Re: Rotary encoder hookup
Sorry, don't know that one specifically but it shouldn't be too hard to work out.
It certainly looks like it has 10k resistor pullups and decoupling caps fitted.
No obvious silicon anywhere so I'd guess the pin labelled 5v can be 3v3 with no consequences.
You could use a DVM to detect the function of the other pins but I would have high confidence that S1 and S2 are the two phases and 'key' is when you push down on the knob.
Don't forget, if you are going to use interrupts to read it, the interrupt triggers on BOTH high and low transitions.
You will have to write code to ignore one of the state changes for each phase.
I don't know if this has changed over the years because the example code assumes a single interrupt trigger and will not work as expected with the current firmware 1.44.2
Just re-read your question.
What are you trying to connect that has "switch data clock"?
That looks like a quadrature encoder which has 2 phases and push button.
It certainly looks like it has 10k resistor pullups and decoupling caps fitted.
No obvious silicon anywhere so I'd guess the pin labelled 5v can be 3v3 with no consequences.
You could use a DVM to detect the function of the other pins but I would have high confidence that S1 and S2 are the two phases and 'key' is when you push down on the knob.
Don't forget, if you are going to use interrupts to read it, the interrupt triggers on BOTH high and low transitions.
You will have to write code to ignore one of the state changes for each phase.
I don't know if this has changed over the years because the example code assumes a single interrupt trigger and will not work as expected with the current firmware 1.44.2
Just re-read your question.
What are you trying to connect that has "switch data clock"?
That looks like a quadrature encoder which has 2 phases and push button.
Re: Rotary encoder hookup
Hi
I am just using an example code and left the acronyms the same. All works well now. No bounce to speak of.
Thanks BeanieBots!
I am just using an example code and left the acronyms the same. All works well now. No bounce to speak of.
Thanks BeanieBots!
Code: [Local Link Removed for Guests]
D1=5:D2=4:D5=14
count = 0
SW = D5
DT = D1
CLK = D2
pin.mode SW, input
pin.mode DT, input, pullup
pin.mode CLK, input, pullup
interrupt CLK, encoder
interrupt SW, switch
wait
encoder:
if pin(DT) = 1 then return ' if the pin is high, returns back
if pin(CLK) = pin(DT) then count = count - 1 else count = count + 1
if count <= 0 or count > 10 then let count = 1 'gives a range of 1 - 10
wlog "count", count
return
switch:
wlog "switch", pin(SW)
return
-
- Posts: 341
- Joined: Tue Jun 21, 2022 2:17 pm
- Location: South coast UK
- Has thanked: 178 times
- Been thanked: 110 times
Re: Rotary encoder hookup
Glad you got it all working OK.
That nomenclature is 'old-school' from before micros when counters were made using hardware flip-flops.
One phase being "data" and the other phase used to clock the data through.
Although it is possible to do debouncing in code, I personally still prefer to do it in hardware with Rs and Cs.
Good luck with the rest of your project.
That nomenclature is 'old-school' from before micros when counters were made using hardware flip-flops.
One phase being "data" and the other phase used to clock the data through.
Although it is possible to do debouncing in code, I personally still prefer to do it in hardware with Rs and Cs.
Good luck with the rest of your project.