Top Banner
ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: [email protected] Office: EN2074
34

ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: [email protected] Office: EN2074.

Dec 28, 2015

Download

Documents

Allison Norris
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

ENGR 6806 – Motor Control

Prepared By: Rob Collett

September 15, 2004

Email: [email protected]

Office: EN2074

Page 2: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Presentation Outline

Introduction Motor Basics H-Bridges Using The PIC for Motor Control Motor Encoders Grounding Conclusions and Recommendations

Page 3: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

1.0 IntroductionWhat Not to Think…

“Our team already has a motor guy… this should be good time to take a nap.”

“Some of this stuff is theory… why is this guy wasting my time with that?”

“I don’t have a clue what he’s talking about.”

Page 4: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

2.0 Motor Basics

Pop Quiz: A motor is like a(n)…A) Resistor

B) Capacitor

C) Inductor

D) Crazy space-aged device we aren’t really meant to

understand

Page 5: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

The Answer Is…(Not D) C) An Inductor!!… sort of…

Page 6: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

The Problem: What’s wrong with the circuit

below?

Page 7: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Well, think about it… An inductor is a short circuit at DC!

This means we’ll have an infinite current! Infinite current = Infinite Speed!!

Page 8: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Get to the Point… A motor is like a REAL inductor…

not an IDEAL inductor.

It has resistance!

Page 9: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Remember this Waveform! Note how the current levels off. This will provide a steady speed.

RL

eR

Vs

R

Vsti

t

)(

Page 10: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

3.0 H-Bridge Basics H-Bridges are used to control the

speed and direction of a motor.

They control the motor using Power Electronics… transistors to be precise.

Remember transistors for Term 4?

Page 11: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

For $1,000,000:What’s a Transistor?

Transistors are electronic devices that can act as either: Amplifiers Switches

We’ll be using them as switches that control the flow of power to the motor.

Page 12: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

A Closer Look at Transistors Note how Digital Logic at the Base

controls Power Flow in the other two ports

Page 13: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Controlling Motor Speed

By turning our transistors (switches) ON and OFF really fast, we change the average voltage seen by the motor.

This technique is called

Pulse-Width Modulation (PWM).

Page 14: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

PWM Basics The higher the voltage seen by the

motor, the higher the speed.

We’ll manipulate the PWM

Duty Cycle.

Page 15: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

The Problem with PWM… Remember our little talk about

motors? Remember that motors are like

inductors? Remember this waveform?

Page 16: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

What’s the Problem? If we switch our transistors too

quickly, the current won’t have enough time to increase.

Page 17: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

The Solution: The period (not to be confused

with duty cycle) of our PWM needs to be long enough for the current to reach an acceptable level:

Page 18: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Direction Control using the H-Bridge

The H-Bridge Chip has a “Direction Pin” that can be set using digital logic High/Low

This pin enables/disables flow through the transistors

Page 19: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

The H-Bridge Chip The H-Bridge we’re using (the

LMD18200) has 11 pins

Some pins involve logic signals, others involve power signals, others won’t be connected

Power signals = No breadboard No breadboard = Soldering

Page 20: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

H-Bridge Pins Pin 1: Bootstrap 1 (10nF cap to Pin 2) Pin 11: Bootstrap 2 (10nF cap to Pin 10) Pin 2: Output to Motor (M+) Pin 3: Direction Input (From PIC) Pin 5: PWM Input (From PIC) Pin 6: Power Supply (Vs) Pin 7: Ground Pin 10: Output to Motor (M-) Pin 4: Brake (Not Used – Connect to GND) Pin 8: Current Sense (Not connected) Pin 9: Thermal Flag (Not connected)

Page 21: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

H-Bridge Wiring (From the Lab Handout)

But wait… There’s something missing!

Page 22: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Another Problem: We’re dealing with a high voltages

and currents that are being switched at high frequencies.

This is going to cause spiking in our power supply… not to mention a whack of noise.

Surely there must be some kind of component that prevents instantaneous changes in voltage.

Page 23: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Of Course! Capacitors!

Capacitors across the H-Bridge power supply will prevent spiking.

Two parallel capacitors are recommended: 200uF 1uf(Be sure to check voltage ratings)

Why two capacitors?

Page 24: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

4.0 Using The PIC for Motor Control

We’ll use the PIC to generate digital logic signals to control our

H-Bridge transistors

So we’ll need A digital high/low for direction

output_high(PIN_A0); A PWM for speed control

Page 25: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Setting the PWM Signal This can be tough because we need

to use a timer to set the PWM frequency.

We also need to figure out how to control the PWM duty cycle.

This is going to take some programming!

Page 26: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Setting up a PWM Signal Step 1:

Tell the PIC we want a PWM signal: setup_ccp1(CCP_PWM);

Step 2:The PIC uses a timer called “Timer2” to control the PWM frequency. We need to set this frequency: setup_timer_2(T2_DIV_BY_X, Y, Z);

But what are X, Y, and Z? - See handout for example.

Page 27: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Setting up a PWM Signal

Step 3: We said before that setting the PWM

Duty Cycle will set the speed of the motor.

So, to start the motor, we could say: set_pwm1_duty(#); (0 < # < 100)

To stop the motor, we could say: set_pwm1_duty(0);

Page 28: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

5.0 Motor Encoders Motor Encoders allow for us to

track how far our robot has travelled.

The encoders count wheel revolutions using optical sensors.

These sensors count notches on the Drive Shaft of the motor.

Page 29: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Some Encoder Details… There are 512 notches on the drive

shaft.

There is a 5.9:1 gear ratio. (This means the drive shaft spins 5.9x faster than the wheel.)

The top wheel speed is around 800rpm (using a 30V supply).

Page 30: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Some Electrical Details…

The encoders we’ll be using have 4 wires: 5V Power Supply (Red) GND (Black) Channel A a.k.a. CHA (Blue) Channel B a.k.a. CHB (Yellow)

Channels A&B will give us the signals to count wheel revolutions.

Page 31: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

How Encoders Work CHA and CHB are actually square

waves separated by 900.

Page 32: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Counting Encoder Cycles So, if we know the current encoder

state and the last encoder state, we can tell which direction we’re going.

By counting the number of times we’ve changed states, we can tell how far we’ve gone.

Just remember that there are 4 encoder states per notch!

Page 33: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

6.0 Grounding Advice What is “Ground”? What is “Ground” on a Robot?

Power Supply Grounds Batteries and Grounding

Use a Grounding Panel! Attach your Panel to your Robot!!

Page 34: ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, 2004 Email: robert@engr.mun.ca Office: EN2074.

Conclusions and Recommendations Help is here if you need it.

[email protected] EN 2074

“My robot isn’t working perfectly.”

Don’t let your robot take years off your life!

Good Luck!