Hardware Reference
In-Depth Information
The signal frequency is xxxxxx Hz.
Crank up the frequency until the measurement becomes inaccurate. What is the highest fre-
quency that you can measure?
L8.2 Pulse-width measurement . Use the input-capture function to measure the pulse width.
The procedure is as follows:
Step 1
Set the function generator output to be square wave and adjust the output to between 0
and 5 V. Connect the signal to the PAI (PT7) pin.
Step 2
Connect the signal to an oscilloscope or a frequency counter to verify your measurement.
Step 3
Output the message “Do you want to continue to measure the pulse width? (y/n)”.
Step 4
Set up the appropriate period (frequency) of the signal to be measured and enter y or n to
inform the microcontroller if you want to continue the measurement.
Step 5
Your program would read in the answer from the user. If the character read in is n, then
stop. If the answer is y, then repeat the measurement. If the character is something else,
then repeat the same question.
Step 6
Perform the measurement and display the period in
s in decimal format on the screen
and go back to step 3. Use as many digits as necessary. The output format should look like
The signal period is xxxxxx microseconds.
Crank up the frequency until the measurement becomes inaccurate. What is the shortest period
that you can measure?
L8.3 Driving the DC motor and servomotor using the PWM module
Motor kits used
A cooling fan with DC motor (D24-B10A-04W4-000 from Globe motors) (shown in
Figure L8.3a)
A hobby servo-motor HS-311 made by Hitec (shown in Figure L8.3b)
A servo is a small device that incorporates a three-wire DC motor, a gear train, a potentiometer,
an integrated circuit, and an output shaft bearing. The shaft of the servomotor can be positioned
to specifi c angular positions by sending coded signals. As long as the coded signal exists on the
input line, the servomotor will maintain the angular position of the shaft. If the coded signal
changes, then the angular position of the shaft changes.
A common use of servomotors is in radio-controlled models like cars, airplanes, robots, and
puppets. They are also used in powerful heavy-duty sailboats. Servos come in different sizes
but use similar control schemes and are extremely useful in robotics. The motors are small and
extremely powerful for their size. They also draw power proportional to the mechanical load. A
lightly loaded servo, therefore, doesn't consume much energy.
A typical servo looks like a rectangular box with a motor shaft coming out of one end and
a connector with three wires out of the other end. The three wires are the power, control, and
ground. Servos work with voltages between 4 and 6 V. The control line is used to position the
servo. Inexpensive servos have plastic gears, and more expensive servos have metal gears which
are much more rugged but wear faster.
μ
 
Search WWH ::




Custom Search