Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: mike_522 on November 09, 2012, 05:04:44 AM

Title: Rotary encoder. Digital counter. Hall-effect
Post by: mike_522 on November 09, 2012, 05:04:44 AM
Hi everyone! I'm hoping to get an advice/answer to the following questions:
1. I'm doing self-balancing robot and I have to implement optical rotary encoder for each wheel. In order to minimise processing power I'd like to make use of a digital counter. I don't quite understand what sort of data it will provide to my microcontroller. Will it be just a number of pulses and my MCU has to workout speed and distance relative to some time period? What about reset? Can anyone provide a tutorial how to build this kind of circuit?
2. As an alternative to optical encoder, I'm thinking of rotary encoder based on hall-effect. These types of sensors look more aesthetic, however I'm not sure about the cost and the complexity regarding implementing it. Any advice on that?
Thank you!
Title: Re: Rotary encoder. Digital counter. Hall-effect
Post by: newInRobotics on November 09, 2012, 09:42:11 AM
Probably the easiest shaft encoder You can make consists of black and white striped disk and IR emitter-detector pair. It works this way:

Using counter  variable value You can determine current velocity of motor shaft. Let's say that You have motor with gearbox that increases RPM three times. You decide to check counter variable every 1s. Also, You know, that Your striped disk consists of 360 stripes. So, You check counter variable value after 1s and find it to be 192 (which means that motor have spun 192°), now You multiply it by 3 (gearbox gear ratio) and find out that the wheel connected to gearbox output shaft have spun 192° * 3 = 576° = 1.6 rotations. Lets say that wheel diameter is 5cm, hence it's circumference is PI * 5cm = 15.7cm. Now You know that You wheel has traveled 15.7cm * 1.6 = 25.12cm.

Don't bother Yourself with external counters, Your microcontroller is more than capable to handle 2 level shift interrupts, loads of other sensors and many many calculations per second.

(http://www.societyofrobots.com/images/schematics_infraredemitdetbas.jpg) (http://www.societyofrobots.com/schematics_infraredemitdet.shtml)

(http://www.societyofrobots.com/images/sensors_printoutencoderwheel.jpg) (http://www.societyofrobots.com/sensors_encoder.shtml)
Title: Re: Rotary encoder. Digital counter. Hall-effect
Post by: mike_522 on November 09, 2012, 11:52:49 AM
Thank you newInRobotics! The reason why I'm interested in digital counter IC's is that I really need a lot of processing power. I'm planning to stabilize my system using pole placement technique, implement kalman filter and also make it avoid obstacles by employing some clever algorithm. 8bit 16Mhz Atmel chip will be struggling I think (I  only know AVR-C). Does anyone know popular digital counter IC chip? Optical encoder is a bit of a pain to be honest, things look much cooler with hall-effect encoder as you can make use of a tiny bit of the shaft sticking out from the other side of the motor.
Title: Re: Rotary encoder. Digital counter. Hall-effect
Post by: Soeren on November 10, 2012, 06:21:17 AM
Hi,

The reason why I'm interested in digital counter IC's is that I really need a lot of processing power.
It's very common for newbies to have very little feel for, what can be accomplished in a given time frame (and they rarely calculate it either).

That said, if you really want the counting to take place outside your microcontroller, just implement the counter of your dreams in another microcontroller - then you can make it communicate with the main controller in whatever way you wish.

One possible problem with an external counter (or divider) is, that if you want tight control, you need to read it very frequently anyway, so the time saving may be minimal and your resolution will suffer and could be just as good with a lower resolution encoder.


[...] by employing some clever algorithm.
How can you determine that you won't have enough time, when you don't know what the program are going to be?


Optical encoder is a bit of a pain to be honest,
Optical encoders are the staple food in rotary encoding in robots.


things look much cooler with hall-effect encoder as you can make use of a tiny bit of the shaft sticking out from the other side of the motor.
If you wanna use a linear hall to get sine/cosine output, you will need to handle it through A/D-C inputs and that's very processor intensive compared to simple digital ticks.

A rotary Hall decoder, on the other hand is expensive and needs very accurate positioning.

An optical solution is cheap and easy and if aestethics is your main goal, you're going to have a shell around the entire robot anyway, so nobody will see it.
Title: Re: Rotary encoder. Digital counter. Hall-effect
Post by: Soeren on November 10, 2012, 06:24:09 AM
Hi,

Let's say that You have motor with gearbox that increases RPM three times.
All the gearboxes I use decreases the RPM ;)
Title: Re: Rotary encoder. Digital counter. Hall-effect
Post by: mike_522 on November 11, 2012, 05:57:03 PM
Once again Soeren, thank you!
Title: Re: Rotary encoder. Digital counter. Hall-effect
Post by: newInRobotics on November 12, 2012, 02:48:01 AM
Hi,

Let's say that You have motor with gearbox that increases RPM three times.
All the gearboxes I use decreases the RPM ;)
Good point. Got everything the wrong way around. Still - math behind it is all the same :)