Electronics > Projects, Designs, and Technical Stuff
Optical Rotary Encoder
<< < (3/4) > >>
SiliconWizard:

--- Quote from: MuchMore on August 21, 2019, 05:07:32 am ---So if the manual states: "Output Voltage High 4.0V minimum"  it is an activ output so I have to level-shift.

--- End quote ---

Since it's just outputs and rise/fall times are probably absolutely not critical here, you can just use resistive dividers to level-shift. No need for anything fancy. If you have doubts about the output current, use higher values for the divider. They state "Output Current I(SINK), per Channel = 25mA max". At 1/10 or even 1/100th of that you should get perfectly workable thresholds. Don't hesitate to experiment though, will be pretty easy to do.

Now I must insist (probably obvious though). This encoder requires a 5V supply, so this is not just a matter of level-shifting the outputs. You need a 5V supply in your system. If it's just for the encoder, that may not  be very practical. If your power supply source is below 5V (such as a battery), you'll need a step-up converter just for that. Sorry if this is obvious.

Just a couple questions. Are you sure you absolutely need an optical encoder? A mechanical one would not have this limitation. Mechanical encoders are used everywhere. So except if you need exceptionally high reliability, is it worth it?

For 3.3V optical encoders, you can take a look at the Grayhill 62A series:
http://www.grayhill.com/assets/1/7/Opt_Encoder_62AVD.pdf

Not cheap though.
MuchMore:
The rise and fall times are absolutely critical here.
I tried an mechanical encoder (Alps) however the signal was too polluted.
Digital debounce was not possible because there is not enough steady state time, at fast rotation. Including an smoothing cap was not possible because the esp32 will trigger 1000 times on slow edges. an analog read takes to much time, and is too noisy.

I already need an 12V supply for an 0-10V output. So I will get an IRM-03-12 followed by an TPS56339 buck converter and an LP2985A-50 LDO for clean 5V to an MCP4728 ADC

So I already have 3 different voltages.... adding another LP2985 does not matter anymore.

I excluded the Grayhill ones because they are >45€ while the Bourns is ~30€
SiliconWizard:

--- Quote from: MuchMore on August 21, 2019, 03:19:34 pm ---The rise and fall times are absolutely critical here.
--- End quote ---

I don't know what your application is exactly and what you're trying to do, but I don't see how rise/fall times could be *that* critical. The DS states 200ns typ. for the outputs. Adding a resisitive divider even with relatively high resistors values, considering the input capacitance of the MCU I/Os, will maybe lead to a couple µs. Multiplying by like 10 the values you were considering would not lead to slower that this IMO. How bad is that for a rotary encoder, even if it's rotating very fast?


--- Quote from: MuchMore on August 21, 2019, 03:19:34 pm ---I tried an mechanical encoder (Alps) however the signal was too polluted.
Digital debounce was not possible because there is not enough steady state time, at fast rotation.
--- End quote ---

How fast is it going to rotate? If your system can rotate it at very slow to very high speeds, I understand that usual debouncing techniques (be it analog or digital) will be tricky to pull off.
And anyway, I was more thinking about manual rotation. If the encoder is constantly rotated at high speeds, I agree that an optical encoder is the obvious solution.

"Interestingly", The Grayhill encoders in 5V version are around 20€ and over 40€ in 3.3V version... Completely nuts. |O
Ian.M:
I agree.  Lets do the math.

Even if you use the 64 pulse/rev variant, and put a spinner knob on it so you can twiddle it maybe up to 10 revs/s, its only going to give you 2560 edge events per second so you shouldn't have any problems as long as rise/fall times are of the order of 200us or better.

N.B. its life is specced at 30 RPM so its almost certainly unsuitable as a high speed shaft encoder.  10 revs/s  is 600 RPM and even if the high speed doesn't drastically shorten its life, the non-detent version is only rated for 2000000 revs operating life, which you'd exceed in under 56 hours at that speed.

Consider a resistive divider of 82K upper and 150K lower resistors, driving an input capacitance of 50pF. That divider, worst case only needs 215uA of IOH so is fine driven by *ANY* TTL output and gives you a Theivenin equivalent resistance of approx 51K, and a time constant of 2.65us (which is a 5.8us risetime).  That should be plenty fast enough if its being sampled by a MCU.   

OTOH if you are using a fast hardware QEI module that has a sub us spec for maximum rise & fall times, you can still use a passive divider.  The raw rise & fall times of the encoder are specced at 200ns, so there isn't much more than an order of magnitude improvement to be had.  Dropping the divider resistors to 8K2 upper, 15K lower get you down to a time constant of 265ns, at the cost of a worst case IOH requirement of 2.15mA.  If it craps out before you draw 2mA, a 470R pullup at the encoder output will fix that as it has plenty of IOL sinking capacity, but will be a power hog.  Calculating the rise time when the time constant is comparable to the input waveform time constant is a PITA, so I simmed it in LTspice with .measure statements for the risetime and got 608ns.

If you *still* need faster edges stick a speedup capacitor across the upper resistor of the divider, of approx double the input capacitance, to form a capacitive divider with the input capacitance.


dom0:

--- Quote from: Ian.M on August 21, 2019, 06:24:30 pm ---82K upper and 150K lower resistors, driving an input capacitance of 50pF. That divider, worst case only needs 215uA of IOH

--- End quote ---

21.5 µA


--- Quote from: Ian.M on August 21, 2019, 06:24:30 pm ---Dropping the divider resistors to 8K2 upper, 15K lower get you down to a time constant of 265ns, at the cost of a worst case IOH requirement of 2.15mA.

--- End quote ---

215 µA
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod