P08027: Wireless Assistive Control System
/public/References/Robot/

motorControls

Table of Contents

Motor Control Testing

This page serves to document the procedures taken to setup and configure the motor controls.

Pulse Width Modulation

For more information please see the reference for an Introduction to AVR timers.[1]

Pulse width modulation (PWM) is used in this project to control the speed at which the motors are driven (for forward and reverse motions) and the direction of travel (for left and right motions). Pulse width modulation, as the name implies, varies the width of a square wave. In effect a square wave is produced which has a variable duty cycle (on time/period). In this application the modulated signal is used to produce an analog voltage which can be used to control the speed at which the motors turn. By lowering the duty cycle, a lower analog voltage may be produced, and by increasing the duty cycle, a higher voltage potential may be produced.

The motor controls utilize the microprocessor's 16 bit timer in phase and frequency correct PWM mode. Additionally the hardware is configured to automatically toggle the outputs of external I/O pins. This alleviates the need to perform such actions in software. The output voltage range of these pins is 0 to 5V. This signal is used to control a transistor which toggles the supply voltage (7.2V) to the H Bridges.

H Bridge

public/References/Robot/SN754410.jpg

Component Information

Initial Configuration

Initial Circuit Layout

Initial Circuit Layout

Truth Table

Truth Table

The first circuit configuration to be tested using the SN754410 followed closely from the pin compatible component's, L293, datasheet. This particular circuit allows for PWM control through the EN pin. The directional output signal from the microprocessor was fed directly to the 1A pin, as well as to the 2A pin (through an inverter). This sample circuit did control the motors, allowing for bidirectional motion.

The drawback to this configuration is that when the PWM signal is low, the hbridge forces the motors into a fast stop, or braking, mode. Since the PWM switches level quite frequently this resulted in the motors producing a significant amount of noise while the PWM's duty cycle was approaching or less than 50% duty cycle. Considerable noise was heard when the steering motor was connected to this circuit.

Note that in this configuration each IC could control two independent bidirectional motors as only two of the chip's four drivers are used per motor.

Alternative Configuration

Subsequently an alternative circuit layout was designed and tested to alleviate the noise and jerkyness of the motors being controlled in the configuration outlined above. It was necessary to prevent the motors from going into a hard brake mode unless this was explicitly desired.

The resulting design uses the PWM signal to switch the motor voltage supply (VCC2) going into the hbridge IC. Since the IC itself uses a separate power supply, the polarity of the output signal from the hbridge is preserved while VCC2 is low. Therefore when the PWM signal is low, the motor enters a free spin mode in which the potential across it is zero. When the PWM signal swings high again VCC2 drives the motor.

Note that since the PWM signal is directly driving the hbridge's motor voltage rail (VCC2), it is no longer possible for each IC to drive two motors independently. A separate hbridge IC will be required for each motor.

Testing / Results

Input: 0x00 0xFF

Input: 0x00 0xFF

Input: 0xFF 0x00

Input: 0xFF 0x00

Input: 0xF0 0x0F

Input: 0xF0 0x0F

Input: 0x70 0x8F

Input: 0x70 0x8F

Input: 0x0F 0xF0

Input: 0x0F 0xF0

Input: 0x07 0xF8

Input: 0x07 0xF8

Input: 0xC0 0x3F

Input: 0xC0 0x3F

Input: 0x40 0xBF

Input: 0x40 0xBF

Input: 0x0C 0xF3

Input: 0x0C 0xF3

Input: 0x04 0xFB

Input: 0x04 0xFB

A tool which came in very handy during the testing of the motor controls was an application, simply named, Terminal.[2] This application was used extensively to produce binary output data for use in testing the microprocessor was correctly interpreting the packetized data. Additionally a good ASCII table is also a good reference.[3]

A particularly nice feature of Terminal is its ability to transmit raw binary or hexidecimal data at any custom baud rate. These two features were used to produce the following test results to debug the motor controls.

The oscilloscope data shown to the right is probed from the vehicles motor control pins. The channel information is outlined in the table below.

Channel Color Signal
1 Orange Right/Left Direction
2 Blue Right/Left Magnitude (PWM)
3 Purple Forward/Reverse Direction
4 Green Forward/Reverse Magnitude (PWM)

Each respective image subtitle indicates the data transmitted to the vehicle wirelessly. For example, the first image's subtitle ("0x00 0xFF") indicates that a packet was sent to the vehicle, 0x00 = 0b00000000, this indicates that the magnitude and direction pins of both motors should be set low. Following the transmission of the first packet, a second packet was transmitted (the compliment of the data packet), 0xFF = 0b11111111, to provide error checking and neutral disparity of the transmitted data.

The tests performed cover the range of capabilities of the vehicles motor controls, and indicate that the link from wireless reception to motor control outputs is operating as expected.

References

  1. AVR Timers Guide
  2. Terminal - simple serial port terminal emulation program
  3. ASCII Table