PIC ReportDcMotor
PIC ReportDcMotor
PIC ReportDcMotor
Students
1- Hala Barqawi 2-Asala Tibi
3- 4-
Performed on: Submitted on:
Report’s Outcomes
ILO __ =( ) % ILO __ =( ) % ILO __ =( ) % ILO =( ) % ILO =( ) %
Discussion: show off your understanding of the results and the data 2
Total 10
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
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.
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:
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.
switch ( appData.state )
case APP_STATE_INIT:
TRISG = 0x0FFF;
if (appInitialized)
DRV_TMR0_Start();
DRV_OC0_Start() ;
appData.state = delay;
break;
case delay:{
break;
case APP_STATE_SERVICE_TASKS:
break;
In system interrupt:
DRV_OC0_PulseWidthSet(flag);
DRV_OC0_PulseWidthSet(flag);
DRV_OC0_PulseWidthSet(flag);
DRV_OC0_PulseWidthSet(flag);
PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_CHANGE_NOTICE);
PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_TIMER_2);
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.