User Tools

Site Tools


embedded:adventures:driving

Drive Class

Once basic actuation of the motors is possible, the typical next step is to create an interface that abstracts the basic functionality so that you can focus on the use of the motors and not on the low-level parts of commanding them.

Since you've already figured out how to program things so that the motors move, either via RC Servo control or via H-Bridge control, let's start to packaging it up for a robotic vehicle. In Arduino- and maybe Energia-speak this adventure is about writing a library (though more generally it is about creating a class to abstract some functionality). Arduino has some tips on writing libraries. The tips, though not necessarily the coding specifics, should apply to mBed and TI (Energia) too.

Tank-Style Robots

Tank-style robots, also known as Hilare or wheelchair robots, are the most common type of wheeled robot, due to their operational simplicity. It's like the quadcopter of ground vehicles (though, I suppose the proper order would be to say that quadcopters are like the tankbots of aerial vehicles, since quadcopters got popular later; way more popular). For these robots, driving is a matter of specifying either (1) the left and right motor velocities, or (2) the forward speed and the turning rate. Let's focus on the first option for the moment for the drive class.

The basic drive class is defined to have minimal functionality:

  1. constructor with pin specifications.
  2. drive(leftVal, rightVal)
  3. driveLeft(val)
  4. driveRight(val)
  5. stop

RC Servo Control

The sabertooth is a motor controller that takes RC Servo commands and convertes them to a pulse width modulated voltage signal to the motors. It takes away some of the progamming difficulties of an H-Bridge and does that on its own internal chip, leaving the microprocessor programmer to just have to specify an RC output to send to the sabertooth as input. The sabertooth is also quite popular for tele-operated robotics since servo signals are naturally transmitted/relayed to RC vehicles by RC controllers, like those used for commanding cars, helicopters, quadcopters, etc. (the truth a is bit more complex, but you can think of it this simplistically).

Since only RC servo PWM is output, there is a need for one pin per motor to drive. The standard robotic vehicle requires two pins. The constructor should specify these two pins. Call this class tankServo.

H-Bridge Control

Interfacing an H-Bridge is a bit different since both the direction bit and the actual (variable) duty cycle signal need to be provided, per motor. The constructor should specify these four pins. The rest should be the same. Call this class tankBridge.


Main Adventures

embedded/adventures/driving.txt · Last modified: 2023/03/06 10:31 by 127.0.0.1