Setting Up A Differential Drive For Your PICAXE Project

The differential drive is a method to give steering capability to vehicles and wheeled robots. The basic principle is to control two drive wheels independently and steer by either stopping or reversing one wheel while continuing to operate the opposite wheel in the forward mode. If the left wheel continues to move forward then the vehicle will turn to the right. If the right wheel continues to move forward then the vehicle will turn to the left.

The circuit described here is based on the PICAXE 18X microcontroller and the SN754410 integrated circuit. The SN754410 is a quad half-H driver that is pin compatible with the L293D described in volume three of the PICAXE manual. It is used here because it is considered an upgrade to the L293D and seems to be more readily available, but either IC would work in this circuit. The chip delivers up to 1 amp continuous current per driver, has thermal shutdown, and good resistance to noise interference. If you are building a small car or robot, this is an ideal solution for small geared motors such as those found in the Tamiya twin motor kits or the Solarbotics GM styles.

The SN754410 is designed for providing switchable, bidirectional drive currents so it is easy to configure a differential drive system. As you can see from the schematic and breadboard diagrams, there are virtually no additional components required. Small DC motors drawing 1 amp or less are connected directly to the IC and the direction of current is controlled by outputs from the PICAXE. The four driver circuits are configured in pairs, with each pair controlling one motor. Referencing the pinout diagram, note that the pairs are on opposite sides of the IC. Drivers 1 and 2 are on pins 1-8 and drivers 3 and 4 are on pins 9-16. Each driver has an input pin A and an output pin Y. Simply put, four outputs from the PICAXE are connected to the four "A" pins on SN754410 while the four "Y" pins connect to the pair of motors making up the differential drive. In the breadboard diagram the circuit ends at the terminals where the motors are connected.

Each driver pair has its own connection to the power supply as well as its own enabling pin. Drivers 1 and 2 are enabled via pin 1 (labeled 1,2EN) while drivers 3 and 4 are enabled via pin 9 (labeled 3,4 EN). What this means, in effect, is that in this circuit the SN754410 has four connections to the positive power supply. Each individual driver has its own ground, so there are an additional four connection to ground.

The motors are controlled by changing the state of the PICAXE output pins. In this example outputs 2, 3, 4 and 5 are used. You can, of course, use any four available outputs and substitute any PICAXE microcontroller for the 18X. Each motor can be in one of three modes - forward, stop, or reverse - depending on the state of the PICAXE outputs. This creates a total of five modes for the differential drive - forward, left, right, stop, and reverse. The following table summarizes the relationship between the PICAXE output pins and the differential drive:

DirectionOut 2Out 3Out 4Out 5
Stop0000
Forward1001
Left101 or 00
Reverse0110
Right01 or 001

There are several notes to be made about the truth table. First both inputs to the same driver are never set high. Note also that some inputs are listed as "1 or 0" - this setting would be determined by whether or not you wish your drive to have the opposite wheel reverse during a turn or simply not run forward. Lastly, because motor polarity and gearing strategies vary, you will need to experiment with the motors you are planning to use for your project to determine the proper connection to the circuit.

Programming support for the differential drive is straightforward. In the following example, the PICAXE BASIC high and low commands are used to run the drive through all the possible modes operating in each mode for two seconds and then stopping for two seconds. The program then loops and will continue until power is removed. Note the 1/10th second pause at the beginning of the program to ensure the SN754410 has time to power-up:


    pause 100     'power-up     

 main:

    high 2        'forward 
    low 3
    low 4
    high 5
    pause 2000    'continue for 2 seconds

    low 2         'stop
    low 3
    low 4
    low 5
    pause 2000

    high 2         'left
    low 3
    high 4
    low 5
    pause 2000    

    low 2         'stop
    low 3
    low 4
    low 5
    pause 2000    

    low 2         'right
    high 3
    low 4
    high 5
    pause 2000    

    low 2         'stop
    low 3
    low 4
    low 5
    pause 2000    

    low 2         'reverse
    high 3
    high 4
    low 5
    pause 2000

    low 2         'stop
    low 3
    low 4
    low 5
    pause 2000    

  goto main




Other Articles You Might Find Enjoyable

Design and Build Your Own Robot

PICAXE USB to Serial Conversion

Introduction to the PICAXE Microcontroller

Adding Memory with i2c EEPROMs

Guide to PICAXE Selection

Basic PICAXE Servo Interfacing

Robot Obstacle Detection and Avoidance with the Devantech SRF05 Ultrasonic Range Finder

Calculating Right Triangles with PICAXE BASIC

Understanding Variables and Symbols in PICAXE BASIC

Flexinol and other Nitinol Muscle Wires

Analog Sensors and the MSP430 Launchpad


Things to Do Here

All PICAXE Articles
Home
Links

Other Places to Go