Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Robotics Chat


Robotics Chat Specific to discussions about robots and the making of.

Reply
 
Tools
Old 21st August 2009, 02:42 PM   #16
Default

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...?
ignisuti is offline  
Old 21st August 2009, 03:14 PM   #17
Default

Quote:
Originally Posted by ignisuti View Post
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...?
Hi,
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.
Attached Thumbnails
Rotary Encoder not working as expected...-aaesp02.gif  
__________________
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.
ericgibbs is offline  
Old 21st August 2009, 04:44 PM   #18
Default

You have to debounce it he seeing switch bounce
be80be is offline  
Old 21st August 2009, 05:10 PM   #19
Default

Quote:
Originally Posted by be80be View Post
You have to debounce it he seeing switch bounce
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.
ignisuti is offline  
Old 21st August 2009, 05:13 PM   #20
Default

Quote:
Originally Posted by ericgibbs View Post
Hi,
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.

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.
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.
ignisuti is offline  
Old 21st August 2009, 06:13 PM   #21
Default

Quote:
Originally Posted by ignisuti View Post
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.
__________________
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/
ericgibbs is offline  
Old 21st August 2009, 06:36 PM   #22
Default

Quote:
Originally Posted by ericgibbs View Post
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.
ignisuti is offline  
Old 21st August 2009, 07:02 PM   #23
Default

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/
ericgibbs is offline  
Old 21st August 2009, 08:03 PM   #24
Default

Quote:
Originally Posted by ericgibbs View Post
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.

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!
ignisuti is offline  
Old 22nd August 2009, 01:48 AM   #25
Default

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)
Mr RB is online now  
Reply

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



All times are GMT. The time now is 11:44 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker