Let's Make Robots!

how to get wheel velocity

Hi guys,

I am taking "control of mobile robots" course on coursera and is pretty intrigued in building a 2 wheel robot car. One of the issues was the control of the 2 wheel velocities here.

So far, I've got a Uno and bought the magician chassis from sparkfun. It provides 2 dc motors. May I know using the dc motors, is it sufficient to be able to know and  control the individual wheel velocities? 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Here's a link to some inexpensive motor contollers.

The L298N chips are a bit overkill for your bot, but I don't think they would cause a problem. Your motors are rated at 6V. If you used a two cell LiPo the L298N chips would drop the 8V from the batteries down to a safe 6V level. If you use NiMH, you'd probably want to use 5 or 6 cells.

I'm using these H-bridge PCBs on my Rover 5 bots. I think they work well. I understand there are lots of more efficient h-bridge chips available but the price of these were L298N boards was so low, I decided to go use them.

Whichever h-bridge you go with, make sure you use the recommended flyback diodes to protect your Arduino. The board I linked to above includes these diodes on the PCB.

Here's an option that probably doesn't require the flyback diodes.

Encoder feed back really helps in some applications. My Mecanum wheeled Rover 5 behaved much better at low speeds after I added feedback from the encoders. You can still do a lot of stuff with your robot without encoders. IMO, you should try adding ultrasound and IR obstacle sensors before messing around with encoders.

There are two more things you need to run the motors and control the speed:

1) Motor driver board.
This is the part that controls the power delivered to the motors, making them run fast, slow, backwards, etc. The Uno by itself can't supply enough current to control the motors, so you'll need a DC motor shield or another type of DC motor driver board.

2) Wheel speed feedback.
If for example you run both motors at 50% power, they still won't go exactly the same speed. Also, as the batteries start to run low your motors will run faster or slower. Other things like temperature, wear, lubrication all factor in to make the motors run at varying speeds even if you try to run them at the same power.
To get around this problem, the easiest thing to do is add some feedback sensors to tell you how fast the wheels are going. If they aren't going fast enough you just keep adding more power until you get the right speed, or less power if the speed is too high.
The simplest type of wheel speed feedback sensor is an encoder like Max mentioned.
OddBot has posted a good walkthrough on quadrature encoders that will help you understand how to use it. 

hi telefox, 

thanks but as I've just got started out on this hobby, there are a couple of things I haven figured out and need your help.

1. What's the difference between a motor shield and a h bridge driver? are there any guidelines in buying one?

2. Do i need external power supply to my uno board, or do i use the 5V USB input, once I got the motor shield? Right now, the magician chassis provides a 1.5V battery case, do I use that instead of the USB power supply?

3. How do I know what are the specifications of my DC motors? I got them with the chassis and theres no specifications anyway?

4. Is there any difference if I use a servo or a dc motor? I've roughly read about the differences but I am not too sure how those differences translates to how I control the motors/accuracy etc.

Thanks again for your help.

1) A motor shield is a board that plugs into an Arduino board that has an H-bridge driver built into it. You can use any H-bridge driver of the right ratings for your motors, however a motor shield will typically be more expensive but require less effort.

2) Yes, it is very unlikely that the USB will provide enough power for your motors. The battery case should be enough to power both the Uno and your motors.

3) There are some specs you can calculate by measuring the motors yourself, but you are probably better off talking to the supplier and trying to get the info from them.

4) Yes, there are many differences:
• Each servo has an integrated driver - no H-bridge required
• Typical servos are controlled to move to a set position, not at a certain speed
• Typical servos can only rotate within a maximum range, usually less than 180°
• Servos are virtually always used with an integrated gearbox, so they turn more slowly but with higher torque 

It is possible to hack a servo so that is can rotate continuously, and then the normal position control becomes a speed control instead. There are many articles that can be found here on LMR regarding making a continuous rotation servo.
You'll be able to manually tune the speed of two continuous rotation servos to be almost the same, but this method is still not going to be as accurate as using DC motors with encoders... really it depends on how accurately you need to be able to control the speed.

On my magician the motors are pretty well matched-enough that I can get away with an "approximate" Pwm ratio and have it drive reasonably straight, but that probably isn't good enough In the long run. What you need to do is search for "encoders" as a method of differential drive speed monitoring. You should have gotten two encoders as part of the chassis-they look like flat little plastic flower heads that have holes in the center the size and shape of the motor shafts. You can use them either with contact switches or optical breaks.

How do I know what are the specifications of the motors? There aren't any datasheets that comes with it? Also, would you also help me with the follow-up questions i posted above?