Projects‎ > ‎

Mobile Robot Motor Drive

This design is for the drive train of a mobile robot that uses two dc motors for propulsion and is intended to demonstrate how speed control is achieved with pulse width modulation (pwm).   The L293 motor controller is old and becomming more difficult to source so using the SN754410 chip that has snubbing diodes included is a good alternative.

Main Components

  Micro-controller        mega8A
  Motors                      35:1 Metal Gearmotor
  Wheels                     Wheel 60x8mm
  Motor controller        L293 Quad Half-H Driver


This design aims for a top speed of 100 cm per second, with pwm this will be far lower.

The power supply is a 9 volt transistor battery or suitable alternative.  If you find that a transistor battery does not have enough power, try using six AAA or AA cells, it will depend on the current drawn by your motors.  The battery voltage is reduced to 3.3 volts for the logic by a linear regulator and to 4.5 volts for the motors by pwm fed to the motor controller chip L293.  To ensure the motors are not burned out, please remember to check that the pwm voltage output is suitable for your motors.  If the pwm duty cycle is set too high it will pull down the battery voltage below the dropout voltage of the 3.3 volt regulator causing the microcontroller to lose power.  This will also happen if your pwm frequency is way too low.  If you set the pwm registers OCR1A  or OCR1B to any number higher than their valid range there will be no output from the pwm pins DDB1 or DDB2.  The maximum is 255, 511 or 1023 depending on the number of bits chosen for the pwm registers.

The L293 is has a maximum operation frequency of 5 kHz so set the pwm to around 2 kHz and use fast recovery diodes for snubbing the motors inductance spikes. 

Programming

A hex file is available below to test your circuit, load it with AVRdude after first setting the mega8 fuse bits.

Compile and link the code into an object file

avr-gcc -mmcu=atmega8 -Os mobile-robot-motor-drive-2011-01-10.c -o mobile-robot-motor-drive-2011-01-10.o

Convert the object file into a hex file

avr-objcopy -j .text -j .data -O ihex  mobile-robot-motor-drive-2011-01-10.o  mobile-robot-motor-drive-2011-01-10.hex

Setting fuse bits with AVRdude for a 4.0 Mz internal oscillator

  avrdude -c usbasp -p m8 -U lfuse:w:0xE3:m

Program the microcontroller with this command

  avrdude -c usbasp -p m8 -U flash:w:mobile-robot-motor-drive-2011-01-10.hex
Subpages (2): Parts List Schematics
ċ
mobile-robot-motor-drive-2011-01-10.c
(5k)
Tom Broadhurst,
9 Jan 2011, 19:14
ċ
mobile-robot-motor-drive-2011-01-10.hex
(1k)
Tom Broadhurst,
11 May 2012, 00:34
Ċ
Tom Broadhurst,
11 May 2012, 00:32
Comments