Table of Contents
Motor Control TestingThis page serves to document the procedures taken to setup and configure the motor controls.
Pulse Width ModulationFor more information please see the reference for an Introduction to AVR timers.
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.
- SN754410 - Quadruple Half-H Driver
- Manufacturer's Page
- Pin compatible part (l293) datasheet - schematics reference
- IC Supply Voltage Range: 4.5 - 5.5V
- Motor Supply Voltage Range: 4.5 - 36V
- 1A continuous output current per bridge
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.
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
A tool which came in very handy during the testing of the motor controls was an application, simply named, Terminal. 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.
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.
|2||Blue||Right/Left Magnitude (PWM)|
|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.