1

I'm trying to create a car that's being controlled by an Arduino. I'm using the following chasis: http://www.aliexpress.com/item-img/New-2WD-car-chassis-DC-gear-motor-wheels-easy-assembly-and-expansion-car-toys-robot-toys/32310649967.html

And L298N motor driver.

The problem is it's hard to make the car go straight. Giving the same PWM value to the motors still makes them spin in different speeds, trying to calibrate the value is hard and every time I recharge my batteries the value changes.

What are my options on making the car go straight when I want (well, sometimes I'll want to turn it around of course)?

I've thought about using an encoder but I wish to avoid that since it will complicate the whole project, is there any other viable option? and even when using an encoder, Does it means I will need to keep track all the time and always adjust the motors value continuously? is there some built-in library for that?

Thanks in advance!

  • You may find Robotics Stackexchange also useful for questions like this. – James Waldby - jwpat7 Feb 9 '16 at 23:43
  • With a separate motor for each wheel, a couple of encoders and a feedback loop seem unavoidable. – Edgar Bonet Feb 10 '16 at 9:23
  • You might be able to use a "hall effect sensor" or "reed switch" and a magnet. It won't be as pretty as a encoder. But it can be used to sync both the wheel speeds. – Paul Apr 11 '16 at 12:15
  • @my past self. It sounds fairly stupid to use a hall effect sensor near a electric motor. (Never mind that suggestion.) – Paul May 11 '16 at 14:13
  • An old method is that if you have access early in the gear train where speed is high and torque low, a pair of magnets can mechanically synchronize two motors when their drive is comparable but still allow them to turn at substantially different speeds/directions when driven differently. – Chris Stratton May 11 '16 at 19:51
1

I used a simple optical encoder and the little disks that came with my kit. The encoders cost < £1 for 2 of them.

Failing that use an accelerometer and measure the lateral motion, should also cost about £1.

0

Modern tiny $20 toy quadcopters use a magnetometer to maintain a steady heading. Duplicating that effect could be cheaper and more reliable than dual encoders. On certain surfaces, like carpet, even perfect encoding with perfect voltage and wheels can't guarantee maintaining the heading.

One viable option might be to drive one wheel with your control system, drive the other wheel to maintain the magnetometer heading, and then steer by adjusting the target heading.

  • 1
    Actually the cheap ones try to integrate the gyro. Magnetometers only come in at a higher price point. Even if you do get a magnetometer it will be harder to interpret and more interference prone than encoders. But it is possible with care if an external reference is what is desired. – Chris Stratton May 11 '16 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.