You are on page 1of 7

Download full-size image

Figure 8.7. A typical PWM signal.

The amplitude is usually fixed by the logic 1 level of the microcontroller output which
depends on the power supply voltage. In some applications, it may be necessary to use
external circuitry to increase the amplitude. In this project, we will be using the output
logic 1 level of the microcontroller which is +3.3 V.
The frequency depends on the application. In this project, we will generate a PWM
signal with a frequency of 40 kHz. This is the frequency commonly used in
most ultrasonic applications, such as distance measurement, ultrasonic cleaning, and
so on.
The duty cycle, denoted by D, is the ratio of the ON time to the period of the signal,
i.e. D = M/T. D can range from 0 to 1 and is sometimes expressed as a percentage, i.e.
from 0% to 100%. The power supplied to the load is controlled by varying the duty
cycle. Figure 8.8 shows signals with different duty cycles.

Download full-size image


Figure 8.8. PWM signals with different duty cycles.

Many electronic circuits such as electric motors, solenoids, LEDs and so on average


the applied ON–OFF signal in their operation. The average voltage used by these
circuits can be expressed as follows:
 Vavg = D∗Von
where Von is the logic voltage level during the ON time. With a 3.3 V supply voltage,
the average voltage becomes
 Vavg = 3.3 × D
Thus, the average voltage supplied to the load is directly proportional to the duty
cycle of the PWM signal output by the microcontroller.
In this project, the duty cycle of the PWM waveform is configured to be 50%.
The block diagram of the project is shown in Figure 8.9.
Download full-size image
Figure 8.9. Block diagram of the project.

8.2.2 Project Hardware
The circuit diagram of the project is shown in Figure 8.10. The PIC32MX460F512L
microcontroller has five pins named OC1, OC2, OC3, OC4 and OC5 that can be used
to generate PWM signal in hardware and independent of the CPU operations. Thus
the CPU can perform other tasks while the PWM signal has output continuously from
the microcontroller.
Download full-size image
Figure 8.10. Circuit diagram of the project.

In this project, the 40 kHz PW1 signal is output from pin OC1 (or RD0, pin 72) of the
microcontroller.
If you are using the LV-32MX V6 development board, then the following jumper
must be set as follows:
 DIP switch SW20, jumper 8, set to ON
8.2.3 Project PDL
Before developing the PDL for this project, it is important to understand how the
project works.
The PWM module inside the PIC32 microcontroller uses a timer to control the signal
frequency and duty cycle. The period of the generated PWM signal is given by the
following:
 PWM Period = [(PR + 1) × TPB × (Timer prescaler value)]
where PR is the value loaded into the period register, and TPB is the clock period of
the peripheral clock. Assuming a peripheral clock frequency of 80 MHz, the
peripheral clock period is given by the following:
 TPB = 1/(80 × 10−6) = 0.0125 × 10−6 s
We are normally interested in finding the value to be loaded into the period register.
Assuming that we are using Timer 2 (Timer 1 cannot be used in PWM mode), the
value loaded into this register is calculated as follows:
Also,
 PWM frequency = 1/[PWM Period]
The PWM duty cycle is specified by writing to the OCxRS register. The maximum
PWM duty cycle resolution is calculated using the following formula:
where, FPB is the peripheral clock frequency, and FPWM is the clock frequency of
the PWM signal to be generated.
The specifications of this project are summarized below:

Frequency of the PWM signal = 40 MHz (or,
period = 0.025 × 10−3 s)

Peripheral bus clock frequency = 80 MHz (or 0.0125 × 10−6 s)

Timer to be used = Timer 2

Timer 2 prescaler value = 1

Duty cycle = 50%.
The value to be loaded into period register PR2 is calculated as follows:
The maximum PWM resolution is calculated as follows:
The steps for configuring the PWM module for the above specifications are given
below (notice that since we are using output pin OC1, the register OCxCON is the
register OC1CON):

Calculate the PWM period (0.025 × 10−3)

Calculate the PWM duty cycle (50%)

Use Timer 2 in 16-bit mode

Clear register OC1CON, bit 5 (OC32) for 16-bit operation

Load PR2 with decimal 1999

Load OC1RS low 16-bits with duty cycle (50% duty cycle corresponds to
1999/2 = decimal 1000)

No interrupts required

Set OCM bits of OC1CON to six to enable PWM mode of operation

Select Timer 2 as the timer source

Clear TCKPS bits of T2CON to set Timer 2 prescaler to 1

Set bit ON of T2CON to enable Timer 2

Set bit ON of OC1CON to enable OC1CON.
Figure 8.11 shows the PDL of this project.

Download full-size image


Figure 8.11. PDL of the project.

8.2.4 Project Program
Figure 8.12 shows the program listing (called PWM.C). At the beginning of the
program pin OC1 (RD0) of the microcontroller is configured as an output pin. Then,
function CONFIGURE_PWM_MODULE is called to configure the OC1CON and the
TIMER 2 registers to generate the 40 kHz PWM wave with the 50% duty cycle. The
following code shows how the configuration is done:

Download full-size image


Figure 8.12. Program listing of the project.

void Configure_PWM_Module(void)
{
  T2CONbits.T32 = 0;               // Timer 2 in 16 bit
mode
  OC1CONbits.OC32 = 0;             // 16 bit operation
  PR2 = 1999;                      // Load PR2
  OC1RS = 1000;                    // Load duty cycle
  OC1CONbits.OCM = 6;              // Enable PWM module
  OC1CONbits.OCTSEL = 0;           // TIMER 2 is the
source
  T2CONbits.TCKPS = 0;             // Set Timer 2
prescaler = 1
  T2CONbits.ON = 1;                // Enable Timer 2
  OC1CONbits.ON = 1;               // Enable OC1CON
}
The rest of the main program consists of an endless loop where the PWM module
runs in the background.
Figure 8.13 shows the PWM waveform generated in this project.

Download full-size image


Figure 8.13. The generated PWM waveform.

Read more
View chapterPurchase book
Power and Telemetry
Robert D. Christ, Robert L. WernliSr., in The ROV Manual (Second Edition), 2014
7.2.2.3 PWM control
Pulse width modulation (PWM) is a modulation technique that generates variable-
width pulses to represent the amplitude of an analog input signal. The output
switching transistor is on more of the time for a high-amplitude signal and off more of
the time for a low-amplitude signal. The digital nature (fully on or off) of the PWM
circuit is less costly to fabricate than an analog circuit that does not drift over time.
PWM is widely used in ROV applications to control the speed of a DC motor and/or
the brightness of a lightbulb. For example, if the line were closed for 1 μs, opened for
1 μs, and continuously repeated, the target would receive an average of 50% of the
voltage and run at half speed or the bulb at half brightness. If the line were closed for
1 μs and open for 3 μs, the target would receive an average of 25%.
There are other methods by which analog signals are modulated for motor control, but
OCROV and MSROV systems predominate with the PWM mode due to cost and
simplicity of design.
View chapterPurchase book
Direct power control of three-phase PWM-
rectifier with backstepping control
Arezki Fekik, ... Sundarapandian Vaidyanathan, in Backstepping Control of Nonlinear
Dynamical Systems, 2021
Abstract
Pulse Width Modulation (PWM) rectifiers belong to the best solutions to improve the
quality of electrical energy transfer from a source to a receiver. In fact, this chapter
proposes a method for regulating the three-phase PWM rectifier and ensuring the
elimination of total harmonic distortion to obtain a non-contaminated system
operating within a unity power factor. This regulation method is contracted via
analogy to the direct torque control (DTC) of an electrical machine. In place of the
torque and stator flux, active and reactive power are the corrected variables. That
work suggests the study of a direct power control (DPC) of a three-phase PWM
rectifier by deploying a backstepping for the correction of the DC bus voltage. The
assessment of the validity and dynamic performance of the control methods was
checked by simulation using MATLAB / SIMULINK environment under various
conditions, such as the variation of the reference voltage and the load. The results of
the simulation showed the robustness of direct power control based on the
backstepping control technique.
View chapterPurchase book

You might also like