Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

PIC ReportDcMotor

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

An-Najah National University ‫جامعة النجاح الوطنية‬

Faculty of Engineering and IT ‫كلية الهندسة وتكنولوجيا المعلومات‬

Computer Engineering Department


Course Name: Microcontroller Lab Number: 66496
Lab Report Grading Sheet

Instructor: Dr.Suliman Experiment Number: 9


Academic Year: 2023 Experiment Name: DC motor
Semester: Spring

Students
1- Hala Barqawi 2-Asala Tibi
3- 4-
Performed on: Submitted on:
Report’s Outcomes
ILO __ =( ) % ILO __ =( ) % ILO __ =( ) % ILO =( ) % ILO =( ) %

Evaluation Criterion Grade Points


Abstract: a very short summary (around 150-250 words) of what the experiment
1
is about, what you found, and why it may be important.
Introduction: Sufficient, clear and complete statement of objectives. In addition
1
to Presents sufficiently the theoretical basis.
Materials and Methods: Technical details about the experiment and how it was
2
performed.
Experimental Results (including code and figures): provide detailed
explanation of the experimental results; outline all of your findings while 2
commenting your code and describing your figures.

Discussion: show off your understanding of the results and the data 2

Conclusions and Recommendations: Conclusions summarize the major


findings from the experimental results with adequate specificity. 1
Recommendations appropriate in light of conclusions.
Appearance: Title page is complete, page are numbered, content is well
1
organized, correct spelling, fonts are consistent, good visual appeal.

Total 10

Issue number: AD3-3 1


An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT ‫كلية الهندسة وتكنولوجيا المعلومات‬

Abstract

In this experiment we learn how to generate a proportional output using the output
compare resource on the PIC32MX processor so that you can implement Digital-to-Analog
Conversion (DAC) with pulse width modulation (PWM). The proportional output will be used
to control the speed of a DC motor, we used 2 buttons to turn the motor ON/OFF.
Introduction

A DC motor is an electro-mechanical device that converts direct current into mechanical energy by
means of rotation of a shaft. It works on the principle of Lorentz force by which the current carrying
conductor in a magnetic field experiences a force hence the conductor moves on the direction of
force called Lorentz force. The speed control of a DC motor using the pulse width modulation (PWM)
technique is discussed in this chapter.

DC Motor

A DC motor is made up of an electromagnet or a permanent magnet, as well as a twisted coil called


the armature. By using a carbon brush or electromagnetic induction, direct current is supplied to the
armature. The armature travels in the direction of force due to electromagnetic induction. DC
motors are frequently utilized in applications such as industrial automation, toys, and robots.
Controlling the current to the armature or utilizing a variable power supply are two ways to control
the speed of a DC motor.

Speed Control of DC Motor Using PWM

Controlling the speed of a dc motor can be accomplished in a variety of methods, including the use
of a potentiometer and a controlled current to the armature. Apart from these methods, pulse width
modulation is the most efficient means to control motor speed. Pulse width modulation (PWM) is a
digital technique for converting digital data into a throbbing square wave signal. PWM is used in a
variety of applications, including motor speed control, telecommunication message encoding,
regulated switching in switch mode power supply, and sound synthesis in audio amplifiers.

PWM employs a rectangular pulse train whose modulation yields the pulse sequence's average
value.

PmodDHB1's DC motor driver circuit lets you to adjust the motor speed and direction by connecting
the Output Enable pin to the PIC32 PWM output.

The PIC32MX output compare(oc)module is used to generate a single pulse or a sequence of pulses,
and it controls the PWM pulse width.

Its operation necessitates the use of a timer as well as one or two coaxial cables.
Issue number: AD3-3 2
An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT ‫كلية الهندسة وتكنولوجيا المعلومات‬

The PIC32MX output compare(oc)module, which is used to generate a single pulse or a sequence of
pulses, controls the PWM pulse-width. Its operation necessitates the use of a timer as well as one or
two compare values.

Equipment
 Chip KIT Pro MX7 processor board with USB cable.
 Microchip MPLAB X IDE.
 MPLAB XC32++ Compiler.
 Digilent PmodDHB1.
 Digital DC Motor.

Procedure and Result


we asked to control the speed of the DC motor by buttons,
At first, calculate the PR value by the frequency equation if time = 1ms and clock = 80M and PS =
256:

 Frequency equation F=PBCClkpresPeriodReg+1

Time = 1/F  1/1m = 10M/256PeriodReg+1

10M*1m=256(PeriodReg+1) ---->38

Second: use this value to calculate the OCR to give it to the OC module by duty cycle equation:

 Duty Cycle =(OCR/PeriodReg+1)*100%

After these calculations we configured the harmony as needed , with drivers , timer and etc.

As mentioned in the first task we controlled the speed of the DC motor , once that button 1
pressed the duty cycle was 95% that equals 37.05 , and if we pressed on button 2 it
decreased to 5%.

In the second task we detect the pressed buttons by using change notice interrupt as we
used for the 1st task , then as shown in the table below , we implemented a speed control
mechanism for the dc motor to four fixed duty cycle values.

Issue number: AD3-3 3


An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT ‫كلية الهندسة وتكنولوجيا المعلومات‬

BTN1 BTN2 PWM


ON OFF 5% 19
OFF ON 75% 28.5
OFF OFF 25% 9.5
ON ON 95% 38

We write the following code to do the task :


in app.c :
void APP_Tasks ( void )

switch ( appData.state )

/* Application's initial state. */

case APP_STATE_INIT:

bool appInitialized = true;

TRISG = 0x0FFF;

if (appInitialized)

DRV_TMR0_Start();

DRV_OC0_Start() ;

appData.state = delay;

break;

Issue number: AD3-3 4


An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT ‫كلية الهندسة وتكنولوجيا المعلومات‬

case delay:{

break;

case APP_STATE_SERVICE_TASKS:

break;

In system interrupt:

void __ISR(_CHANGE_NOTICE_VECTOR, ipl1AUTO) _IntHandlerChangeNotification(void)

if(PORTGbits.RG6 ==0 && PORTGbits.RG7 ==0){

int flag =9.5;

DRV_OC0_PulseWidthSet(flag);

else if(PORTGbits.RG6 ==1 && PORTGbits.RG7 ==0){

int flag =19;

DRV_OC0_PulseWidthSet(flag);

else if(PORTGbits.RG7 ==1 && PORTGbits.RG6 ==0){

int flag =28.5;

DRV_OC0_PulseWidthSet(flag);

Issue number: AD3-3 5


An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT ‫كلية الهندسة وتكنولوجيا المعلومات‬

else if (PORTGbits.RG7 ==1 && PORTGbits.RG6 ==1){

int flag =38;

DRV_OC0_PulseWidthSet(flag);

PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_CHANGE_NOTICE);

void __ISR(_TIMER_2_VECTOR, ipl1AUTO) IntHandlerDrvTmrInstance0(void)

PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_TIMER_2);

void __ISR(_OUTPUT_COMPARE_2_VECTOR, ipl1AUTO) _IntHandlerDrvOCInstance0(void)

PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_OUTPUT_COMPARE_2);

Conclusion
We learn how to control the speed of DC motor. We were also able to construct the PWM
output that controls the motor speed as well as the output comparisons that were utilized to
generate the pulses using timer 2.

Issue number: AD3-3 6

You might also like