go_away

Author Topic: Rotary encoder. Digital counter. Hall-effect  (Read 1376 times)

0 Members and 1 Guest are viewing this topic.

Offline mike_522Topic starter

  • Jr. Member
  • **
  • Posts: 13
  • Helpful? 0
Rotary encoder. Digital counter. Hall-effect
« 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!
« Last Edit: November 09, 2012, 05:08:24 AM by mike_522 »

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Rotary encoder. Digital counter. Hall-effect
« Reply #1 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:
  • IR emitter shines to striped disk.
  • As disk spins IR beam gets reflected of every white area of the disk and gets absorbed by every black area of the disk.
  • When IR detector gets hit by reflected ray, it's resistance decreases, when there are no IR rays hitting it - it's resistance increases.
  • If You connect resistor to IR detector's input or output pin, You create resistive voltage divider. With every transition from black to white and vice-versa Your voltage divider will output voltage which will transition between voltage near Vcc and voltage near Gnd.
  • What You do next it plug voltage divider output to Your microcontroller and set the connected pin to listen for voltage level change interrupt. When interrupt takes place, it should increment counter variable by one.
  • Also, you should setup a timer to check counter variable value periodically and reset it to zero.

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.



"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline mike_522Topic starter

  • Jr. Member
  • **
  • Posts: 13
  • Helpful? 0
Re: Rotary encoder. Digital counter. Hall-effect
« Reply #2 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.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Rotary encoder. Digital counter. Hall-effect
« Reply #3 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.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Rotary encoder. Digital counter. Hall-effect
« Reply #4 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 ;)
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline mike_522Topic starter

  • Jr. Member
  • **
  • Posts: 13
  • Helpful? 0
Re: Rotary encoder. Digital counter. Hall-effect
« Reply #5 on: November 11, 2012, 05:57:03 PM »
Once again Soeren, thank you!

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Rotary encoder. Digital counter. Hall-effect
« Reply #6 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 :)
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

 


Get Your Ad Here

data_list