Sie sind auf Seite 1von 14

Experiment 7

DC MOTOR CONTROL
Name: ____________________________________

Section: ECE41

Professor: ENGR. EMMANUEL T. LONGARES

Date: AUG. 18, 2014

DURATION: 3 Hours
OBJECTIVES:

To interface the PICmicrocontroller to the H-Bridge Type DC Motor control circuit


board.

To drive the 9V DC brush motor in clockwise and in counterclockwise directions


using PICmicrocontroller.

To control the speed of DC motor.

BACKGROUND:

The H-Bridge type of design is an effective way of controlling the direction and
speed of a DC motor.

An H-Bridge is composed of four power transistors and each transistor is usually


represented as a switch, Figure 7.1. The direction of DC motor can be controlled by
switching ON the SW1 and SW4, or SW2 and SW3, for clockwise and counter
clockwise direction, respectively. If SW1 and SW3 are accidentally turned ON, short
circuit will arise. And it has to be prevented. The same thing will happen if SW2 and
SW4 are turned ON simultaneously.

76

SW2

SW1

SW-SPST

SW-SPST

BAT1
12V
DC Supply

+88.8

SW4

SW3

SW-SPST

SW-SPST

Figure 7.1: H-Bridge Circuit


The speed of DC motor depends on the amount of current flowing through the
transistors. And it is based on the amount of biasing voltage applied in power MOSFET
transistors.

MATERIALS/COMPONENTS (Optional):
4 Mhz Crystal Oscillator

- 1 piece

10KOhm resistor (1/4W)

- 1 piece

Tact Switch or Push Button

- 1 piece

MOSFET IRF9530 (P-Channel) - 2 pieces


MOSFET IRF530

(N-Channel) - 2 pieces

100F Electrolytic Capacitor

- 1 piece

2N7000

- 2 pieces

12Vdc Brush Motor

- 1 piece

PIC16F84A

- 1 piece

77

EQUIPMENT:
Computer with installed MPLAB IDE V.8.33
PIC Start Plus Programmer or equivalent
DC Motor Control circuit Board with model no. 2012E7B4(01-10)V1
DC Power Supply
IC Puller

TOOLS:
Breadboard
Connecting Wires

PROCEDURE:
Part 1: Clockwise Direction
a.

Open the MPLAB IDE software. Using the project wizard, choose
PIC16F84A as the device.
Create a folder and name it as Expt_7.1. Use the DC_Motor1 as the

b.

filename for this project. Save and place it to Expt_7.1 folder.


c.

Compile the copied PIC16F84A template using Ctrl F10 of your keyboard.
Make sure that it is working properly before you proceed to the next step.

Type the given source code for H-Bridge dc motor shown below.

d.

;**********************************************************************
;

Filename:

H-Bridge DC Motor Controller_Clockwise.asm

File Version:

;**********************************************************************

78

list

p=16F84A

; list directive to define processor

#include <p16F84a.inc>

; processor specific variable definitions

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC


;**********************************************************************
INT_VAR
UDATA 0x0C
M
RES
1
N
RES
1
;**********************************************************************
RESET_VECTOR

CODE 0x0000

; processor reset vector

goto start

; go to beginning of program

MAIN_PROGRAM CODE
start:
banksel

TRISB

; Bank 1

bcf

TRISB, 0

; PORTB0 set as output

bcf

TRISB,1

; PORTB1 set as output

banksel

PORTB

; Bank 0

bsf

PORTB,0

; Bias both signal transistors, hence,

bsf

PORTB,1

; the voltage across their outputs are zeros.

PORTB,1

; Pulse train for power transistors.

Stop_Motor:

Start_Motor:
bcf
goto $
;-----------------------------------------------------------------------------------------END
; directive 'end of program'
;************************************************************************************************************

e.

Compile and load the code into the PIC16F84A.

79

f.

Construct the H-Bridge DC Motor Controller circuit shown in Figure 7.1 or


use the DC Motor Control circuit Board with model no.
2012E7B4(01-10)V.
VEE

VDD
+

5V

10k

10k

R3
1k

10k

VCC
+

6V

12V

C1
100uF

R2
1k
Q2

P-Channel
Q3

P-Channel

IRF9530

IRF9530
S1
-

Reset
Button

RA0
RA1
RA2
RA3
RA4T0CKI

4
16

MCLR
OSC1CLKIN

VSS

VDD
RB0INT
RB1
RB2
RB3
RB4
RB5
RB6
RB7
OSC2CLKOUT

14
6
7
8
9
10
11
12
13
15

2N7000

+
M

MOTOR

Q5

U1
17
18
1
2
3

2N7000

Q4

N-Channel

Q6
Q1

IRF530N

PIC16F84
X1

N-Channel
IRF530N

HC-49/U_4MHz

Figure 7.1: H-Bridge DC Motor Controller

g.

Check your connections before you power up the circuit. If you are not
sure with your connections, kindly ask assistance from your professor.

h.

Adjust the power supply with the required voltages. Connect one at a time
the probes of power supply to your circuit board. Make sure that you do
not over supply the circuit.
Note: If you notice that the power transistors IRF530 and IRF9530
become hot easily, turn off the power supply immediately. It means that
there is something wrong with the circuit. Check again your connections.
Refer to the specification sheet of IRF530 and IRF9530 to check the pin
assignment of transistors.

i.

In what direction did the motor rotates?


CLOCKWISE DIRECTION.
80

Part 2: Counter Clockwise Direction


a.

In the given source code in Part 1, modify the Start_Motor by changing all
the PORTB, 1 to PORTB, 0.

b.

Load the modified source code to the PIC16F84A.

c.

Repeat procedure b to d of Part 1.

d.

In what direction did the motor rotates?


COUNTERCLOCKWISE DIRECTION.

Part 3: DC Motor Speed Controller


a.

Open the MPLAB IDE software. Using the project wizard, choose
PIC16F84A as the device.

b. Create a folder and name it as Expt_7.2. Use the DC_Motor_Speed as


the filename for this project. Save and place it to Expt_7.2 folder.
c. Compile the copied PIC16F84A template using Ctrl F10 of your keyboard.
Make sure that it is working properly before you proceed to the next step.

Type the given source code for H-Bridge dc motor shown below.

d.

;**********************************************************************
;

Filename:

H-Bridge DC Motor Controller_Clockwise.asm

File Version:

;**********************************************************************
list

p=16F84A

#include <p16F84a.inc>

; list directive to define processor


; processor specific variable definitions
81

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC


;**********************************************************************
INT_VAR
UDATA 0x0C
M
RES
1
N
RES
1
;**********************************************************************
RESET_VECTOR

CODE 0x0000

; processor reset vector

goto start

; go to beginning of program

MAIN_PROGRAM CODE
start:
banksel

TRISB

; Bank 1

bcf

TRISB, 0

; PORTB0 set as output

bcf

TRISB,1

; PORTB1 set as output

banksel

PORTB

; Bank 0

bsf

PORTB,0

; Bias both signal transistors, hence,

bsf

PORTB,1

; the voltage across their outputs are zeros.

bcf

PORTB,1

; Pulse train for power transistors.

call

delay

bsf

PORTB,1

call

delay

goto

Start_Motor

Stop_Motor:

Start_Motor:

;-------------------------------------------------------------------------delay
movlw
movwf

0x0FF
M

; approximately 197msec delay at 1Mhz internal clock


; 1 cycle delay, let us assign this as M=0xFF
; 1 cycle delay

movlw

0x0FF

; 1 cycle delay x M , let us assign this as N=0xFF

D1

82

D2

movwf

; 1 cycle delay x M

decfsz
goto
decfsz
goto
return

N,f
D2
M,f
D1

; 1 cycle delay x N x M
; 2 cycle x N x M
; 1 cycle delay x M
; 2 cycle
delay x M
;2 cycle delay

;-----------------------------------------------------------------------------------------END
; directive 'end of program'
;************************************************************************************************************

e.

Compile and load the code into the PIC16F84A.

f.

Test the source code using the H-Bridge DC Motor Controller circuit shown
in Figure 7.1 or using a DC Motor Control circuit Board with model no.
2012E7B4(01-10)V.

g.

Using an oscilloscope tap the two probes of oscilloscope to the output of


signal transistors. Note, measure it with respect to the ground. Sketch your
measurement on the space provided below.

83

h. What do you observe with the speed of DC motor?


________________________________________________________________
________________________________________________________________
________________________________________________________________

i.

Explain the meaning of the measured waveform.


_____________________________________________________________
_____________________________________________________________
_____________________________________________________________

Part 4: Exercises

a. Develop a source code for this condition: if button in RA3 is pressed, the
motor will rotate in clockwise direction. Write your codes in the space
provided below.
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________

84

b. Develop a source code for this condition: if button in RA4 is pressed the
motor will rotates in counter clockwise direction. Write your codes in the
space provided below.
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________

c. Develop a source code for this condition: if button in RA1 is pressed, the
motor will rotate in counter clockwise direction and once the button in RA0 is
pressed, the motor stops for 2 seconds and starts to rotate again in counter
clockwise direction. Write your codes in the space provided below.
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
85

________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
d. Develop a source code for a 40% full speed of DC motor.
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________

e. Develop a source code for a 70% full speed of DC motor.

________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________
________________________________________________________________

86

SUMMARY:
________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________

CONCLUSION:
________________________________________________________________
______________________________________________________________________
______________________________________________________________________
87

______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
____________________________________________________________________

RECOMMENDATION:
________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
_____________________________________________________________________

REFERENCES:

Mano, M. Digital Design 4th ed. Singapore: Pearson Education, Asia, 2007

88

Bartee, T. Computer Architecture and Logic Design. New Jersey: John Wiley & Sons,
2004

M. Predko, Programming and Customizing PICmicro MICROCONTROLLERS


2nd Edition, McGrawHill Companies Inc., USA, 2002

F. Valdez-Perez and R. Pallas-Areny, Microcontrollers Fundamentals and


Application with PIC, CRC Press, Taylor and Francis Group, USA, 2009

J. Sanches and M. P. Canton, Microcontroller Programming The Microchip


PIC, CRC Press, Taylor and Francis Group, USA, 2007

D.W. Smith, PIC in Practice, Dave Smith, Elsevier Ltd.,UK, 2006

S. R. Ball, Analog interfacing to Embedded Microprocessors : Real World


Design, Newnes, USA, 2001

R.L. Tokheim, Digital Electronics Principles and Applications 6th Edition,


McGraw-Hill Companies Inc. USA, 2003

PIC16F84a Datasheet.pdf

http://www.microchip.com

89

Das könnte Ihnen auch gefallen