Page 1 of 1

Optical Encoder

Posted: Mon Sep 19, 2016 12:26 am
by neteng
Hi All,

I am still a RPi newbie and I am in search(if their is one) of a motor encoder library. My motors are 12V DC motors with optical encoders providing feedback. These encoders have 2 channel output, channel A and B which are 90 degrees apart.

Could anyone provide a source code library or hints for these types of encoders??....

Also,
the encoders are specified to have a Vcc of 5V...And I have tried supplying it with 3.3V Vcc and I can still see the pulses at the outputs....Reason why I am supplying it with 3.3 V is that I want it to be able to be connected to the RPi GPIO....

Is this ok??...Or if one could recommend another alternative like stepping down the voltage level before feeding it to the RPi GPIO???

Re: Optical Encoder

Posted: Mon Sep 19, 2016 8:23 am
by joan
Generally the A/B outputs are open collector. That means they pull-down to 0V to signal a pulse and float to an external voltage otherwise. The specs should say.

If that's the case you should be able to power the encoder from 5V but attach A and B to Pi GPIO. You'll need an external 3V3 pull-up on the A/B GPIO through something like 4k7. Alternatively use the Pi's internal A/B GPIO pull-ups to 3V3 (about 50k).

For example software see http://abyz.co.uk/rpi/pigpio/examples.html#pdif2_RED which should handle several 1000s of detents per second.

Re: Optical Encoder

Posted: Mon Sep 19, 2016 8:30 am
by neteng
Thanks joan...

What is this 4k7 you're talking about??

Re: Optical Encoder

Posted: Mon Sep 19, 2016 8:37 am
by joan
A resistor. If the A/B outputs are open collector they need to be pulled up to an external voltage to work properly. They will then normally read 1 but will read 0 at each detent. 4k7 will let enough current flow for the A/B outputs to be a solid 1 but will still be easily defeated when the A/B outputs are pulled to ground by the encoder (so that they read 0 for a pulse).

Re: Optical Encoder

Posted: Mon Sep 26, 2016 2:07 am
by neteng
I am thinking of using an ATX power supply to cater for my 3.3V Vcc for my encoder. Is this harmful to my GPIO???

Re: Optical Encoder

Posted: Mon Sep 26, 2016 7:49 am
by joan
neteng wrote:I am thinking of using an ATX power supply to cater for my 3.3V Vcc for my encoder. Is this harmful to my GPIO???
3.3V is precisely what the GPIO need. It would be prudent to measure the voltage though. The Pi will present little load.