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.

Switching from Mechanical Encoder to Optical Encoder

Status
Not open for further replies.

DerStrom8

Super Moderator
Hi guys,

I have not had the opportunity to use rotary encoders in the past for my designs, so I am very fuzzy about the differences in types, and how they're handled by software (assuming a uC is used). One design I'm currently looking at uses the Grayhill 25LB11-Q mechanical rotary encoder (Datasheet ). I have the software for reading from this device using a microcontroller, and it works very well. However, being mechanical these encoders are generally only good for about 100k rotations (according to the DS) before they start to fail. The device in question requires constant manipulation of the knobs, so the mechanical ones really don't last very long. I am looking for different options, and thus I have begun to look at optical encoders instead. One that I have considered is the Bourns EM14A0D-C24-L032N (Datasheet: https://www.bourns.com/data/global/pdfs/em14.pdf). I am wondering what changes (if any) will need to be made to the software to "read" the optical encoder instead of the mechanical one? The optical one will, of course, have an extra pin for the external 5V power supply (something that the mechanical encoder didn't need). Neither have a built-in switch.

I don't need any of the code or anything like that. I am wondering, however, if the same code used to "read" the 25LB11-Q will work with the EM14A0D-C24-L032N as well, or if it will require changes (if so, what types of changes)?

The diagrams look identical:

Mechanical:

upload_2015-7-16_11-21-7.png


Optical:

upload_2015-7-16_11-20-39.png


Thanks,
Matt
 
Last edited:
You are changing from something with two output impedances at the extremes (0 ohms and infinity) to something with a totem pole output and a moderately low output impedance. From the datasheet numbers, it looks sorta like AC CMOS. Assuming your original interface circuit had pull up or down resistors, you won't need them. Depending on the logic polarity of the old encoder (switch to gnd vs. switch to Vcc), the new encoder might seem to be backwards. You can fix this in firmware, or by swapping the A and B output connections.

ak
 
Can't see how you'll need to change the software!! You're only difference is the interface..

I actually use that bourns pot.... I use it on a slewing limiter that I make... One thing!!! Decoupling cap on the encoder, I lost three before I realized how sensitive they are... 0.1uf across the power rail right on the pins....
 
You are changing from something with two output impedances at the extremes (0 ohms and infinity) to something with a totem pole output and a moderately low output impedance. From the datasheet numbers, it looks sorta like AC CMOS. Assuming your original interface circuit had pull up or down resistors, you won't need them. Depending on the logic polarity of the old encoder (switch to gnd vs. switch to Vcc), the new encoder might seem to be backwards. You can fix this in firmware, or by swapping the A and B output connections.

ak

The diagrams I included in my post suggest that the polarities are the same--The "HIGH"s match up, as do the "LOW"s. The old design did indeed use pull-ups: a network of 3.3k resistors (it has 3 knobs, so two resistors for ch A & B on each encoder).

Can't see how you'll need to change the software!! You're only difference is the interface..

I actually use that bourns pot.... I use it on a slewing limiter that I make... One thing!!! Decoupling cap on the encoder, I lost three before I realized how sensitive they are... 0.1uf across the power rail right on the pins....

Thanks for the info Ian. I will certainly remember the decoupling caps :D

I didn't think I would have to change the software, as the polarity and switching styles appear to be identical. I just wanted to verify, as I have not used these before. I actually inherited this project.

Thanks,
Matt
 
The truth tables for the 25L mechanical encoder indicate that the switches were pulling the signal lines up when closed, which means the signal lines had pull down resistors. You have pull up resistors, the opposite logic polarity.
25L A phase in DerStrom8 circuit = EM14 B phase.

ak
 
As regards code, the phase difference is always quadrature (90° phase shift), so it should not matter, also assuming both diag. show the same rotation dir.
Max.
 
The truth tables for the 25L mechanical encoder indicate that the switches were pulling the signal lines up when closed

Where do you see that? I'm seeing this:

upload_2015-7-16_15-24-26.png


Dots indicate a closed circuit, which means it's connected to ground (the "COMMON" pin). Am I wrong?
 
The common pin could be connected to either ground or the logic 1 level. If common is connected to ground the there would be pull up resistors to the logic 1 level on the A and B outputs. If common is connected to logic 1 level then pull down resistors would be connected between ground and the A and B outputs. Either way is valid so the table does not imply weather common should be connected to either ground or logic 1 level.

Les.
 
To me the dots on the chart indicate high or 1.
Quadrature position optical encoders used in CNC or servo positioning do not use any detent whatsoever.
A or B pulse 1 or 0, or if differential the complements also, /A & /B.
Typically 3 types of output, push-pull, open collector and differential.
Max.
 
The table for position 2 combined with the waveform drawing for position 2 in post #1 make it clear (OK, clear to me) that a dot = a closed switch = a logic 1 = Vhigh, implying pull-down resistors. The "32 DETENT" plot for the optical encoder confirms that both encoders define phase A the same way. Ergo...

ak
 
Do both types of encoder provide the same number of pulses per revolution? If not, depending on your application, some software change may be necessary.
 
I was looking at the current schematic for the project I'm working on when I said that Common is connected to ground. Thus a "closed switch" would connect A and B to ground as well, hence the pull-up resistors I'm seeing in the existing schematic.

Do both types of encoder provide the same number of pulses per revolution? If not, depending on your application, some software change may be necessary.

The datasheets I linked to suggest that both encoders are 32 PPR.
 
Can't see how you'll need to change the software!! You're only difference is the interface..

I actually use that bourns pot.... I use it on a slewing limiter that I make... One thing!!! Decoupling cap on the encoder, I lost three before I realized how sensitive they are... 0.1uf across the power rail right on the pins....

Hi Ian, back to this--

The encoders are mounted to the top of an enclosure, and the shortest cables I can find are 6". Currently I have the decoupling caps on the PCB, but I'm wondering if I should solder them directly to the pins of the encoders. What would you suggest?

Also, did someone say that pull-up resistors aren't necessary for optical encoders?

Thanks,
Matt
 
Correct, you do not need the resistors with optical. The difference from mechanical encoders is that for optical encoders you can not set the logic polarity. If you don't like the logic polarity, you must either add inverters to the signal paths or alter the firmware that uses the encoder signals. When changing between the two encoders in post #1, this will be necessary.

ak
 
The Bourns appear to be TTL compatible output.
All optical quadrature encoders are detected as two sine waves and have to be squared up before output, and three typical outputs exist, Push-Pull, Open Collector, and Differential (RS485).
Apart from the 25ma sink detail the actual nature is not shown.
Max.
 
Hi Ian, back to this--

The encoders are mounted to the top of an enclosure, and the shortest cables I can find are 6". Currently I have the decoupling caps on the PCB, but I'm wondering if I should solder them directly to the pins of the encoders. What would you suggest?

Also, did someone say that pull-up resistors aren't necessary for optical encoders?

Thanks,
Matt
The optical bourns pots that I had didn't like spikes so I decoupled them right at the pot... They seem to work okay now.
 
Thanks everyone. You all have been a huge help!

Regards,
Matt
 
The optical bourns pots that I had didn't like spikes so I decoupled them right at the pot... They seem to work okay now.

Well that makes it a bit tricky, since the cable is fit onto to the pins of the encoder I'm not sure how much room I'll have to solder in a cap. Poor product design? I realize these are supposed to be PCB mount, but they provide cables for a reason. If someone uses a cable, how are they supposed to fit in a decoupling cap??? :facepalm:

Matt
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top