0115 966 7955 Today's Opening Times 10:00 - 20:00 (BST)
Banner ad for Viper plagiarism checker

Control The Speed Of The DC Motor Engineering Essay


Disclaimer: This essay has been submitted by a student. This is not an example of the work written by our professional essay writers. You can view samples of our professional work here.

Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of UK Essays.

Direct current (DC) motor is applied in a wide range of applications particularly in automation technology due to minimal voltage consumption. In the proposal DC motor plays an effective role in Hardware implementation. The main principle behind the project is to use the cascade control to run the DC motor; it's one of best feedback controllers. For estimating the velocity and the armature current of the DC motor with 24 volts and a dsPIC Microcontroller is programmed .The above all operation is done in a closed control loop function.

Table of Contents

1.2 Objective

2. Specific Aims of the project

Chapter 1

1. Introduction

1.1 Background

Brushed DC Motor

DC motor model

Digital control of dc motor

Advantages of dc with respect to speed control

Analogue control of dc motor

2.1 ds PIC

dsPIC30f 3010


3. Design and Research

Cascade control

Currentloop dynamics

Speed loop dynamics

3.1 Components for controlling 24v brushed Dc motor

3.1. Flexible inverted board

3.2.1 Generating PWM wave forms

3.1.2 H-Bridge converter

3.2 Software techniques used in DC motor

Programming microcontroller in Flexible inverted board

4. Results and Discussion

5. Conclusion

6. Appendix

List of Figures

FIGURE 1: Operation of BRUSHED DC Motor

FIGURE2: General block diagram of speed loop and current loop of DC Motor

FIGURE3: H-bridge converter with different voltage Vα & Vβ



1.1 Objective

The main function of the project is to control the speed of the DC Motor using a dsPIC30f3010 microcontroller. For that implement a separate hardware to satisfy the main function of the project.

1.2 Specific Aim of the project

In order to achieve the main core of the project, construct Hardware for controlling the speed control of DC motor. The main hardware requirements are

ds PIC microcontroller

ICD interface & connector for system interface

DC power supply


Current sensors

The above components are required to construct a hardware called Flexible Inverted Board [4].



In this paper a flexible inverted board is constructed with the series of hardware components


Then communicate the Flexible inverted board with system using MPLAB IDE software with ICD-3 interface [4].the language used in the MPLAB software is C-language.


The speed loop and the current loop are the two important functions for controlling the speed of the Dc motor. In our project the key point is to control both the loops by C-programming language using MPLAB ICD-3.

The speed loop of the microcontroller is called speed controller and the current loop of the microcontroller is called current controller.



2 Background

2.1 Brushed DC Motor

In automotive industries DC motor is used widely in "fuel pump control, electronic steering control, engine control and electric vehicle control" [6]for its cost effective and it is used in many applications like "pulp and paper industries, fan pumps, press, winder motors" [2],"home appliances, washers, dryers and compressors"[6] are some of the best examples. DC motor is one of the important hardware employed in this paper, it consists of a rotor and stator, and the parts are placed in a permanent magnetic field. Commutator and brush are placed in between the rotor and stator. Positioning the brush at a particular direction in the rotor is classified into some categories and they are "radial, trailling or leading" [3] positions. When the rotor rotates the commutator and carbon brush interface at a point, which produces an enormous amount of magnetic field from the brush of the motor and it produces current to the armature winding of the Dc motor.

FIGURE 1: Operation of BRUSHED DC Motor[a]

2.2 DC Motor model [8]

Each motor will have different specification and requirements. According to motor requirements and details the model can be designed. The aim of motor model, deals with controlling the applied voltage of both speed and current. The basic model for a Dc Motor is shown below

FIGURE2: DC Motor model

The above diagram is a simple RL circuit. RL circuit is called resistance inductance circuit

and a 24v DC Motor. All these components combine to form RL circuit.

Now the derivation part of the RL circuit is explained below

T (t) = J

w is the Angular velocity

J is the moment of inertia

B is the friction

T is the armature Torque

T (t) = (t)

is the Torque constant

is Armature current

According to Kirchhoff's law

(t) - (t) = (t) +

and are the inductance and resistance for the armature current (ia)

The electromotive of the motor can be determined by multiplying the back emf with speed

The relationship for the electromotive force is shown below

(t) =

The state model for any DC motor using ia and w (speed) is mentioned below.

= +

2.3 ds PIC -microchip

ds PIC stands for Programmable Interface Controller or programmable intelligent computer, which act as an important controlling unit for entire system. The main objective of this project is to make the ds PIC to generate 6PWM waveform. In an ideal condition the waveform from the pulse width modulation can control the H-bridge converter. It not only serves as an interface controllers but also plays a role of a programmable logic controller (PLC). [16,20]

ds pic has a memory of 16bit microcontroller that has two major functions. Firstly it can act as a software part serving software functions and the other is a hardware part serving hardware functions.

The input signals that are attain from the feedback serve system are received by the software part which in turn utilizes the codes that are written on the chip on C - language to analyze the input and operate the hardware. Finally the software makes sure the hardware runs based on the software functions to gain the required output. [18, 20]

Our project concentrated on working experiments that were run at lab conditions. Since a couple of systems have certain differences from the stimulation that have been run in real conditions compared to ideal conditions. This in turn is the working of the microcontroller.

dsPIC30F 3010, 2010 4011 and 3012 are the series of chips that have been available in the Lab. The letter 'F' in ds PIC30F and such chip states that the chip contains flash memory. The reason for considering this flash memory product is because 30F has an ex-ordinary performance when compared to EPROM (Erasable Programmable Read-Only Memory) and one time programmable chips (OTP). This has been a major requirement for the running of this project to get the required output.

16-bit modified Harvard architecture has been added to the CPU containing ds PIC30F for utilizing the data and upgrading the set of guide lines for running digital signal processing (DSP) [14]. There is a lengthy flexible opcode field which has been installed in the CPU that has a 24 bit wide user programmer memory area and the total addressing speed can go up to 4MÃ-24 bit. This programming model has sixteen 16bit working registers in ds PIC30F chip. There are two classes of introduction controlling unit that have been integrated and used for execution they are integrated and used for execution [2].

2.3.1 dsPIC30F 3010

This section is about the pin configuration and the components available in dsPIC30F3010 microcontroller. Normally the memory allocation in dsPIC30F 3010 can classified in to three categories they are

SRAM in Bytes

EEPROM in Bytes

Programmable memory in Bytes/instruction SRAM

SRAM stands for static RAM (Random Access Memory). According to the tabulation shown below the data limit for static RAM should not exceed 1024 bytes. The memory in the function can classified in two types they are

X - Data RAM

Y - Data RAM

The static RAM uses X -RAM and Y_RAM for storing datas.

The memory allocation for EEPROM is same as static RAM. In read only memory one of the important types of ROM used to store memory is EEPROM. The main function of this ROM is based on two parameters they are endurance and retention [2]. Endurance is to retain the data even after the ROM fails. Therefore the data can't be deleted at any instant. Time period is required to store data that is taken care by retention [2]. memory

In a particular program ds PIC30f microcontroller has a separate memory allocation for storing both the address and data. The memory limit for the program memory is 24K.

program address space anda data address space

TABLE 1: Tabulation for memory allocation in ds PIC30f3010

The pin configuration of dsPIC30f3010 is described below

FIGURE 3: Pin configuration of dsPIC30F 3010[2]

Pin descriptions

(PWM1L and PWM1H), (PWM2L and PWM2H) & (PWM3L and PWM3H) [2] these are six different types PWM channels used in the pin configuration. In which each PWM pair generates three duty cycles with one high output (H) and one low output (L).

INT0, INT1&INT2 are the interrupt buffers used in the PIC. VSS and VDD [2] are the supply voltage and ground in the PIC controller.

U1RX & U1TX, U1ARX & U1ATX [2] are the series of pins used for communicating PIC microcontroller with PC, in other system interface operation can be done by UART function. In that RX stands for receiver and TX stands for transmitter. The above pin function plays an important in our project.



3.1 Components for controlling 24v brushed Dc motor

Since the project is fully based on hard ware so many components are available and how they work in that operation.

3.1.1Cascade control operation in Dc Motor:

The below operation is done by using Double cascaded layout, it consists of two loops they are current controller with current reference and speed controller with speed reference [5] as shown in .

FIGURE4: General block diagram of speed loop and current loop of DC Motor [b]

The current loop is covered by the speed loop, in the block diagram it has the two circles inner circle is called inner loop and the outer circle is called outer loop since the inner circle operation is always quicker than the outer circle. In other words inner circle performance is multiple of ten times quicker than the remaining one. The cascade control principle is mainly used in our project to maintain the speed of the motor at a constant level and the current loop in the cascade control is the armature current and it is otherwise called as torque. Sometimes armature current may exceed the limit to avoid this situation in cascade control, it has limiter, and the main function of the limiter is to limit the values of the armature current. For example To limit the armature current to 64volt i.e. 1 ampere. So that the armature won't exceed those limits since the limiter is available in cascade control. The speed controller in the cascade control used to produce demand current ia*. The motor runs to overcome the demand current values. The demand current value will always higher than the normal current values. So that the speed motor gradually increases.

PI controller(proportional Integral controller)

Current controller

Speed controller

The above all components construct a cascade controller and the function each component is described below controller (proportional and integral controller)

In cascade controller function various controllers are used for detecting the speed and control of the motor, but PI controller is recommended as high efficient controller because it consist to constant gain Kip and Kid. By manually tuning the gain of both Kii and Kpi will reduce the steady state error and the stability of the system will be increased. In recent survey more than 70% cascade controller used PI controller for controlling the speed control DC Motor. In order to reduce the steady state error in the closed loop system, gradually increase the proportional gain constant Kp. As the gain of the Kp increases the steady state error in the system decreases. But the stability of the system will not be stable. To make the system stable, integral term Ki is introduced in the system. When both the proportional and integral term sum each other to reduce the steady state error and make the system stable .the above two functions can be done simultaneously in the PI controller. The mathematical expression for PI controller is explained below.

FIGURE 5: PI controller of a closed loop function [1]

Kp-proportional gain

Ki-Intergral gain

Y- Output of the PI controller

Err-Error in the PI controller

At the beginning error (Err) will pass through both Kp and Ki.

For proportional gain the output is Kp Err

y1= Kp Err eqn1 [1]

y2 = eqn 2 [1]

y = y1 + y2 eqn 3 [1]

eqn 4 [1]

The key point in this PI controller is the error Err in intergral gain Ki will be integrated. so that the steady error will be reduced and the system will be stable. controller

The current controller in the closed loop functions of the cascade control. The current loop is also called as current controller. It is used to protect cascade circuit from damage. The main function of the cascade function is to control the speed. Before controlling the speed the current of the controller should be controlled. The current obtained from the closed loop function is from armature circuit of the DC Motor [7].the input in the current controller is the back emf (ia*).

Power converter is mainly used to improve the control in the system. It has high switching frequency, since the power converter in the current loop is very quick. The output of the converter is armature voltage (Va).

(-E) is the disturbance occurred in the current loop, in order avoid the disturbance





Power Converter


FIGURE 6: Functional block diagram of Current controller

The disturbance is added along with RL circuit, and the equation is shown below

Va = (S La + Ra) ia + E

The function of the RL circuit is reduce complexity

Va is Armature voltage.

ia is armature current (trying to control)

Ra is Armature resistance

E is Disturbance

RL = 1/(S La + Ra)

Current loop is carried out by transmitting the from ia(armature current) to ia*(demand armature current). As quick as possible without making the over shoot getting so high. If the over shoot is high it creates problem to the converter. Similarly when the gain values (Kp and Ki) increases in PI controller the over shoot value reduces, but the same time there is more amount of oscillation which may affect the system. Care should be taken in choosing both Kp and Ki values.




FIGURE 7: graph for armature current vs settling time

ia - Armature current

ia* - Demand armature current

ts - Settling time

3.1.2 Flexible inverted board

The major hardware has been designed and implemented as Flexible inverted board.

It consists of many components they are dsPIC30F3010 microcontroller, H-bridge converter and dc motor. The functions of these hardware components are explained earlier. The above all operation is implemented in a single hard ware called flexible inverted board.

FIGURE 8: Functional block diagram of Flexible inverted board IR2130 gate drive circuit:

There are three input signal generator blocks which are capable of providing two outputs each gives the inputs to the six output drivers. L1, L2 and L3 are signal generators which drive precisely the three low-side output drivers although H1, H2 and H3 signal generators must be level shifted before it is fed to the high-side output drivers.

The floating points of the driver, gate charge requirements of the power switch and the maximum power switch "ON" times receives power from three bootstrap capacitors C1, C2 and C3. Bootstrap capacitors also feed supply to the internal floating driver current. Once these energy requirements are met there must be considerable amount of charge still on the 8.3V nominal to prevent stopping. D7, D8 and D9 should be super-fast.

VCC level seen by an under-voltage detector circuit gives an input to outlaw six outputs of the signal generator circuits. Current sensor R1 derives the ITRIP signal in the main power circuit of the motor when it is segregated with a 0.5 volt reference to outlaw the six signal generator outputs. ITRIP inputs sets up a fault logic circuit which in turn gives open drain TTL output for system gesture.

FIGURE 9: Circuit diagram for IR2130 gate drive circuit port function with PWM

Trim port are small in size and they are very small in size .it is mainly used in many PCB construction board since it's occupies less space.

The trim port act like a potentiometer and it is otherwise called as trimmer [ ]. By tuning the trim port, resistance value can be minimized or maximized. For example if a 50ohm resistance can be tuned by trim port from 0 - 50.

The two leg of H-bridge converter produce two pulse wave form one with low output (1L) and another one with high output (1H). The duty ratio of the PWM wave form can adjust using trim port. MOTOR ENCLOSED WITH A ENCODER

The best methods of calculating the speed of the DC motor is using optical encoder method. It consists of a disk, Light Emitting Diode (LED) and optical sensor [6]. The disk is fitted with the rotor, as the rotor rotates the disk starts spinning along with the rotor and it is placed in between the LED source and the light sensor. Once the rotation starts the disk passes through the LED source and the optical sensor gets started, from which the speed of the motor can be calculated because the optical sensor acts like a tachometer. In other words the encoder in the DC motor is otherwise called as speed detecting sensors. [6] H-Bridge converter

DC motor runs differential speed, but the applied voltage of the motor varies at every interval of time. Since the voltage is directly proportional speed, as the voltage increases the speed of the motor also increases. Speed can be calculated by tachometer which is in build in the DC motors, the applied voltage can be supplied and controlled by a converter called h-bridge converter.


GD - Gate Drive Circuit

FIGURE 10: H-bridge converter with different voltage Vα & Vβ[c]

In this H-bridge circuit it produces two unipolar pulse width modulations because it has two leg inverter. Effective modulation takes place only in the first half of the inverter. As a result two variable voltages are generated on either side of the armature winding.

In H-bridge, modulation index is represented as (+mi) and the reciprocal of modulation index is represent as (-mi).the motor in our project actually experiencing two pulse width. Both the pulses are inversely proportional to each other producing a unipolar PWM.

The two legs in the converter are called the switching signals or switching frequency. Bigger converter relatively has lower frequency and smaller converter has higher frequency. If the frequency in the leg1 is high in contrast the frequency in the leg2 will be low.

In our project consider Vα and Vβ are the switching channels of the H- bridge converter . they are inversely proportional to each other.

The carrier signal is called the input frequency . the carrier frequency used in our project is 10khz. According to the carrier frequency the time period of Vα and Vβ differs.

In C coding Vα and Vβ is mentioned as PDC1and PDC2 from the below graph

FIGURE 11 graphical representation of PWM signals in H- Bridge converter.

The output voltage of the h-bridge converter can be obtained both negative and positive voltage distribution [1]. Pulse width modulation in the h-bridge converter helps to control the armature circuit of the DC motor [1]. Maximum armature current (torque) can be obtained by comparing time constant of both field winding and the armature winding [1]. Since the motor is connected directly to the field windings supply voltage in the field winding is more when compared with the armature winding. To maintain equal time constant in both field and armature winding [1], the applied voltage in the armature winding should be increased, as the armature current increases the torque output is maximized [1].

3.1.3 Generating PWM wave forms

As the torque output gets maximized, pulse width modulation is introduced in the H-bridge system to avoid the disturbance in the armature current.it can be done by increasing the frequency level of the H-bridge converter at a higher range.

As the torque output gets maximized, pulse width modulation is introduced in the H-bridge system to avoid the disturbance in the armature current.it can be done by increasing the frequency level of the H-bridge converter at a higher range.

FIGURE 12: Diagrammatic representation of the pulse width modulation is shown below [6]

The below specification is referred from [6]

Ton - Time is ON (applied voltage)

Toff - Time OFF (applied voltage)

T - Time period.

Duty cycle =.

The average voltage of the DC motor can be shown in an equation below

Average = Duty cycle Ã- Vin [6]

When the motor is running at a constant speed the back emf of the motor is also remain constant.

As the back emf remain the same the motor running at constant speed and the armature current (Ia) is zero. PWM is one main part that is required for the operation of cascade control.

4. Software used to drive the Motors

4.1 Programming microcontroller in Flexible inverted board using C-language

In the flexible inverter board PIC microcontroller plays a major position in directing the pulse width modulation. The Ton time in the pulse width modulation (PWM) signal can be modulated or controlled by the microcontroller, as the microcontroller varies the time, the velocity of the motor changes with respect to time. The Programing language used in microcontroller is embedded C. The programming codes are downloaded in the microcontroller chip, the downloading approach can be done by a software development tool called MPLAB, this software exists in monitoring the systems, this software should be first installed in the PC, the programmers will write the codes to modulate the PI controller to acquire Applicable source from the current loop of the cascade control function. Once the codes are accepted according to the current loop [1], the programs can be downloaded in the microcontroller through universal serial bus or in circuit Debugger (ICD); ICD is a bus which interfaces PC system and the flexible inverter Board. [6]

In order to program the microcontroller examine whether the hardware components are interfaced with the controller. The programming language used for programming the controller is C language. In c-language the data's are classified in to input data and output data. The microcontroller send the information in analogue signal, where the C-language won't accept analogue signals .To avoid the situation ADC converter and encoder interface are introduced in the system. ADC stands for analogue to digital converter; it converts the analogue signal in to digital signals. Then the digital signals get received by the C-program as input data. In turns c-program will send the output data to the PWM unit. UART communication system is a bidirectional so that microcontroller and PC can communicate simultaneously. UART stands for universal asynchronous receiver transmitter. The basic diagrammatic representation for system communication with C-language is shown below

FIGURE 13: System communication in C - Programming Language.

In C-language firstly initialise all the functions required for the speed control of motor.

4.1.1Current sensor input:

The current in the motor coils is one important parameter in the effective running of the motor. So it is essential to measure the value of this current. The measurement of the current is performed by using special sensors call Hall Effect Sensors. The range of the current is determined by the rating of the motor. Any over current in the motor can badly damage the motor. The Hall Effect sensors produce a voltage corresponding to the phase current. This is fed to the ADC inputs of the micro controller where it is converted into the digital signals. This is then fed into the microcontroller program. Hence the current needs to be limited within specific limits.CL1, CL2 and CL3 are the three current sensors variables used in this coding. The bit ratio of the ADC input is 10 so the input data ranges from 0 to 1023. The maximum data limit for the current sensor is 1023.so the current sensor value in the C- code is initiated as

CL1 = 511; CL2 = 511; CL3 = 0;

4.1.2 Encoder input:

For any speed controller, the actual speed of the rotor forms the basis for the control signals. The speed control signal can be changed only if there is an error between the actual speed of the rotor and the desired speed of the rotor. If the measured speed is less than the desired speed then the PWM pulses are varying accordingly to increase the speed. To perform this action a shaft encoder is used. The shaft encoder uses an opto-mechanical system to generate pulses.

These pulses then are used to derive the speed of the rotor. A reference pulse is used as an indicator to count the pulse. This information is fed to the microcontroller, which then uses a special timing circuit that processes these encoder pulses. The motor speed to be accessed by the microcontroller needs to be stored in a variable within the micro controller code. The variable used in this program is a variable called rpm. This variable is accessed to calculate all functions related to the motor speed.

4.1.3 Pulse Width Modulation:

The MOSFET's in the circuit is used as switches. These MOSFET's are switched according to a PWM. To drive these MOSFETs' a gate driver circuit is required. The gate drive signal generates the voltage required for the operation of these MOSFET's. The PWM is generated by the microcontroller according to the program and is supplied to the gate drive circuit. The PWM signals are separate for each if the 3 legs of the MOSFET inverter. Each of the PWM requires a modulation index to generate the signal. These modulation indexes are stored in a register. The registers are named as PDC1, PDC2, and PDC3. These variables are very crucial in generating the PWM signals for the MOSFET drivers. Since data limit is 1023.

4.1.4 Initializing the code in C - language

Before performing any function in C-language, it requires an initialisation. It is important to initializing the variable of a function. Some the functions are initialized below.

Init PORT ()

This function initialize the digital input and output port or analogue input and analogue output of the microcontroller.

Init UART ()

It is one of pin in the microcontroller .The main function of the UART is used for bidirectional communication with PC. Since UART can able to detect the transmission speed in data transfer between the microcontroller and PC. The maximum transmission speed is around 19200.the data transfer won't exceed the limit.

Init PWM ( )

The input frequency of our PWM signal is 10kHz.the time limit for the modulation index is around 0-1474.in the h-bridge converter has two legs so each leg produces a PWM signal with a maximum time limit of 0-737. Hence the Ton time of PWM signal will be in 1:1 duty ratio.

Init ADC ( )

It is used to convert the analogue signals in to digital signals. In the microcontroller there are five pins reserved for the ADC inputs. During the data transmission ADC functions plays a important role in interrupting the signal. An initialisation is required for the interrupt to perform any function in C- language.

Init CAPTURE ( )

The capture function is mainly used to measure the frequency and time period of the PWM wave form generated from the two legs J30 and J31 pins of the H-bridge converter

InitTimer3 ( ) and InitTimer1 ( )

To set initial time in the microcontroller for the capture function and timer 1 set the starting time for the interrupt function happened in the UART communication system.


Interrupts are occurred only during the data transfer, when the transmission speed that is the baud rate is known means the interrupts can be added to the system easily.in our project the baud rate is 19200.the main function of the interrupt is used synchronize time period of PWM with the speed loop and the current loop of the motor. In our project four different type of interrupt service routine are used.

They are ISR_ADCInterput ( )

This interrupt is triggered when the ADC finishes its conversion and hence its get synchronized to the microcontroller PWM time base. From this all the application control code to be implemented in this interrupts service routine.

ISR_T1Interput ( )

The various information to the PC is transferred by using the UART communication link in this interrupts service routine. All the variables that are needed to be mentioned in this routine using standard C function sprint ( ).

ISR_U1RXInterput( )

Various information is transferred from the PC in to the C program. This routine concedes us to regulate the aspects of the program when it is running.

ISR_IC1Interput( )

It measures the speed value from timing data that are attained in the input capture module.

FIGURE 14 The connection diagram for the speed control of Dc motor is shown above


5 Results and discussion

As discussed earlier the various functions of hardware components in this project, this section discusses the details regarding how the project deals with comparing and evaluating the results. Project has a series of steps; each step is assigned with different operation techniques to execute the final results.

5.1 Initial connection test between MPLAB IDE and Flexible inverted Board

Initially the system needs to be interfaced using the flexible inverter board. This operation is performed by connecting the PC to the flexible inverted board. To connect the PC to the flexible inverted board, ICD 3 interface port is used to complete the connection. Since the data transmission speed in ICD 3 is high when compared with ICD 2, the power supply to the inverted board is supplied through the Dc power supply generator. The Initial conditions were set to the power supply generator where the voltage limit and current limit is zero. For the Dc motor maximum voltage supply is 24voltage in VDC and a current of 0.5 ampere is set in the power supply generator which is then connected to the inverter board. Once the initial conditions are set, the power generator is fitted with a track button which needs to be held and simultaneously the output button needs to be pressed. Once the output button is turned ON, the power is applied to the inverted board. On the other hand MPLAB IDE software is opened in the system, where a new file needs to be created then the required compiler for this project needs to be selected. Once these settings are done the debugger option in the MPLAB ICD 3 is chosen, the software will initialize the tool and a confirmation message was displayed on the screen which says "ICD 3 is connected". The codes for this were designed in the MPLAB software and burnt in the ds PIC microcontroller by ICD 3 interface.

5.2 Step 3, 4 & 5

One of the ADC input pin in the PIC microcontroller needs to be initialize as ADCBUF0. The maximum input range of ADC interrupt is 1023 since ADC input is initialized as IN1.

When IN1 is initialized as ADCBUF0 in C-language it can be written as



PDC1 = IN1;

IFS0bits.ADIF = 0;


Here IN1 is the data value for the trim port in the flexible inverted board. The maximum IN1 value is 1023. As mentioned earlier PDC1 is initialized as one leg part H-bridge converter, where PDC1 is 1474 and a unipolar pulse width modulation was generated. If IFS0bits.ADIF is zero, it means that the main used to initialize ADIF value is 0 in other words it is the default value.

PDC1 = 2*IN1;

Similarly in step 4 multiply the trim port input value with 2. Then the PDC1 input range will exceed so 'if' statements are used to limit the value of PDC1 from 0 to 1474.

To limit the values of PDC1 the code in C-language can be implemented as;

PDC1 = 2*IN1;

If (PDC1 > 1474)

PDC1= 1474;

5.3 Step6&7

The flexible inverted board consists of a gate triggered circuit in other words they are known as MOSFETS. Totally 6 MOSFETS are available in the flexible inverted board. In our project two MOSFET are used and both of them are connected to the legs of the H-bridge converter. The MOSFETS that are connected to H-bridge converter are 'U10 and U13' & 'U11 and U14'. To monitor and check if the MOSFETS are triggering the pulse or not it can be done by examining the test points available in the flexible inverted board. This is done using the oscilloscope where the test points are connected via probes as a result triggering pulse is produced. The diagrammatic representation of Square wave form is shown below.

FIGURE 15The above diagram represents the general pulse waveform

Depending on the modulation index value produced by the ADC input the duty ratio of the pulse fit modulation varies accordingly. In other words the modulation index is directly proportional to the duty ratio. Using appropriate C program the resulting waveform from the three different duty ratios was observed to be in the square shape. When the oscilloscope is connected to the test point J30, three different percentages were obtained due to the different duty cycles. The C codes that were used to obtain the waveforms are mentioned below:

C code for 50% duty cycle:

PDC1 = MI + 737;

PDC2 = MI - 737;

Manual calculation for 50% duty cycle

Since PDC1 = 1474

If PDC1/2 = 1474/2 = 737.

Resulting waveform for 50% duty cycle is shown below

FIGURE 16 wave from for 50% duty cycle

C code for 25% dutycycle:

PDC1 = MI + 1105.5;

PDC2 = MI - 1105.5;

Manual calculation for 25% dutycycle:

(PDC1 and PDC2 ) value for 50% duty cycle is 737

(PDC1 and PDC2) value for 75% duty cycle is 368.5

For 25% duty cycle add both 737 + 368.5 = 1105.5

Resulting waveform for 25% dutycycle:

FIGURE 17 wave form for 25% duty cycle

Code for 75% dutycycle:

PDC1 = MI + 368.5;

PDC2 = MI - 368.5;

Manual calculation for 75% duty cycle

For PDC1 and PDC2 is 737

Divide PDC1 and PDC2 by 2

The solution for for PDC1 and PDC2 is 368.5.

Resulting wave form for 75% dutycycle

FIGURE 18 wave form for 75% duty cycle

5.4 Step 7

The last operation is based on connecting the oscilloscope with the test point J30 in the flexible inverted board, similarly the same operation is performed in another test point J31. The triggered pulse obtained from the MOSFETS is shown below for the different duty cycle ratio as already mentioned in step 6.

Resulting waveform for 25% duty cycle:

FIGURE 19 Resulting wave form for 25% duty cycle in test point J31

Resulting wave form for 50% duty cycle is shown below

FIGURE 19 Resulting wave form for 50% duty cycle in test point J31

FIGURE 20 Resulting wave form for 75% duty cycle:

From above three wave forms each differs in their duty ratio. Then compare the waveform of J30 & J31. The different is happened because of delay or error occurred during the data transmission.

5.5 Step 10

In the initial condition of the trim port is set as zero. Then the duty cycle of the PWM 1 is high and PWM 2 will be low .In other words PWM1 is inversely proportional to PWM2. Similarly in the later condition when the trim port is turning toward the higher end. Now the duty cycle of PWM 2 is found to be more than 95%. The output of the PWM is determined from the oscilloscope. Since the value of PDC1 and PDC2 will be 1474.due to 1:1 duty ratio. The input data values are equally shared by both PDC1 and PDC2. In some conditions when the PDC1 = 2*IN1.the value of IN1 is 1023, and then value of PDC1 is 2046. As per the conditions mentioned earlier the value should not exceed the input data limit 1474. Such situation are handled with help of if statements. Using if statement how the condition is satisfied in C coding

PDC1 = 737+MI;


If (PDC1 > 1474)

PDC1 = 1474;

If (PDC2>1474)


This code C2=1474-PDC1 makes the motor to rotate at reverse direction.

When the above code is compiled and executed the resistivity value increased or decreased by manually tuning the trim port in the flexible inverted board. According to the resistance value in the microcontroller the amplitude and the current flow can be controlled.

5.6 Step 11

Ripple current and RL Load

Now connect the RL load with the connector of the flexible inverted board to calculate the ripple current. In the connector of the flexible inverted board has two points. They are considering as point A and point B. Ripple current can be calculated by a device called current probe. First connect the current probe to the point A of the connector and view the average value of the ripple current in the oscilloscope. The waveform for the average ripple current value for point A is shown below.

FIGURE 21 wave form for duty cycle1 with 1H and duty cycle 2 1L(point A)

1H - High Output

1L - Low Output

In this waveform the conditions are totally reversed when compared with the above waveform.

The duty cycle 1 with 1L and duty cycle 2 with 1H (point A)

FIGURE 22 wave form for duty cycle1 with 2L and duty cycle 2 1H (point A)

Once the ripple currents are calculated in point A. the similar operation is performed by the current probe in point B. the waveforms are shown below

FIGURE 23 waveform for duty cycle1 with 1H and duty cycle2 with 1L ( point B)

FIGURE 24 waveform for duty cycle1 with 2L and duty cycle2 with 2H ( point B)

5.7 Step 12

This step deals with calculating the offset and gain value of ripple current through current probe as discussed earlier. These values are mainly used for sampling the input data's from the microcontroller.

In order to calculate the offset and gain value the values need to be identified as shown in the tabulation below they are; ADC voltage, current sensor, PDC1 and PDC2. Initially the interface needs to be reloaded with the flexible inverted board. The PDC1 and PDC2 value can be determined by the watch option in MPLAB IDE software. The current sensor in the flexible inverted board has a test point J43. Then the current sensor value was measured by multi meter through the test point. For this a 24 voltage Dc motor the maximum current sensor value obtainable will be 2.57voltage. Initially set the trim port value to zero, then check the current sensor value by a multi meter where it showed 2.57. By increasing the resistivity of the trim port the current sensor and ADC voltage will be gradually decreased however at one stage the ADC voltage gradually decreases to zero. Later the ADC voltage value increased slowly but the current sensor constantly decreased as shown in the tabulation. These values were recorded in the tabulation.

Subtracted ADC voltage value from PDC1 value and the average value result was recorded in the new column. Then the average value for the new column is calculated.

Table 2 Tabular column for calculating offset and gain values

ADC voltage

Current sensor



PDC2 - ADC voltage


















































Manual calculation for the above tabulation is shown below

Offset bit = (PDC1 - ADC voltage) / total number values

(PDC1- ADC voltage) = 13.49 + 117.57 + 261.21 + 528.21 + 756.9993 + 956.28 + 1118.93 + 1412.6 = 5588.7793

PDC1-ADC voltage = 5588.7793

Total number of values = 9

Average (PDC1 - ADC voltage) = 5588.7793/9 = + 620.9754778.

Calculate the total ADC voltage

Total ADC voltage =27.51 + 25.43 + 21.79 + 20.51 + 17.79 + 0.0007 + 3.72 + 4.07 + 18.4 = 132.5

Offset bit = + 620.9754778./ 132.5 = 4.4602 bit

5.8 Step 13

In this section connect 24 volt Dc motor to the flexible inverted board. When the power supply is turned ON the motor rotates at a particular speed and this speed of the motor rotates according to the duty ratio produced by the H-bridge converter. Initially test all the conditions to verify the working condition of the motor. The motor used here is fitted with an encoder that is attached together. Since the flexible inverted board has an encoder detector the encoder part of the motor was connected to the encoder detector, thus the motor satisfies the conditions mentioned above.

5.9 Step 14

In this step, J14 pin of the flexible inverted board is interfaced together with the system through a cable. Using Lab view software's the Tacho range, RPM can be determined.

PDC1, PDC2 and their corresponding duty cycle percentage are viewed.

Like this similar operation

Table 3 Tabular column for calculating voltage vs speed






Duty 1 %

Duty 2 %






















































































To calculate the value of the k

K = Vdc12 - Vdc1/RPM12 - RPM1

K = 19.6-18.1/1919 - 1776

K = 0.0104

As per the requirements from the tabulation plot the graph for Vdc(voltage) vs RPM

The graph representation is shown below

FIGURE 25 Voltage vs Speed

5.10 Step 15

5.10.1Current loop

Once the average value of the ripple current and the offset values are calculated, to control the speed of the motor, firstly the applied voltage of the motor should be controlled. Interestingly the applied voltage can be determined from the current loop of the proportional and Integral controller in other words as PI controller. Since the operation of PI controller is explained before itself. In the PI controller current plays the inner loop, and it is 10 times faster than the outer loop. So the inner loop is executed first. A step input given to the PI controller. The result expected from the output of the PI controller as a step output with peak over shoot.

This peak over shoot increases the steady state error also increases. In turns steady state error produces a voltage drop in the motor. So the speed of the motor gradually decreases. This situation can be overcome by adjusting the gain of both proportional and integral. The maximum peak over shoot level is 7.5%. If the level exceeds, the output of the current loop is not in a stable condition. If the system is not stable , it is difficult to control the speed of the motor . the graphical representation of the expected current loop is shown below.

FIGURE 26 step response output for current loop

In the above step response the ia* and ia are the demand current and the armature current.

Since the current sensor value 1023 .

Two current sensors are used.

They CL1 and CL2

The armature current ia = 511

Demand current ia* = 511

E is the error

E = demand current - armature current

E = ia* - ia

E = 511 - 511 = 0;

According to the calculation shown above .The code is compiled in C-language for the current loop.

In the coding

First initiate the gain values of the PI controller as kpi and kii.

int kpi, kii;



Then initialize the error, armature current and demand current as i_error, ia and ia_demand

int ia, ia_demand, i_error;

ia = CL1; (initialize current sensor 1 as armature current of the motor)

CL1 = 511;( initialize the value of current sensor 1 as 511)

ia_demand = 511; (demand armature current)

i_error = ia_demand - CL1;( Error in the armature current can be determined by subtracting the armature currenr (ia) from the demand armature current(ia*). The expected error should be zero. when the above code is executed in MPLAB software. In the beginning the error is not zero. Some time the current sensor value differs. As per the code the expected CL1 value should 511.

In this condition, a new set of code is implemented. In this code , if statements are used for the CL1 value. Then the current sensor value will be within the range.

if (510< CL1 && CL1<517) the value CL1 ranges from (511 to 517)

The manual tuning of kpi and kii changes CL1 from 511 to some other value.

As a result error occurs in the peak over shoot.

For example if CL1 is 514, which is displayed on the watch of MPLAB

Since the expected CL1 is 511 but CL1 is 514

The error difference between the expected and the present value is 3.

The avoid the error difference in CL1 a simple code is designed below

CL1 = CL1 -3; ( if CL1 is 514 , 514 - 3 is 511).

The error is zero but the peak over shoot is still high. This is due integral wind up function because the integral added with kii in PI controller. To avoid this error separate code is executed in C coding.

The variable zi is initialized as integral accumulator and its value is 737.





the above code keeps the zi value within the range.

Since i_error = 511

zi = 737 + 511

zi = zi+i_error; (anti wind up code added with an error)

In order to avoid the integral error multiply integral accumulator with integral gain (kii).

kii * zi (eqn 1)

Multiply the error with the gain of proportional.

kpi * i_error (eqn 2)

add both the eqn to get the saturated modulation index. This function will reduce the steady state error and peak over shoot.

mi = (kpi*i_error) + (kii*zi);

From this code the expected peak over shoot is obtained with zero steady state error.

The expected current loop wave form implemented from the code is shown below

In this wave form over shoot is high.

To reduce the over shoot and stead state error manually tune the kpi and kii value.

Manual tuning is like a iteration method to get a particular solution after many comparisons take place between kpi and kii values. The expected output is not yet determined. So the expected output is still under process.


[1]D.J.Atkinson, "Control of Electric drives," EEE 8014 lecture notes, School of electrical, electronic and Computer engineering, Newcastle University,2011.[c]

[2]R.Roberge, "Carbon brush performance and application in the pulp and paper environment", National Electrical Carbon Products, 2001.

[6]E.A.CHOON, "DCmotor speed control using microcontroller pic16f877a", 2005, pp. 1-64.

[3]K.Hameyer, R.J.M.Belmans, "Permanent magnet excited brushed DC motors" Dept. of Electrical. Engineering. Katholieke University, Vol. 43, 1996, pp. 247-255

[a]CONDIT, R. (2004) Brushed DC Motor Fundamentals Microchip Technology Inc.

[5b]P.Chevrel, L.Sicot, S.Siala, "Switched LQ controller for DC Motor Speed and Current Control: a comparison with cascade control", 1996.

[4]G.J.Atkinson, "Electrical Power and Control Project," EEE8075 (Semester 1) lecture notes, School of electrical, electronic and Computer engineering, Newcastle University, 2011.

[7]M.V.Ramesh, J.Amarnath, S.Kamakshaiah, G.S.Rao, "SPEED CONTROL OF BRUSHLESS DC MOTOR BY USING FUZZY LOGIC PI CONTROLLER" ARPN Journal of Engineering and Applied Sciences.Vol.6, NO. 9, 2011.

[8]R. K. Munje, M. R. Roda, B. E. Kushare, "Speed Control of DC Motor Using PI and SMC" IPEC, 2010 Conference Proceedings, 2010, pp.945- 950.

DS pic reference

[2]. (2010) dsPIC30f3010 Data Sheet. Microchip Technology Inc.

[16].D'SOUZA, S. (2004) sensor less BLDC Motor Control Using dsPIC30f2010. Microchip Technology Inc.

[18]. ELLIOTT, C. & BOWLING, S. (2004) Using the dsPIC30F for senseless BLDC control. IEEE Inc.

[20]. HUDDLESTON, C. (2007) Intelligent sensor design using the microchip ds PIC [electronic resource]/ by Creed Huddleston., Elsevier/News.


J. Plantier, H. Aziza, J.M. Portal, C. Reliaud, A. Regnier, J.L. Ogier, "EEPROM tunnel oxide lifetime reliability prediction based on fast electrical stress tests" ELECTRONICS LETTERS Vol. 46 No. 23, 2010.

Tang Yiliang, Cui Wenjin, Xie Xiaorong, Han Yingduo, Man-Chung Wong "80Cl96MC Microcontroller-based Inverter Motor Control and IR2130 Six-output IGBT Driver" Department of Electrical Engineering and Faculty of Science and Technology, 1999, pp.665-667.[FIGURE9 and]

David Cook "CHAPTER 14 Variable Resistors ROBOT BUILDING FOR BEGINNERS", 2010, pp 173-191.[trimport]

To export a reference to this article please select a referencing stye below:

Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.

Request Removal

If you are the original writer of this essay and no longer wish to have the essay published on the UK Essays website then please click on the link below to request removal:

More from UK Essays

We can help with your essay
Find out more