circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

May 2004, Issue 166

Embedded Java Controllers


by D. Jay Newman

MOTOR CONTROLLER PROJECT

Now I’ll describe a simple motor controller that uses the I/O pins of the JStamp/JStik and controls four servomotors. Because my application (my robot, Zeppo) uses servos converted for continuous rotation, I don’t need a lot of resolution in my motor control.

The full open-source robotics framework is posted at http://enerd.ws/robots/code/. The code for the motor controller is taken directly from this framework. I must warn you that the framework is constantly evolving, so the code on the site may be more recent than the code associated with this article.

An R/C servo motor (because I’m on a first-name basis, I call it just a "servo") is a standard DC electric motor with a bit of electronics added. The electronics are designed to take pulses generated by an R/C receiver and convert them into a position. Normally, the pulses control the position of the motor to an angle of ±90°. However, I use servos that have been modified for continuous rotation (converted servos).

A standard servo will be at 0° or no rotation with a pulse of 1.5-ms duration. Positive rotation is achieved with a pulse duration of more than 1.5 ms. Negative rotation is achieved with a pulse duration of less than 1.5 ms. The typical servo accepts pulses between 1 and 2 ms. I found that some converted servos will take pulses between 0.5 and 2.5 ms. For best results, the pulses should be repeated every 20 ms (see Figure 2).

Figure 2—This is roughly what the pulses should look like. My program divides time into 0.10-ms intervals called "ticks."

 

Many Circuit Cellar authors talk about their hardware first. I’ve waited until now because the circuit is ridiculously simple (see Figure 3). I built it on a SimmStick prototyping board from Dontronics. It is a sea-of-holes board.

Figure 3—This is about as simple as possible for a schematic. I just connected all the pins of the first header to ground, servo power to the pins of the next header, and the four I/O pins to the third header.

 

Because servos expect male headers in groups of three, I used three eight-pin male headers. Power goes along one row, ground the next, and the signals go on the third. I’m only using four signals at this time, even though I have eight headers on the board (see Photo 3).

Photo 3—My latest prototype was built with point-to-point soldering. It also includes an eight-channel ADC that is controlled by SPI, but that’s a subject for another time.