CURRENT ISSUE
Contests
Feature Article
|
|
Issue #200 March 2007
Inertial Rolling Robot
by Jeff Bingham & Lee Magnusson
Start | Electronics | Drive Motor | Servo Motor | Pressure Sensor | Software | DC Drive Motor Control | Servo Motor Control | Mechanical Components | Manufacturing | Assembly | Findings | Sources & PDF
SERVO MOTOR CONTROL
The servo motor is controlled by pulse-width encoding at a rate of 50
Hz. The pulse for standard hobby servos ranges between 1 and 2 ms with
1.5 ms corresponding to the neutral position.
Timer W on the H8/3664 microcontroller is set up to overflow at a frequency of 50 Hz, or a 20-ms period. The period in terms of Timer W counts is 49,152. The compare-match register is set up in buffered PWM mode, so the PWM-output signals can be generated without concern for the timing of writing to the compare-match register. The new value will be automatically loaded at the beginning of the PWM cycle, eliminating the chance for making writes at the wrong time and causing erroneous PWM-signals.
In terms of Timer W counts, 1 to 2 ms corresponds to a GRB value ranging from 2,458 to 4,915, with a neutral position of 3,686. Limit checks are included to ensure that the servo is not overdriven.
A/D conversion for the pressure sensor is accomplished in the adc.c file that’s available on the Circuit Cellar FTP site. Only one channel is used (AN0) in order to store the value of the current pressure. The ADC is set up to run in continuous operation, and the current value from the pressure sensor can be read at any time.
|