go_away

Author Topic: PWM 2 x DC MOTORS - Different Speeds? Motor Recommendations  (Read 2571 times)

0 Members and 1 Guest are viewing this topic.

Offline ethoughtTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
PWM 2 x DC MOTORS - Different Speeds? Motor Recommendations
« on: March 07, 2010, 08:36:26 AM »
Hi All -

I am trying to build my robot drive system using 2 DC motors, one at each front wheel.

I Built 2 identical H-bridges with LMD18201 chips. Purchased some DC motors I got on eBay, they are "Globe Motors - 12V - PN: 125052" @ about $25 ea.

Hooked H-bridges up to an Atmega8 mcu, connected the motors and everything works well EXCEPT the motors run at slightly different speeds.

I determined that one motor was running slightly faster than the other irrespective of what H-bridge it was hooked up to. I tried just about every different type of PWM configuration possible with the Atmega8, just in case, but one motor was always running faster.

So the question: Do cheaper motors often run at different speeds with an identical PWM source? If cheaper motors do often have these problems what quality level of motor, and possibly what brands, will see motors that can run at identical speed / rpms for identical PWM sources?

Thanks


Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
Re: PWM 2 x DC MOTORS - Different Speeds? Motor Recommendations
« Reply #1 on: March 07, 2010, 09:16:49 AM »
Yes, two "identical" motors (same brand, same model) can have different speed. I don't know if high quality DC motors can be more "accurate", but you might need to have some closed-loop system to regulate the speed. For instance with a rotary encoder on each wheel to determine the actual speed and adjust the pwm value accordingly.

Chelmi

Offline ethoughtTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: PWM 2 x DC MOTORS - Different Speeds? Motor Recommendations
« Reply #2 on: March 07, 2010, 09:52:56 AM »
Thanks - Looks like my first robot is not going to be moving as quickly as I had hoped.

The motors infact have HEDS-5505 encoders on them. Just need to figure out how to use them...

Can this be done using just the H-bridge and the Atmega8 via software or do I need some sort of motion control processors like the LM629?

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,941
  • Helpful? 98
Re: PWM 2 x DC MOTORS - Different Speeds? Motor Recommendations
« Reply #3 on: March 07, 2010, 10:05:41 AM »
Thanks - Looks like my first robot is not going to be moving as quickly as I had hoped.

The motors infact have HEDS-5505 encoders on them. Just need to figure out how to use them...

Can this be done using just the H-bridge and the Atmega8 via software or do I need some sort of motion control processors like the LM629?


Yes, feed the encoder outputs to the Atmega8. Write software to measure the time from one encoder tick to the next (this is the inverse of wheel motor/speed). Then adjust the PWM width to obtain the desired encoder tick time.

I have used this method on a couple of bots and it works very well.

Offline ethoughtTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: PWM 2 x DC MOTORS - Different Speeds? Motor Recommendations
« Reply #4 on: March 08, 2010, 09:57:32 AM »
Hmm - Have figured out how to use basic interrupt functions but a bit lost trying to figure out how to time the tick intervals...

Connected channel A of the encoder to INT1. Figured dont need channel B as I just want to know the rotation speed not direction.

After hours of searching I cannot seem to find any simple examples of how to do this.

Anyone got any example code or suggestions?

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,941
  • Helpful? 98
Re: PWM 2 x DC MOTORS - Different Speeds? Motor Recommendations
« Reply #5 on: March 08, 2010, 01:15:12 PM »
I use a PIC and not the Atmega but both have some common features so the same general algorithm should work.

I set-up a hardware timer that interrupts every 2ms and increments a counter for each wheel.
I run the wheel encoder outputs into a pin the generates an interrupt.
In the encoder ISR the counter from the timer ISR is saved and cleared (so a new count can be collected) and set a flag to indicate a new count is available.

The motor speed PWM period is controlled by a second hardware timer that interrupts every fourth cycle. In this ISR if the new count flag is set the wheel encoder count is compared to the target encoder count (desired wheel speed) and the PWM duty is adjusted and the new count flag is cleared.

Does this help?

 


Get Your Ad Here