Design Idea
Code provides adjustable differential drive for robots
Edited by Bill Travis
Alton Harkcom, EGO North America, Newnan, GA -- EDN, 10/16/2003
Intelligently modifying the motor-drive commands to a robot can give you control finesse during competitions. Moving a joystick hard right, for example, might have different effects, depending on the robot's speed and direction. Software running on an inexpensive microcontroller (in this case, an NEC (www.nec.com) PD78F9814) manages this control by calculating separate drive and adjust vectors and then combining the vectors and calculating the appropriate power ratio for two tread motors (Figure 1). This demonstration system uses a simple treaded toy vehicle to show how the ratio-drive concept works and requires no sensors in the vehicle. The microcontroller controls the tread motors with simple forward/reverse signals based on the calculated motor speeds and directions.
Listing 1 shows the main routine for this application. It begins by initializing all the signals and then calibrating them with the joystick at the idle position (MID) and each extreme (LO and HI). The code uses several sets of variables. Drive variables (DriveRaw, DriveHI,
DriveMID, DriveLO, and Drive) specify the combined drive speed for the motors. Ratio variables (RatioRaw, RatioHI, RatioMID, RatioLO, and Ratio) specify the ratio of right-to-left motor balance. Adjust variables (AdjustRaw, AdjustHI, AdjustLO, and Adjust) specify the adjustment value to the ratio value. The adjustment reduces the ratio value to better control left/right balance at particular speeds. Range-conversion variables (RangedUpper, RangedLower, and Ranged) rerange the ADC inputs to the desired 0 to 100% values for the motor speed and direction. After the code calculates the Left and Right motor vectors, another routine uses these vectors to drive the motors. If Right is greater than 1, for example, the drive routine enables a RightForward PWM signal and disables the reverse signal. For experimentation purposes, you can use a 1A quad half-H bridge to route the speed and direction signals to the motors. In actual competitions, you need a heavier duty motor controller because the motor-stall currents can exceed 1A.



