Transcript Day 6

PHY 235 Robotics Workshop
Day 6
DC Motors, H-Bridge Board,
Simple Lego/Boe Bot
Robotics Motors - Servos
• So far we have used servos to propel our robots.
• Advantages:
• High torque
• Feedback and gearing built in
• Direction and speed controlled by
simple pulse command.
• Disadvantages:
• Limited speed
• Not easily integrated with Lego structures
Robotics Motors – Simple DC
• So far we have used servos to propel our robots.
• Advantages:
• Simple to use – two wires
• There is a Lego DC motor
• Direction and speed directly related to voltage
• Disadvantages:
• Requires gearing and feedback
• Not as easy to precisely control
speed, as compared to servos
DC Motors
Brushes
When the coil is powered, a magnetic field is generated causing the
coil to be pushed away from the left magnet and drawn towards the
right. The charge is reversed when the coil becomes horizontally
aligned and the process continues with the coil spinning.
DC Motor:
Brush Motors
DC Motors
Stator (permanent magnets)
Brushes
DC Motors - Demo
• The instructor will demo a “dissected” DC
motor and also show how the motor is
powered by a simple DC voltage source.
• Note that the motor reverses direction when
the polarity of the voltage source is changed.
DC Motors and ZX-24a Control
• We will be using a Lego DC motor to control the Lego
Robot we will build for the RoboPong contest.
• To control this DC motor, we need a way of
controlling the power to the motor by using the ZX24a I/O pins (output = 0 or 1 (0V-5V)).
• One idea: Just send a 1 (=5 volts) value on an I\O pin
connected to the motor.
• Problem: DC motors consume a lot of current
(~amps) – the I\O pins can output only a small
amount of current (~millamps)
H-Bridge
• Solution: Use an H-Bridge control circuit. In its
simplest form, this circuit can be
built with 4 switches, as shown:
• SW1 and SW4 on will cause the
motor to turn one direction
• SW2 and SW3 on will cause the
motor to turn the other direction
H-Bridge using Relays
• Relays are switches
which can be turned
on by small signals.
Here we have 4
inputs: A, B, C, D.
The table shows how
the choice of signals
controls the motors.
H-Bridge using Transistors
+9 V
+9 V
R4
1 k
A
E
B
Q4
2907A
(PNP)
D2
1N5817
(Schottky)
D4
1N5817
(Schottky)
R2
1 k
E
B
B
C
C
Q2
2907A
(PNP)
M
R3
1 k
C
Q3
2222A
(NPN)
C
B
D3
1N5817
(Schottky)
M1
DC Brush
D1
1N5817
(Schottky)
E
C
Q1
2222A
(NPN)
B
R1
1 k
E
A=0, C=0 , B=1, D=1 -> Red Flow
A=1, C=1, B=0, D=0 -> Green Flow
Taken from Intermediate Robot Building by David Cook
D
H-Bridge Simplified
• Note that we can simplify the control of this circuit if we use
one signal to set A,C and another signal to set B, D. Thus, we
can use inputs AA and BB.
• AA=0, BB=1 Motor turns one direction
• AA=1, BB=0 Motor turns other direction
+9 V
+9 V
E
E
C
C
B
B
AA
BB
M
B
C
E
M1
DC Brush
C
B
E
Taken from Intermediate Robot Building by David Cook
SN 754410 H-Bridge Chip
+5 VDD
220 F
Disconnected or
VDD
from microcontroller
From microcontroller
+4.5 to +36 VDC
M
ENABLE A&B
2
INPUT A
3
OUTPUT A
4
GND
5
GND
OUT B
6
OUTPUT B
from
microcontroller
7
INPUT B
V Motor
8
VMOTOR
220 F
SN754410
M1
DC Brush
1
VLOGIC
16
INPUT C
15
OUTPUT C
14
GND
13
0.1 F
From microcontroller
M
M2
DC Brush
GND
12
OUTPUT D
11
INPUT D
10
From microcontroller
9
Disconnected
or
VDD
from microcontroller
ENABLE C&D
0.1 F
Taken from Intermediate Robot Building by David
Cook
SN 754410 H-Bridge Chip
• We will use this chip to enable the ZX-24a to control
two Lego DC motors.
• These are the motors we will
use for the RoboPong
competition.
• We will build a circuit board that will implement the
connections on the previous slide. The board will
follow the schematic on the next slide.
Motor Controller
Motor Controller
• We will construct this circuit on a small circuit board.
• The parts for this board will be distributed by the
instructor. He will explain the construction details.
Motor Controller
• To test out the board, we will connect the CPU I/O
connections (ZX-24a I/O 4-pin header) to Pins P0, P1,
P2, and P3 on the Boe-Bot. The two Lego motors
should be connected to the motor out 4-pin header.
• The two-pin headers should be connected to Vdd
and ground. Make sure the polarity is correct.
• Your instructor will show you a Boe-bot with all of
the connections.
• To test out the motors, we can use the code on the
next slide.
Motor Controller
const p0 as byte = 5
const p1 as byte = 6
const p2 as byte = 7
const p3 as byte = 8
Sub Main()
do
' Motors rotate one direction
call putpin(p0, 1)
call putpin(p1, 0)
call putpin(p2, 1)
call putpin(p3, 0)
call delay(0.5)
' Motors rotate the other direction
call putpin(p0, 0)
call putpin(p1, 1)
call putpin(p2, 0)
call putpin(p3, 1)
call delay(0.5)
loop
End Sub
Simple Lego Bot
• For the rest of today, your team task is to create a
basic (simple) Lego vehicle using the two Lego
Motors and controlled by the ZX-24a board and
batteries.
• You should unscrew the board and battery pack from
the metal Boe-bot chassis and construct your Lego
bot so that it has a place for the green BOE board
and battery pack to be situated.
• Then, re-implement some of your basic navigation
routines (forward, back, etc) using the Lego motors.