You are on page 1of 12

LABORATORY SESSION # 9

9 Speed Control of a DC Motor using Variable Duty Cycle PWM


[Open Ended Lab]

9.1 EQUIPMENT & MATERIAL REQUIRED

- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________

9.2 PRE-LAB PREPARATIONS

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

9.3 PRCEDURE

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Student Workbook EE-07310: Microprocessor based Embedded Systems

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

9.4 OBSERVATION & RESULTS

- Complete code
pwm.c

#include "main.h"
#include "PWM.h"

void PWM_Init(void)
{
RCC_APB2ENR |= 0x0000080C; // Enable clock to GPIO port A, B & Timer 1

GPIOA_CRH &= 0xFFFFFFF0; /* Clear previous config for PA8


(PA8 is connected to TIM1_CH1)
- user manual page 15*/
GPIOA_CRH |= 0x00000009; // 10Mhz push pull alternate output.

TIM1_CR1 = 0x0080; /* Enable Auto Reload Preload Enabled


-pg248(also check DIR register-page248)*/
TIM1_CNT = 0; /* Initialise counter from 0*/
TIM1_PSC = 7; /* Divide the default 8M Hz into
0.1M Hz clock(1us) ----- resolution*/
TIM1_ARR = 20000-1; /* 50Hz - 100 counts-after every 1us increase 1 in
the counter (counts x resolution = 1/PWM Frequency)*/
TIM1_CCMR1 = 0x0068; /* Output compare 1(preload enable &PWM mode 1
enabled &configured as output) - page 259 ref manual*/
/*TIM1_CCMR1 = 0x6868; Output compare 1+2 (preload enable & PWM mode
1enabled & configured as output) - page 259 ref manual*/
/*TIM1_CCMR2 = 0x0068; Output compare 3 (preload enable & PWM mode
1 enabled& configured as output)- page 259 ref manual*/
TIM1_CCER = 0x0001; /* Signal is output on the corresponding pin
- page 262 ref manual*/

TIM1_EGR = 0x0001; /* Reinitialize the couner & gen updates of the registers*/
Student Workbook EE-07310: Microprocessor based Embedded Systems

TIM1_BDTR = 0x8000; /* MOE - Main output enabled - page 268 ref manual*/
TIM1_CR1 |= 1; /* Timer starts - counter enabled*/
}

void Duty_Vary_Ch_1(int Dc)


{
TIM1_CCR1 = Dc; /* Capture/Compare register for channel 1; defines duty cycle*/
/* Simillarly we can have 4 different duty cycles
by using CCR1 to CCR4 (freq will be same)*/
}

pwm.h
#ifndef _PWM_H_
#define _PWM_H_

void PWM_Init(void);
void Duty_Vary_Ch_1(int Dc);

#endif
main.c

#include "main.h"
#include "PWM.h"
void SystemInit(void)
{}
void Cyclic_Start(const unsigned short PERIOD)
{ RCC_APB1ENR |= 0x00000001;
TIM2_CR1 = 0;
TIM2_CNT = 0;
TIM2_PSC = 7999;
if(PERIOD > 1)
{
TIM2_ARR = (PERIOD-1);
}
else
{
TIM2_ARR = 1;
}
TIM2_CR1 = 0x0001;
}
void Cyclic_Wait(void)
{
while((TIM2_SR & 0x00000001)==0)
{
}
TIM2_SR = 0;
}
// delay function end
int main(void)
{
int Dc=0;
PWM_Init();
Cyclic_Start(10);
Student Workbook EE-07310: Microprocessor based Embedded Systems

while(1)
{
Duty_Vary_Ch_1(10000);
Cyclic_Wait();
}
return(1);
}

Figure 9.1:Complete code in Keil µVision 4

- Successful creation of HEX file

Figure 9.2:0 Errors, 0 Warnings


Student Workbook EE-07310: Microprocessor based Embedded Systems

- Software screenshots in debugging session

Figure 9.3:Debugging session

- Record all measurements /parameters (software/hardware) in tabular form

Table 9.1: Duty cycle VS speed of motor

S. No. Duty Cycle (%age) Speed (rpm)

1 10% 270.9

2 20% 502.6

3 30% 729.1

4 40% 931.3

5 50% 1124

6 60% 1324

7 70% 1523

8 80% 1726

9 90% 1916

10 100% 2077

- Duty Cycle 1
Student Workbook EE-07310: Microprocessor based Embedded Systems

Speed on meter Duty Cycle on Oscilloscope

Figure 9.4:Speed of motor with duty cycle 1

- Duty Cycle 2
Speed on meter Duty Cycle on Oscilloscope

Figure 9.5:Speed of motor with duty cycle 2

- Duty Cycle 3
Speed on meter Duty Cycle on Oscilloscope

Figure 9.6:Speed of motor with duty cycle 3

- Duty Cycle 4
Student Workbook EE-07310: Microprocessor based Embedded Systems

Speed on meter Duty Cycle on Oscilloscope

Figure 9.7:Speed of motor with duty cycle 4

- Duty Cycle 5
Speed on meter Duty Cycle on Oscilloscope

Figure 9.8:Speed of motor with duty cycle 5

- Duty Cycle 6
Speed on meter Duty Cycle on Oscilloscope

Figure 9.9:Speed of motor with duty cycle 6

- Duty Cycle 7
Student Workbook EE-07310: Microprocessor based Embedded Systems

Speed on meter Duty Cycle on Oscilloscope

Figure 9.10:Speed of motor with duty cycle 7

- Duty Cycle 8
Speed on meter Duty Cycle on Oscilloscope

Figure 9.11:Speed of motor with duty cycle 8

- Duty Cycle 9
Speed on meter Duty Cycle on Oscilloscope

Figure 9.12:Speed of motor with duty cycle 9

- Duty Cycle 10
Student Workbook EE-07310: Microprocessor based Embedded Systems

Speed on meter Duty Cycle on Oscilloscope

Figure 9.13:Speed of motor with duty cycle 10

- Derive conclusion(s) from the recorded results


__________________________________________________________________
__________________________________________________________________
__________________________________________________________________
__________________________________________________________________

9.5 LEARNING OUTCOMES


_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

9.6 EXERCISE QUESTIONS

- Investigate the working of motor driver circuit.

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

This open–ended lab also qualifies as a Complex Engineering Problem as it meets the
criterion 1 and criterion 3.
Student Workbook EE-07310: Microprocessor based Embedded Systems

S# Attribute Complex Problems = 1 &(2 | 3 | 4 | 5 | 6 | 7 | 8 | 9)

Engineering problems which cannot be resolved


1 Preamble without in-depth engineering knowledge, and have ☒
some or all of the characteristics listed below:

Range of conflicting Involve wide-ranging or conflicting technical,


2 ☐
requirements engineering and other issues.

Have no obvious solution and require abstract


3 Depth of analysis required thinking, originality in analysis to formulate suitable ☒
models.

Requires research-based knowledge much of which is


Depth of knowledge at, or informed by, the forefront of the professional
4 ☐
required discipline and which allows a fundamentals-based,
first principles analytical approach.

5 Familiarity of issues Involve infrequently encountered issues ☐

Are outside problems encompassed by standards and


6 Extent of applicable codes ☐
codes of practice for professional engineering.

Extent of stakeholder
Involve diverse groups of stakeholders with widely
7 involvement and level of ☐
varying needs.
conflicting requirements

8 Consequences Have significant consequences in a range of contexts. ☐

Are high level problems including many component


9 Interdependence ☐
parts or sub-problems.
Student Workbook EE-07310: Microprocessor based Embedded Systems

GENERALIZED LAB RUBRICS


Component Above Meeting Approaching Below Weight / Score
Domain with Expectation Expectation Expectation Expectation Used 100
(1–4)
Taxonomy (4) (3) (2) (1) (Optional)

Is able to build a given


setup neatly and timely Is able to assemble Is not able to
Psychomotor

Is only able to copy


Building using correct hardware a given setup using assemble a given
(Hardware) components and / or correct hardware
a given setup using
setup using 
correct hardware
P4 can reorganize / adapt components after correct hardware
components
to new / special minor revisions components
requirements
Recording
Is able to record Is only able to
Measurements Is able to record Is unable to
(Hardware / accurate measurements
accurate record accurate
record accurate ☐
measurements most measurements on
Software) all the time measurements
of the time some occasions
C3
Is able to formulate
Is partially able to
/develop theories in Is able to evaluate
Investigation evaluate /conclude Is unable to
addition to evaluating /conclude correctly
(Hardware /
/concluding correctly about investigation
correctly about comprehend 
Software) investigation investigation
about investigation parameters by
C5 parameters by parameters
parameters by assessing assessing data
assessing data
data
Design /
Is unable to
Development Is able to design / Is able to partially
Is able to design / partially design /
Cognitive

of Solution develop the solution of design / develop the ☐


develop the solution develop the
(Hardware / a given problem and solution of a given
of a given problem solution of a
Software) add features to it problem
given problem
C6
Is able to use the
Software Is adept in the use of Is able to use the
software tool
Usage software tool and can
effectively by
software tool but Is unable to use 
(Software) access advanced cannot access all the the software tool
accessing all the
C3 features required features
required features
Is able to efficiently
Is able to complete
complete a given task
a given task using
Programming using advanced Is unable to
required Is able to partially
Language programming language
programming complete a given
partially 
(Software) constructs / methods / complete a given
language constructs task
C3–C6 commands and/or add task
/ methods /
features to the original
commands
task
Student Workbook EE-07310: Microprocessor based Embedded Systems

GENERALIZED LAB RUBRICS

Component Above Approaching Below


Meeting Expectation Use Weight Score
Domain with Expectation Expectation Expectation / 100
(3) d (1–4)
Taxonomy (4) (2) (1) (Optional)

Safety Assesses and Assesses and complies Assesses and complies Assesses and
Instructions complies with all with most EHS with some EHS complies with ☐
(PLO6) EHS instructions instructions while in instructions while in few EHS
A4 while in lab lab lab instructions in lab
Does not exhibit
Exhibits exemplary Makes an effort to professional
Professional Exhibits professional
professional ethics exhibit professional ethics while
Ethics ethics while dealing
while dealing with
with fellow students,
ethics while dealing dealing with ☐
(PLO8) fellow students, lab with fellow students, fellow students,
A3 lab staff and instructor
staff and instructor lab staff and instructor lab staff and
all the time
all the time all the time instructor all the
time
Consistently shows
Shows some
full preparation by
Consistently shows full preparation which is Shows very little
Contribution completing all
preparation by mostly at superficial or no preparation
(PLO9) agreed tasks and
completing all agreed level in completing a in completing a 
A5 provides additional
tasks and work requires task and work requires task and work
resources for the
Affective

little or no revisions much revisions and quality is poor


group and work
editing
quality is excellent
Internalized positive
Attitude Consistent positive Neither helpful nor Discouraging
behavior and
(PLO9) encourages and
behavior most of the damaging and shows behavior towards ☐
A5 time towards other disinterest in the other team
helps other team
team members performance of others members
members
Report on all Report on all relevant Report on all relevant
relevant sections sections related to the sections related to the
Report related to the lab lab tasks is completed lab tasks is completed Report on all
Writing tasks is completed but few deficiencies but many deficiencies relevant sections
accurately, meeting are present in terms of are present in terms of related to the lab ☐
(PLO10)
A2 the requirements, in accuracy / meeting the accuracy / meeting the tasks is not
prescribed time and requirements / requirements / completed
with good language prescribed time / good prescribed time / good
skills language skills language skills
Lab Task Does not manage
Management Manages tasks well
within given
Manages tasks within Manages tasks in an tasks even in ☐
(PLO11) given timeframe extended timeframe extended
A3 timeframe
timeframes

You might also like