| Wirz 203 to BrainStem Example Last Modified: 2007-03-08 | | |
| Acroname Robotics | PDF webpage version | ||
| ![]() BrainStem to Motor Driver to Motor Introduction In this example, a BrainStem GP 1.0 module uses a Wirz 203 motor driver board to turn a motor on and off and switch its polarity.
At power-up, the Stem's digital IO pins are configured as inputs. This means the inputs to the driver board are effectively "floating" or left disconnected. With the inputs left floating, the motor may turn on. Adding pull-down resistors on the inputs will keep this from happening. (The motor driver board does not have them.) The motor will also turn off once the digital IO pins are initialized. The Wirz 203 board can control two motors. Two motors with independent on-off control and direction control can provide locomotion for a simple differential drive robot. Pulse width modulation can be applied to the PWM inputs to control motor speed. Circuit Schematic ![]() BrainStem to Wirz Motor Driver shematic In the above schematic, the PWM input acts as a power switch for the motor. The DIR input acts as a polarity switch or motor direction control. The Wirz 203 uses a 754410 dual h-bridge chip. Normally, a user must control two h-bridge control lines and an additional enable line to control one motor. The Wirz 203 has some extra "glue logic" to convert the two control lines into a single DIR input. Toggling the DIR input changes the motor direction. Turning the PWM input on and off turns the motor on and off. Source Code The following program turns a motor on and off several times and changes its direction. It makes several calls to a subroutine that applies the direction input, turns the motor on for a short amount of time, then turns off the motor. The program uses the TEA language which is a subset of ANSI C. It is compiled using the BrainStem Console by entering the steep command. It may be downloaded to the BrainStem and executed using load and launch commands. This program uses standard TEA libraries. /* filename: wirz203.tea */
#include <aCore.tea>
#include <aDig.tea>
#define PWM 0
#define DIR 1
#define PWM_ON 1
#define PWM_OFF 0
#define FORWARD 0
#define REVERSE 1
/* apply direction */
/* spin motor for up to 6.5535 seconds */
/* turn motor off */
/* give motor time to stop */
void go(char dir, int time)
{
aDig_Write(DIR, dir);
aDig_Write(PWM, PWM_ON);
aCore_Sleep(time);
aDig_Write(PWM, PWM_OFF);
aCore_Sleep(500);
}
void main()
{
int i;
aDig_Config(PWM, ADIG_OUTPUT);
aDig_Config(DIR, ADIG_OUTPUT);
/* brief delay before starting */
aCore_Sleep(30000);
for (i = 0; i < 4; i++)
{
go(REVERSE, 20000);
go(FORWARD, 20000);
}
}
Revision History:
| ||||||
Related Links: | |||||||
| voice: 720-564-0373, email: sales@acroname.com, address: 4822 Sterling Dr., Boulder CO, 80301-2350, privacy © Copyright 1994-2010 Acroname, Inc., Boulder, Colorado. All rights reserved. |