Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Rotary Encoder not working as expected...

Status
Not open for further replies.
That is a great find, but I still don't think it accounts for what I'm seeing... :(
If I had this other type of encoder, I'd see various states as I rotate. But what I see now with my current configuration is consistent with each rotation.

hi,
I looked at that link stated inside the link I posted.

Its a link to a Bourns encoder, I noted that the centre pin 'C' of that type is the centre pin.???

I know its a pain, but can you post a sketch or a more detailed description on how the leds A, B light for 4 steps of the ident.

I'll try to figure whats happening.:)
 
hi,
I know its a pain, but can you post a sketch or a more detailed description on how the leds A, B light for 4 steps of the ident.

I'll try to figure whats happening.:)

I'll try to explain better. Maybe the only problem is with my understanding.

Hardware:
I have an LED connected between 5V and a 390 ohm resistor. The other side of that resistor connects to Phase A. Phase B is setup the same with separate LED and resistor. The common pin is connected to Ground.

My Output Waveform is exactly as shown in the datasheet. However, the time that it occurs conflicts with my understanding.

Here's my understanding:
The knob on the encoder rotates and has feedback provided by the detent. The detent is the location where the knob is forced to stop so that the output can be measured. In my case, just observe LEDs. The transition from one detent to the next should be an unstable point and no measurements should be taken then. As you rotate, each detent should provide 1 of 4 gray code states and you'd compare you current state with the previous state to know the direction of travel.

Here's what I'm seeing:
Anytime the knob is in the detent position (stable), neither of the LEDs are lit. When I slowly move from one detent position to the next, I see the one LED light up and then the other. Then, the first turns off and then the other. This is the Output waveform specified in the Datasheet. My only reason for concern is that I didn't expect this waveform to occur during the transition from one detent to another.

So, let's start by you guys telling me if my understanding is correct or not.

Let me know if this sheds light on anything. If not, I'll try to take some pictures this weekend.
 
hi,
Thats working as described in the encoder link I posted:
ie:
Contacting encoders often have detents that 'click' through an entire A/B cycle per detent

So its this type and its working correctly.:)
 
hi,
Thats working as described in the encoder link I posted:
ie:
Contacting encoders often have detents that 'click' through an entire A/B cycle per detent

So its this type and its working correctly.:)

Okay. Great! I should have paid more attention to your previous post. :rolleyes:

So, now I can just write a program with the following logic:
-If I see Phase A rising while Phase B is still low then I know I'm going one direction.
-If I see Phase B rising while Phase A is still low then I know I'm going the other direction.

And then I just need to worry about de-bouncing and see if I can do all that through a software delay. My MCU speed is only 32KHz. So, it might be going so darn slow that I don't have to worry about de-bouncing. :p

Anyways, case closed! Thanks for your patience!
 
Yeah with knob encoders the mechanical detent is almost always after a full quadrature cycle, and at the point when both switches are OFF again (to save power? reduce switch corrosion?).

Your decoding logic seems to be funky, not only will you fail to get full resolution but the detected events won't be evenly spaced - you will only detect events 0 and 1 out of 0,1,2,3 for example.

You can use the old 1/4 resolution system as used in digital logic;
if A goes hi, direction = B

or if you want full encoder resolution there is a good system here
TrackBall Interfacing - TrackBall to PIC microcontroller
(see down the page for C code to read encoder)
 
dear all,

I need help for the rotary encoder. how to check rotary encoder if this damage or no,? could you please teach me and give me an idea how to check this.

thanks,
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top