PC/CP320 Physical Computing
Raspberry Pi Servo Motors and Stepper Motors
Overview
Servo motors and stepper motors are common.
Objectives
- To introduce control of servo motors with the Raspberry Pi
- To introduce control of stepper motors with the Raspberry Pi
Background
The Raspberry Pi has a PWM output built-in which can help with
servo motor control.
Preparation
Equipment
- Raspberry Pi
- TTL-serial cable
- Servo motor
- Stepper motor with controller board
Procedure
|
Use the optoisolators for the motor signals.
This will adjust voltages and protect against EMFs.
|
-
Servo motor
Robot's Servo Drive Motors
Introduction to Servos
The Futaba S3003 servos have been modified to run in continuous mode
or free running mode. The servo has three wires,
- red - power 4 to 6 V DC
- black - ground
- white or yellow - signal wire
To drive the motors, a pulse width modulated signal must be sent every
20ms. The width of the pulse will indicate direction and speed:
- pulse width of 0ms, i.e. no pulse -- the motor will stop
- pulse width <1.5ms -- the motor will continuously rotate in one
direction (clockwise)
- pulse width = 1.5ms -- the motor is in neutral or dead zone
- pulse width > 1.5ms -- the motor will continuously rotate in the
other direction (counter clockwise)
- the drive signal is proportional, so the farther it is from the neutral
position, the greater the speed
- NOTE: neutral is approximately at 1.5ms, you must calibrate to get
effective speed control
Suggestions for Investigation and Calibration
of Servo Motors
- Use the PWM GPIO pin; it will make your life easier.
Develop a program to find the neutral or dead zone of one
servo motor; do not assume that they are all the same. The
neutral zone
will be approximately 1.5ms and the motor will stop moving in
the neutral
zone. Send a pulse every 20ms; note that the period
is always 20ms.
The program should have a starting pulse width and some
mechanism for
increasing/decreasing the pulse width.
For the pulse width you will need a resolution
of at least 0.01ms to find the dead zone; for example, neutral may
be at 1.53ms not 1.50ms.
- Remember, the closer you are to neutral, the slower the speed of
the motor. The farther you are away from neutral,
the faster the speed
of the motor.
Determine the duty cycles that give each of the following:
- the dead zone
- full speed in one direction
- full speed in the other direction
- about half speed in both directions
Demonstrate your circuit to the lab supervisor.
-
Stepper motor
See the Raspberry Pi Wiki output examples about output to
several channels at once.
Use half-stepping.
Demonstrate your circuit to the lab supervisor.
Wilfrid Laurier University
© 2019 Wilfrid Laurier University