Sie sind auf Seite 1von 36

Electronic Engineering Laboratory IV

BEE31101
Instruction Sheet

Lab No. 6
Lab Title 6A. DC Motor Control
6B. Servo Motor Control
Semester 02
Session 2016/17
Lab Durations 4 Hours
Independent Studies 2 Hours
Electronic Engineering Laboratory IV (BEE31101) ii
Lab 6

Table of Contents

1.0 Outcomes A

2.0 Guidelines A

3.0 Procedures B

Overview of Lab 6A B

Overview of Lab 6B F

4.0 Lab Activity H

Lab 6A: DC Motor Control H

Lab Activity 1 H

Lab Activity 2 K

Lab 6B: Servo Motor Control L

Lab Activity 3 L

Pre-Lab 1

Questions 4

Lab Activity 8

Lab Activity 2 8

Lab Activity 3 12

Observations 14

Lab Activity 1 14

Lab Activity 2 14

Lab Activity 3 15

Conclusion 17

References 18

Grading Rubric for Written Reports 19

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) A


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

1.0 Outcomes

After completing this module, students should be able to:


1. Relate the appropriate assembly language for applications related to dc motor. (C3, PS)
2. Create and apply basic concept of servo motor control. (C3, PS)
3. Organize time management in group effectively according task given. (P5, TS)
4. Adapt the current cache memory technology with etiquette. (A4, ET)

2.0 Guidelines

1. Grouping: Lab group is not predetermine and consists with at most two team members.
2. Pre-Lab: Must be submitted to the instructor at the beginning of lab sessions. Verified by the
instructor and returned to the students at the end of lab session. The verified pre-lab will be
attached with the final report for submission.
3. Lab Activities: All lab activities such as sample code, examples and lab assignments must
be held in the respective lab location and completed within the given times.
4. Demonstration: Student must demonstrate the successful sample code, examples and lab
assignments to the respective instructor. Verification only will be given upon completion of all
lab activities and initialized by the instructor on the cover page.
5. Report Organization: Report must be organized according to given report template. All
source codes, schematic diagram, graphs and related materials must be printed and attached
as appendices.
6. Include reference used. Use the following format for references. References section should
be placed after conclusion section.
Book reference format and example:
Author, Books title. Edition, Location: Publisher, Year Published.
Gregory L. Moses, Digital Systems Lab Manual: A Design Approach. 11th ed., Wiley,
2010
Online reference format and example:
Author, Webs title. Retrieved at websites address on date accessed.
Digital Systems Design. Retrieved at http://www.wiley.com/gregory on September 2012
7. Report Submission: Report must be received by respective technical staff (at respective
lab) before consecutive lab session.

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) B


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

3.0 Procedures

Overview of Lab 6A

A. Pulse width modulation (PWM) Overview

CCP module in PIC16F877A has a 16-bit register which can operate as 16-bit capture register (in
Capture Mode), or 16-bit compare register (in Compare Mode), or 16-bit PWM duty cycle register.
There is no 16-bit register in 16F877 since the microcontroller is an 8-bit processor. Therefore, two
8-bit register are used to form a 16-bit register: CCPR1H and CCPR1L for upper and lower byte of
the 16-bit register for CCP1 module and CCPR2H and CCPR2L for CCP2 module.
CCP modules are controlled by CCP control registers: CCP1CON for CCP1, and CCP2CON
for CCP2. The details of CCP1CON register is illustrated in Figure 1. As seen in the figure,
CCPM3:CCPM0 determine the three modes in CCP module. DCB1:DCB0 are used only for PWM,
which define the last two LSBs for 10-bit PWM duty cycle. *The next discussion is focused on
CCP1 module only, the same procedures can be applied on CCP2 module.

Figure 1: CCP1CON Register

In PWM mode, the CCP1 pin of 16F877 produces up to a 10-bit resolution PWM output. Since
the CCP1 pin is multiplexed with the PORTC data latch, the corresponding TRISC bit must be
cleared to make the CCP1 pin an output. A PWM output has a time-base (i.e., pulse period) and a
time that the output stays high (i.e., duty cycle). The frequency of the PWM is the inverse of the
period (1/period). The PWM period is specified by writing to the PR2 register. PWM period in
second, Tpwm, is determined by the following formula:
2 1 4 2
where TMR2ps is the TMR2 pre-scale value, and Tosc is the oscillation period.

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) C


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Since one instruction takes four oscillation periods, we have the term 4Tosc. Also, since the PR2
register content will increase by 1 every instruction cycle, we have the term [PR2] +1. Again, the
pre-scale further increase the number of actual oscillation cycles to the 4Tosc multiplied by the
pre-scaler of TMR2, we have the term TMR2ps. All together, we have the PWM period.

When TMR2 is equal to PR2, the following three events occur on the next increment cycle:
i. TMR2 is cleared
ii. The CCP1 pin is set (exception: if PWM duty cycle = 0%, the CCP1 pin will not be set)
iii. The PWM duty cycle is latched from CCPR1L into CCPR1H

The PWM duty cycle is specified by writing to the CCPR1L register and to the DCB1:DCB0
(CCP1CON<5:4>) bits. The CCPR1L contains the eight MSbs and CCP1CON<5:4> contains the
two LSbs. This 10-bit value is represented by DCB9:DCB0 in the equation below. The PWM duty
cycle in second, Dpwm, is given by the following formula:`
9: 0
where [DB9:DB0] is the 10-bit value which comes from CCPR1L<7:0> for eight MSBs
concatenated by CCP1CON<5:4> for two LSbs.

The DCB9:DCB0 bits can be written to at any time, but the duty cycle value is not latched into
CCPR1H until after a match between PR2 and TMR2 occurs (which is the end of the current
period). In PWM mode, CCPR1H is a read-only register. The CCPR1H register and a 2-bit internal
latch are used to double buffer the PWM duty cycle. This double buffering is essential for glitch-
less PWM operation. When CCPR1H and 2-bit latch match the value of TMR2 concatenated with
the internal 2-bit Q clock (or two bits of the TMR2 pre-scaler), the CCP1 pin is cleared. This is the
end of the duty cycle.

Duty Cycle = TMR2


Period = PR2 + 1

TMR2 = PR2 +1
TMR2 forced to 0h
TMR2 = PR2 +1
TMR2 forced to 0h

Figure 2: Duty Cycle and period

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) D


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Let's consider the maximum PWM resolution, Rpwm. This is to decide how small a duty cycle
can be determined. First consider the period of PWM, Tpwm, with relation with the period of the
oscillator clock, Tosc. We have to know that the period of PWM is determined a multiple of the
period of oscillation. In other words, in a PWM period there must be n number of the oscillation
period: Tpwm = n.Tosc . By the way, the resolution in bits for a number n is determined by the power
of 2 of the number n. (Remember that, in ADC, the 10-bit resolution has the value in the range of
1 1024 or 20 - 210. In other words, the resolution in bits is the power of 2 for the maximum value
it can provide.)

Therefore, the above equation can be changed to: 2 . , where Rpwm is the
maximum PWM resolution in bits. Therefore, the equation for Rpwm can be rewritten as:

log 2
This equation can be further altered in terms of frequencies of PWM and oscillation:

log 2

Let's have an example. Assuming that the desired PWM frequency is 78.125kHz (i.e., PWM
period of 12.8s) with oscillation speed of 20MHz, and TMR2 prescale is 1. First thing we have to
find is the content of PR2 register.
From the PWM period equation, 2 1 4 2 , we can draw an
equation for [PR2], the content for PR2 register:

2 1
4 . 2
Since, Tpwm = 12.8s, Tosc = 1/20MHz = 0.05s, and TMR2ps = 1 (since prescale is set to 1)
12.8
2 1 64 1 63
4 0.05 1

Let's calculate the maximum resolution we get from PWM duty cycle under the example case.
From the maximum resolution equation,
12.8
8
0.05

So the maximum resolution of the PWM duty cycle in the example is 8. What does this mean?
What maximum resolution being 8 means that, simply put, the 10-bit PWM values determined by
DCB9:DCB0 is less than or equal to 28. In other words, even though PWM duty cycle can get you
maximum 10-bit resolution, it does not mean that it provides you with 10-bit resolution every time.

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) E


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

In the example case, it provides only 8-bit resolution. In analogy to PWM, for a given pulse period,
to have 8-bit resolution is to have a total number of 256 division scales in the pulse period. In our
example, the pulse period is 12.8s, therefore the each scale is 0.05s. In other words, there is no
way to reduce the scale to, for example, 12.8/512 =0.025s, since this scale is close to 1
instruction execution time. Duty cycle is simple the multiple of the minimum scale.

In other words, any value in DCB9:DCB0 greater than 255, would be regarded as if the same
as 255. In order to achieve higher resolution, the PWM frequency must be decreased. Or, in order
to achieve higher PWM frequency, the resolution must be decreased. The following table lists
example PWM frequencies and resolutions for fosc = 20 MHz. The TMR2 prescaler and PR2 values
are also shown.
Table 1: TMR2 Prescaler
PWM frequency 1.22kHz 4.88 kHz 19.53 kHz 78.12 kHz 156.3 kHz 208.3 kHz
TMR2 prescaler 16 4 1 1 1 1
[PR2] value FFh FFh FFh 3Fh 1Fh 17h
Maximum 10 10 10 8 7 5.5
Resolution [bits]

Now let's further discuss about the PWM duty cycle formula with the given example. Assume that
we want to have a 50% duty cycle, on for the half the pulse period and off for the rest of the pulse
period. From the PWM duty cycle equation, 9: 0
(note that the duty cycle is given with [sec] not in[%]), we get the equation for [DB9:DB0]:

9: 0
.
Since 50% of the PWM pulse period is (0.5)*(12.8s) = 6.4s, and with Tosc = 0.05s and TMR2ps=
1, we get
6.4
9: 0 128 0 80 0010000000
0.05 1
In practice, B'0010000' (or 0x20 as the upper 8 digits) is written to CCP1L register, and the
last two digits 00 to DCB1:DCB0 bits (CCP1CON<5:4>). If we follow all these steps, the pin
CCP1 would generate +5V pulse with its period 12.8s with on-period of 6.4s and off period
6.4s.

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) F


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Overview of Lab 6B

B. Operations of Servo Motor

Servos are controlled by sending an electrical pulse of variable width, or pulse width modulation
(PWM), through the control wire. There is a minimum pulse, a maximum pulse, and a repetition
rate. A servo motor can usually only turn 90 degrees in either direction for a total of 180 degree
movement. The motor's neutral position is defined as the position where the servo has the same
amount of potential rotation in the both the clockwise or counter-clockwise direction. The PWM
sent to the motor determines position of the shaft, and based on the duration of the pulse sent
via the control wire; the rotor will turn to the desired position. The servo motor expects to see a
pulse every 20 milliseconds (ms) and the length of the pulse will determine how far the motor
turns. For example, a 1.5ms pulse will make the motor turn to the 90-degree position. Shorter
than 1.5ms moves it to 0 degrees, and any longer than 1.5ms will turn the servo to 180 degrees.

Figure 3: PWM Pulse respective to servo rotation

When these servos are commanded to move, they will move to the position and hold that
position. If an external force pushes against the servo while the servo is holding a position, the
servo will resist from moving out of that position. The maximum amount of force the servo can
exert is called the torque rating of the servo. Servos will not hold their position forever though; the
position pulse must be repeated to instruct the servo to stay in position.

This pulse corresponds to a servo position, usually from 0 to 180 degrees.


5V for 500 microseconds = 0.5 milliseconds and corresponds to 0 degrees
5V for 1500 microseconds = 1.5 milliseconds and correspond to 90 degrees
5V for 2000 microseconds = 2.0 milliseconds and corresponds to 180 degrees

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) G


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

The relationship is linear, so use mathematics to determine the pulse which corresponds to a
given angle. Note that if you send a signal that is greater or lower than the servo can accept, you
might damage the actuator.

Servos are extremely useful in robotic application. The motors are small, and have built with a
motor, control circuitry, a set of gears, and the case, and are extremely powerful for their size. A
standard servo has 42 oz/inches of torque, which is pretty strong for its size. It also draws power
proportional to the mechanical load. A lightly loaded servo, therefore, doesn't consume much
energy. There are 3 wires in it: power, ground, and control. The amount of power applied to the
motor is proportional to the distance it needs to travel. So, if the shaft needs to turn a large
distance, the motor will run at full speed. If it needs to turn only a small amount, the motor will run
at a slower speed.

The control wire is used to communicate the angle. The angle is determined by the duration of
a pulse that is applied to the control wire. In other words, the duration of the pulse dictates the
angle of the output shaft.

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) H


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

4.0 Lab Activity

Lab 6A: DC Motor Control

Lab Activity 1

1. If PWM, rather than just on/off drive, is applied to an H-bridge, then continuously variable
reversible drive can be achieved. If it is an exact square wave of sufficiently high frequency,
the motor stands still, as the average current is zero. This is illustrated in Figure 4. If the
Bridge Drive changes to a Mark:Space ratio of less than 1 the current takes up a negative
average value. With a Mark:Space ratio of greater than 1 it takes up a positive average value.
By varying the PWM pulse width across its full range, from absolute minimum to absolute
maximum, the motor speed can be continuously varied, in both directions.
2. The source code in Program 1, demonstrates PWM waveform generation using CCP1 which
generated pulses with 0.5ms period and duty cycle of 50%. The pulse is a continuous stream
of 0.25ms long +5V DC signal followed by 0.25 ms long 0V signal.
3. Test the given source code using MPLAB simulation and observe the output.
4. Generate hex file, upload to Proteus circuit (Figure 5) and record your observation.

Figure 4

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) I


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Program 1

;******** Lab6A Example 1 ***********


;This program uses CCP1 module with TMR2 for
;PWM signal generation at ccp1 (RC2) pin
;
; PWM with 0.5 ms period with 50% duty cycle
; |-----|
;---| |-----
;

STATUS EQU 0x03


INTCON EQU 0x0b
TMR2 EQU 0x11
PIE1 EQU 0x8c
PIR1 EQU 0x0c ; bank1
PR2 EQU 0x92 ; bank1
CCP1CON EQU 0x17
CCPR1L EQU 0x15
T2CON EQU 0x12
TRISC EQU 0x87 ; bank 1
B5 EQU 0x05
B4 EQU 0x04
PWM1 EQU 0x02
TMR2IF EQU 0x01

CBLOCK 0x20 ; RAM AREA for USE at address 20h


FIFTY
ENDC ;end of ram block
;
;=========================================================
org 0x0000 ;line 1
GOTO START ;line 2 ($0000)
;=========================================================
; 16F877 Clock Frequency = 20 MHz
; Tosc = 1/[Clock Frequency] = 0.05us
; PWM Period = 2000Hz = 0.5 ms
; TMR2 Prescale = 16
; PR2 = (period / [4*Tosc*Prescale]) - 1 = 155.25
; = 155
; = 0x9b
; PWM Ducty Cycle = 50% of the PWM period
; = 0.5 *(0.5ms)= 250us
; ---> PWM Duty Cycle / (Tosc * Prescale)
; = [250u]/[0.05u*16] = 312.5 = 313 = 0x139
;
; CCPR1L CCP1CON
; 76|5432|10 76|54|3210
; 01|0011|10 |01|
; CCPR1L:CCP1CON<5:4> =(PWM Duty Cycle)/(Tosc*Prescale)= 139h
; CCPR1L = 0x4e
; CCP1CON<5:4> = b'01'
;
org 0x0005
START
banksel PIE1
clrf PIE1
banksel CCP1CON
clrf CCP1CON
clrf TMR2

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) J


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

clrf INTCON
clrf PIR1
movlw 0x4e ;50% Duty Cycle
movwf FIFTY
;PWM Period Setting
banksel PR2
movlw 0x9b ;2000Hz(0.5ms)Period
movwf PR2
banksel FIFTY
;PWM Duty Cycle
movf FIFTY, W ;Move 50% Duty Data to W reg.
movwf CCPR1L
bcf CCP1CON, B5 ;Under PWM mode
bsf CCP1CON, B4 ;2 LSB's of PWM duty cycle; the other
8bits
;are located at CCPR1L
banksel TRISC ;TRISC Setting for output
bcf TRISC, PWM1 ;set PORTC.2 as output
banksel T2CON
movlw 0x07 ;TMR2 Turn On and
movwf T2CON ;TMR2 Prescale 16

banksel CCP1CON ;CCP1CON Module Setting


bsf CCP1CON, 0x03 ;PWM Turn ON
bsf CCP1CON, 0x02 ;11xx<3:0> is PWM mode

END

Figure 5: PIC16F877A connected to Dual full bridge driver (L298)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) K


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Lab Activity 2

1. Based on flow chart in Figure 6, create an application that could generate 8 kHz PWM signal
with 25% and 75% duty cycle from CCP1.
2. Execute your program and observe the simulation output. Please use the simulation circuit
provided as shown in Figure 5.

Start

Tosc = 0.05us
PWM Period = 8kHz
TMR2 prescaler 16

PWM Output PWM Output


with 75% Duty NO RA2 = High? YES with 25% Duty
Cycle Cycle

Figure 6: Flow chart

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) L


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Lab 6B: Servo Motor Control

Lab Activity 3

1. Run Program 2 in your MPLAB and run the Proteus simulation circuit as shown in Figure 7.
2. Observe the output of the program. The TMR0 concept is applied as in the previous lab to
acquire the time value.
Overflow time = 4 x TOSC x Prescaler x (256 TMR0)
3. Modify Program 2 so that the servo will turn at +90 degree when a button located at RC2 is
pressed.
4. Again, modify the program in Step 4 if the crystal oscillator is changed to 20MHz (re-calculate
the value of TMR0 and COUNT register).

Figure 7: Servo Motor Simulation Circuit

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) M


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Program 2

#include <p16f877a.inc>
#define _XTAL_FREQ 40000000
COUNT EQU 0x20

ORG 0x00
BSF STATUS,RP0
MOVLW B'00000000' ; Motor located at PORTB
MOVWF TRISB
MOVLW B'11111111' ;BUTTON LOCATED AT PORTC
MOVWF TRISC
MOVLW B'00000100' ; Prescaler =32 (Bit 2,1,0 = 100)
MOVWF OPTION_REG
BCF STATUS,RP0

; -90 DEGREE ROTATION = 0.5ms (high)


; delay = 19.5ms (low) , Total high and low = 20ms
TEST BTFSS PORTC,0
GOTO PRESS
GOTO RELEASE
PRESS BTFSS PORTC,0
GOTO LOOP
GOTO RELEASE
LOOP MOVLW D'40'
MOVWF COUNT
MOVLW D'100' ;
MOVWF TMR0
BSF PORTB,0
BCF INTCON,TMR0IF

WAIT_0.5ms BTFSS INTCON,TMR0IF


GOTO WAIT_0.5ms
GOTO DELAY_19.5ms
DELAY_19.5ms MOVLW D'100'
MOVWF TMR0
BCF INTCON, TMR0IF
BCF PORTB,0
DECFSZ COUNT
GOTO WAIT
GOTO TEST
WAIT BTFSS INTCON, TMR0IF
GOTO WAIT
GOTO DELAY_19.5ms
; 0 DEGREE ROTATION = 1.5ms (high)
; delay = 18.5ms (low). Total high and low = 20ms
RELEASE BTFSS PORTC,1
GOTO PRESS2
GOTO TEST

PRESS2 BTFSS PORTC,1


GOTO LOOP2
GOTO TEST

LOOP2 MOVLW D'4'


MOVWF COUNT

DELAY_1.5ms MOVLW D'100'


MOVWF TMR0
BCF INTCON, TMR0IF
BSF PORTB,0
DECFSZ COUNT
GOTO WAIT2
GOTO LOW_PULSE

WAIT2 BTFSS INTCON,TMR0IF


FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) N


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

GOTO WAIT2
GOTO DELAY_1.5ms

LOW_PULSE MOVLW D'38'


MOVWF COUNT
DELAY_18.5ms MOVLW D'100'
MOVWF TMR0
BCF INTCON, TMR0IF
BCF PORTB,0
DECFSZ COUNT
GOTO WAIT3
GOTO RELEASE

WAIT3 BTFSS INTCON, TMR0IF


GOTO WAIT3
GOTO DELAY_18.5ms

END

FKEE, Semester II Session 2016/2017

BEE31101 ELECTRONICS ENGINEERING LABORATORY IV

About Students:
Name Matric No. Section: 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8
/ 9 / 10 / 11 / 12
Instructors Name:
Assoc. Prof. Dr. Abd Kadir Mahamad
Dr. Chessda Uttraphan Eh Kan
Azmi Sidek
Mohamad Md Som
Munirah Abd Rahman

About Experiment:
Title Venue
MCAD1 / MCAD2 / MSKM /
Lab 6A: DC Motor Control MSK / MRK
Lab 6B: Servo Motor Control Date

FOR INSTRUCTORS ONLY

Domain Item Lab A Lab B Total


Pre Lab /05 /05
C
Questions /15 /15
/40
Lab Activities /20 /20
P Observations /20 /20 /100
Conclusion /10 /10
Demonstration and Verifications /10 /10
A Ethics /10 /10 /60
Content /10 /10

TOTAL MARKS Instructors Comment Submission Stamp

/200
Electronic Engineering Laboratory IV (BEE31101) 1
Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Pre-Lab

Matric No. Name

Matric No. Name

Marks Check by

Lab 6A: DC Motor Control

1. What is the function of Prescaler for DC motor?

(1 mark)

2. Describe the function for every bits of these instructions.


MOVLW .5
MOVWF T2CON
(2 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 2


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

3. The statement below is taken form source code of Program1.


banksel PIE1
clrf PIE1
Explain why PIE1 need to be cleared.
(2 marks)

Lab 6B: Servo Motor Control

4. Briefly explain the fundamental operation of servo motor.


(2 marks)

5. List down four (4) application of servo motor.


(1 mark)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 3


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

6. Differentiate the dc motor and servo motor controller in microprocessor.


(2 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 4


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Questions

Lab 6A: DC Motor Control

1. Discuss the outcome of source code in Lab Activity 1 if the prescaler is changed to 32.
(7 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 5


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

2. Briefly explain the significant of using PWM in controlling the rotation and speed of DC motor.
(8 marks)

Lab 6B: Servo Motor Control

3. Based on Program 2, prove (show your calculation) that 0.5ms for high pulse requires a pre-
loaded value of 100 to be inserted into TMR0.

(3 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 6


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

4. Based on Program 2, demonstrate the relationship of 19.5ms overflow time with the pre-
loaded value of 40 in the COUNT register.

(4 marks)

5. Based on Program 2, demonstrate the relationship of 1.5ms overflow time with the pre-
loaded value of 4 in the COUNT register.

(4 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 7


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

6. Based on Program 2, demonstrate the relationship of 18.5ms overflow time with the pre-
loaded value of 38 in the COUNT register.

(4 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 8


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Lab Activity

Lab 6A: DC Motor Control

Lab Activity 2

1. Calculate the numerical representation for PR2.


(2 marks)

2. Explain how 25% duty cycle of 8kHz PWM will be represented in CCP1L and CCP1CON
register.
(4 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 9


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

3. Explain how 75% duty cycle of 8kHz PWM will be represented in CCP1L and CCP1CON
register.
(4 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 10


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

4. Modify the sample code of Program1 to generate PWM waveform with condition based on flow
chart in Figure 6.
(10 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 11


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 12


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Lab 6B: Servo Motor Control

Lab Activity 3

1. Write down the modification of source code (from Program 2) for step 4.
(10 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 13


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

2. Write down the modification of source code (from Program 2) for step 5.
(10 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 14


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Observations

Lab 6A: DC Motor Control

Lab Activity 1

1. Discuss the difference of Proteus simulation outcome with respect to its expected theoretical
outcome.
(5 Marks)

Lab Activity 2

2. Conclude the effects of PWM duty cycle against dc motor speed and rotation.
(5 Marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 15


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

3. Summarize the role of PR2, CCPR1L and CCP1CON in determining the PWM duty cycle.
(5 Marks)

Lab 6B: Servo Motor Control

Lab Activity 3

4. Observe the simulation outcome of Program 2.


(5 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 16


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

5. Detailed out the difference of the outcome after modification made in step 4.
(5 marks)

6. Write down your observation when the crystal value is changed in step 5.
(5 marks)

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 17


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

Conclusion

FKEE, Semester II Session 2016/2017

Electronic Engineering Laboratory IV (BEE31101) 18


Lab 6A: DC Motor Control
Lab 6B: Servo Motor Control

References

FKEE, Semester II Session 2016/2017

Grading Rubric for Written Reports

Scale
Criteria
5 4 3 2 1
LabActivities Varies,dependingonactivityassigned

Observations Varies,dependingonquestionassigned
Conclusion Accurate Accurate Astatementofthe Astatementofthe Noconclusionwas
statement of the statement of the resultsofthelab resultsis includedorshows
results of lab results of the lab indicateswhether incompletewith littleeffortand
indicates whether indicates whether resultssupportthe littlereflectionon reflectiononthe
results support results support hypothesis thelab. lab.
hypothesis. the hypothesis.

Possible sources Possiblesourcesof
of error and what erroridentified.
was learned from
the lab is
discussed.
Demonstration Demonstrateswith Exhibitslimited Demonstration
and clear understandingor without
understandingof principle understandingthe
Verifications principleor demonstrated; principle;cannot
conceptinvolved; minorinaccuracies relateconceptto
accuratelyrelates inrelating demonstration
conceptto demonstration.
demonstration.
Ethics Selfgenerated Solution/ideasare Copiedsolution/
solution/ideas. adoptedfrom ideasfromothers.
others.
Reportis Reportis
submittedbefore Reportis submittedmore
dateline. submittedaday thanadayafter
afterdateline dateline.
Coverpage
informationis Informationon
completelyfilled. coverpageisnot
completelyfilled.
Content Ideas are written Ideasarewritten Plagiarizes.Ideas
using own withlimited aredirectlycopied
original language knowledgeand fromreferences.
and clearly understandability.
focused. Ideasaresnipped Nocitationof
fromreference reference.
Reference is withoutfully
cited using ieee
understandthe
standards.
concept.

Referenceiscited
usingvarious
standards.

Das könnte Ihnen auch gefallen