# SPWM Generator Module (without Using Microcontroller)

265

1

## Introduction: SPWM Generator Module (without Using Microcontroller)

Hello everyone,welcome to my instructable! I hope you all are doing great. Recently, I got interested in experimenting with PWM signals and came across the concept of SPWM (or Sinusoidal Pulse Width Modulation)where the duty cycle of a train of pulses is being modulated by a sine wave. I came across a few results where such kind of SPWM signals can easily be created using a microcontroller where the duty cycle is being generated by using a lookup table that contains the necessary values to implement the sine wave.

I wanted to generate such SPWM signal without microcontroller and thus I used Operational Amplifiers as the heart of the system.

Lets get started!

### Supplies:

2. LM358 dual comparator IC
3. 14 pin IC base/socket
4. 10K resistors-2
5. 1K resistors-2
6. 4.7K resistors-2
7. 2.2K resistors-2
8. 2K variable resistor(preset)-2
9. 0.1uF ceramic capacitor-1
10. 0.01uF ceramic capacitor-1
12. Veroboard or perfboard
13. Hot glue gun
14. Soldering equipments

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Theory: Explanation of Signal Generation for SPWM

To generate the SPWM signals without a microcontroller, we need two triangular waves of different frequencies (but preferably one should be the multiple of other ). When these two triangular waves are compared with each other using a comparator IC such as LM358 then we get our required SPWM signal. The comparator gives a high signal when the signal at the non inverting terminal of the OpAmp is greater than that of the signal at the inverting terminal.So when high frequency triangular wave is fed at the non inverting pin and the low frequency triangular wave is fed into the inverting pin of the comparator, we get multiple instances where the signal at non inverting terminal changes amplitude several times before the signal at the inverting terminal. This allows for a condition where the OpAmp output is a train of pulses whose duty cycle is governed by how the two waves are interacting.

## Step 2: Circuit Diagram: Explanation and Theory

This is the circuit diagram of the entire SPWM project consisting of two waveform generators and a comparator.

A triangular wave can be created using 2 operational amplifiers and thus a total of 4 OpApms will be required for the two waves. For this purpose I have used the LM324 quad OpAmp package.

Let us see how the triangular waves are actually generated.

Initially the first OpAmp acts as an integrator whose non inverting pin is tied to a potential of (Vcc/2) or half the supply voltage using a voltage divider network of 2 10kiloOhm resistors. I am using 5V as the supply so the non inverting pin has a potential of 2.5 volts. A virtual connection of the inverting and non inverting pin also allows us to assume the 2.5v potential at inverting pin which slowly charges the capacitor. As soon as the capacitor is charged to 75 percent of the supply voltage, the output of the other operational amplifier which is configured as a comparator changes from low to high. This in turn starts to discharge the capacitor(or de-integrates) and as soon as the voltage across the capacitor falls below 25 percent of the supply voltage, the output of the comparator gets pulled low again, which again starts to charge the capacitor. This cycle starts again and we have a triangular wave train. The frequency of the triangular wave is determined by the value of the resistors and capacitors used. You can refer to the image in this step to get the formula for frequency calculation.

Okay so the theory part is done.Let's get building!

## Step 3: Gathering All the Required Parts

The images show all the parts required to make the SPWM module. I have mounted the ICs on the respective IC base so that they can be easily replaced if need be. You can alos add a 0.01uF capacitor at the output of the triangular and SPWM waves in order to avoid any signal fluctuations and keep the SPWM pattern stable.

I cut out the required piece of veroboard in order to fit the components properly.

## Step 4: Making the Test Circuit

Now before we start soldering the parts, it's necessary that we make sure that our circuit works as desired and thus it is essential we test out our circuit on breadboard and make changes if necessary. The above image shows the prototype of my circuit on breadboard.

## Step 5: Observing the Output Signals

To make sure that our output waveform is correct it becomes essential to use an oscilloscope to visualize the data. Since I do not own a professional DSO or any kind of oscilloscope,I got myself this cheap oscilloscope- DSO138 from Banggood. It works just fine for low to medium frequency signal analysis. For out application we will be generating triangular waves of frequencies 1KHz and 10KHz which can easily be visualized on this scope. Of course you can get much more reliable information of signals on a professional oscilloscope, but for quick analysis, this model works just fine!

## Step 6: Observing the Triangular Signals

The above images shows the two triangular waves generated from the two signal generation circuits.

## Step 7: Observing the SPWM Signal

After successfully generating and observing the triangular waves, we now have a look at the SPWM waveform that is generated at the comparator output. Adjusting the tie base of the scope accordingly enables us to properly analyze the signals.

## Step 8: Soldering Parts on to the Perfboard

Now that we have our circuit tried and tested, we finally start soldering the components on to the veroboard to make it more permanent. We solder the IC base along with the resistors, capacitors and variable resistors according to the schematic. It is important that the placement is components is such that we have to use minimal wires and most connections can be made by solder traces.

## Step 9: Finishing the Soldering Process

After about 1 hour of soldering I was complete with all the connections and this is what the module finally looks like. It is quite small and compact.

## Step 10: Adding Hot Glue to Prevent Shorts

In order to minimize any shorts any shorts or accidental metallic contact at the solder side I decided to protect it with a layer of hot glue. It keeps the connections intact and isolated from accidental contact. One can even use insulating tape to do the same.

## Step 11: Pin-out of the Module

The above image shows the pinout of the module that I made. I have a total of 5 male header pins of which two are for power supply (Vcc and Gnd ), one pin is to observe the fast triangular wave, the other pin is to observe the slow triangular wave and finally the last pin is the SPWM output. The triangular wave pins are important if we want to fine tune the frequency of the wave.

## Step 12: Adjusting the Frequency of the Signals

The potentiometers are used to fine tune the frequency of each triangular wave signal. This is due to the fact that not all components are ideal and thus the theoretical and practical value may differ. This can be compensated by adjusting the presets and correspondingly looking at the oscilloscope output.

## Step 13: Schematic File

I have attached the schematic layout for this project. Feel free to modify it according to your needs.

I hope you like this tutorial.

Until next time :)

36 1.4K
34 9.8K
764 45K