![]() | ![]() | ![]() |
| |||||||
| Robotics Chat Specific to discussions about robots and the making of. |
![]() |
| | Tools |
| | #16 |
|
Status update: I had to order some more encoders to test if I damaged my previous one. I wired the new on up per you Eric's diagram. However, my results are the same. I'm now seeing both LEDs light up briefly 'during' each position change. The order that they light up depends on the direction of travel. Again, I can write software to watch for which LED lights up first, but I'm still curious why my results are different than expected... FYI: I also purchased a different type of rotary encoder for the purposes of testing and it's acting the same. Anymore thoughts...? | |
| |
| | #17 | |
| Quote:
Been doing a little checking thru various encoder types. You may have this type: Contacting encoders often have detents that 'click' through an entire A/B cycle per detent That is the mechanical indent is positioned to give only a transient switching action. I found this link that may help. Google Image Result for http://www.qsl.net/pa3ckr/bascom%20and%20avr/interrupts/rotary-encoder.gif EDIT: Relooking at your original datasheet, its misleading, it shows the detent numbers misaligned which suggests the A/B cycle is at rest. Modified image.
__________________ Eric " Good enough is Perfect " I will NOT answer PM's requesting technical help, please use the Forum PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 21st August 2009 at 03:26 PM. | ||
| |
| | #18 |
|
You have to debounce it he seeing switch bounce
| |
| |
| | #19 |
| Contact bounce would be if my MCU saw several hits. This isn't the case as I havn't made it that far yet. I just built a VERY simple test circuit that lights an LED through a 390 ohm resitor. Each phase (A & B) has it's own LED. I'm seeing both LEDs light up but only as I move from on detent location to the next. They turn off once I reach the resting point. One phase always lights up before the other, based on the direction of rotation. | |
| |
| | #20 | |
| Quote:
![]() 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. | ||
| |
| | #21 | |
| Quote:
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.
__________________ Eric " Good enough is Perfect " I will NOT answer PM's requesting technical help, please use the Forum PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/ | ||
| |
| | #22 | |
| Quote:
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. | ||
| |
| | #23 |
|
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.
__________________ Eric " Good enough is Perfect " I will NOT answer PM's requesting technical help, please use the Forum PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/ | |
| |
| | #24 | |
| Quote:
![]() 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. ![]() Anyways, case closed! Thanks for your patience! | ||
| |
| | #25 |
|
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) | |
| |
|
| Tags |
| encoder, expected, rotary, working |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Identifying and using a rotary encoder, help! | dec_lan | General Electronics Chat | 3 | 11th August 2009 04:55 AM |
| Rotary Encoder | vk6kci | Electronic Projects Design/Ideas/Reviews | 6 | 21st May 2009 12:57 AM |
| PPR for rotary encoder | engkeat | Robotics Chat | 0 | 23rd December 2008 05:03 PM |
| Rotary Encoder with Switch | Mike, K8LH | Datasheet/Parts Requests | 3 | 24th March 2005 03:28 PM |
| Magnetic rotary Encoder | sarang1_in | Datasheet/Parts Requests | 1 | 28th February 2005 04:13 AM |