KRAKKUS.COM

PWM Tool

Real-time waveform display on a digital multimeter or oscilloscope, showcasing dual-signal PWM generator with dead time and inverted signal.

This is a dual-signal-PWM-generator. The second signal is inverted and never overlaps with the first one (dead time).

Oscillator circuit

Op-Amp

The entire circuit it made out of 3 stages, the first one is the "Oscillator", it will create the base frequency for the PWM signals.

An op-amp based oscillator circuit diagram, a crucial component in generating base frequencies for PWM signals, with notes and markings on technical components and visible objects.

At the heart of this oscillator is an op-amp which we will use in a very simplistic way.

I will first explain and build the individual parts, and when that is done explain how they work together with the op-amp.

Electronic circuit board with various components attached, featuring small pins connected via wires for a digital circuits or microcontrollers project. A breadboard circuit with resistors and capacitors mounted on a white baseplate, featuring parallel slots for connectors and components, with visible dirt or debris indicating use.

We will build the circuit on a so-called bread-board.

On the back we can see how the pins are connected to each other.

The long rows for power, and the short ones for connecting components.

Electronic breadboard with various components, including yellow connectors or resistors and white resistors connected by jumper wires, ideal for prototyping and testing electronic circuits.

This is a power supply for breadboards, it takes 12 volts from a barrel jack or 5 volts from a USB-C charger.

It provides power and ground to the long rails on the board, 5 volts on left and 3.3 volts on the right.

Electronics enthusiast tests a breadboard circuit with an oscilloscope and probe, verifying power rails and signal variations in a laboratory setting.

We need 5 volts for this circuit, so lets test if the rails are powered.

Regular multi-meter probes don't fit in the breadboard holes.

Those probes use banana-plugs, so I take some banana-plug-to-crocodile-clip cables and put them into the multi-meter.

Those clips then grab jumper-wires which DO fit in the board. That's a free tip from me :)

Other free tip... put the multi-meter in DC voltage mode, not AC ;)

5 volts, perfect!

Electronic components and circuits in progress on a breadboard, featuring resistors, capacitors, and possibly integrated circuits, with an oscilloscope probe nearby. A circular electronic module features a ring of LED lights and multiple pins, likely used in lighting or sensor applications, with two op-amps inside an integrated circuit.

Now we install the IC which contains the op-amp, there are actually 2 of them inside!

Lets look at the print on the IC to see the model and make!

Yup, can't see shit with this thing!

Hand-drawn circuit diagram illustrating electronic component connections and troubleshooting steps for an LM3668 op-amp IC.

Well, got a schematic on paper, very useful when connecting it to the rest of the circuit!

That notch on the top is also on the actual IC, so you know which way is up.

An engineer works on a printed circuit board, connecting components and troubleshooting electronic circuits. An electronics enthusiast adjusts and secures components on a circuit board, featuring an integrated circuit chip and various resistors and connectors. A prototype circuit board featuring an integrated circuit and various electronic components, including resistors, capacitors, and a USB connector, in the early stages of development. Electronic circuit board prototype featuring ICs, resistors, and capacitors, with jumper wires connecting components on a grid-like pattern.

So the IC has a VCC pin at the top right. Lets get 5 volts from the left power rail to that pin.

If we cut the wire 3 points further than the hole it should go into, then it will be just long enough after stripping the coating.

Now for the ground pin, that's on the bottom left.

An electronic circuit on a breadboard being tested with a multimeter, ensuring proper power flow to an IC chip.

I know this looks like overdoing it, but I really want to be sure power actually goes to the IC.

Resistor divider

Hand-drawn diagram illustrating a resistor divider and oscillator circuit, featuring mathematical equations and component symbols for understanding electronic design and behavior.

The next part of the circuit is a resistor divider, I love those things, really.

They are two equal resistors in series, between 5 volts and ground.

That results in the voltage in between them is 2.5 volts.

The resistors are of really high value, so little current goes through them.

And that means that the midpoint voltage can be easily influenced, which is exactly what we will do.

The op-amp can output a signal either 5 volts or ground.

This voltage is send to the same midpoint voltage, but through a resistor smaller in value, so it has a big influence on the final midpoint voltage.

That will be either close to 5 volts, or close to ground, but not all the way, and that last bit is important.

Electronic circuit development board setup with microcontroller and jumper wires, accompanied by a digital multimeter for voltage testing and measurement. Electronic components and tools on a workbench, featuring a printed circuit board with integrated circuits and an older digital oscilloscope for testing and analysis.

First we do the two 1 mega-ohm resistors.

I also like to test every component before placing them on the board, to make sure they work, and that the value is correct.

These component-testers are really inexpensive from china.

I have the circuit schematic and the IC schematic next to me.

And we just saw how the breadboard is wired underneath.

That and taking your time makes it not that difficult to get the components where they should go.

Electronic enthusiast tests a circuit prototype on a breadboard, measuring voltage with a digital multimeter and verifying successful connections among various components.

More testing! I want to see the midpoint voltage at 2.5 volts.

Great, that works!

Electronic circuit board with IC, jumper wires, coil, and capacitor, featuring a Y-type connector and test points for prototyping and testing purposes.

Now for the final resistor that connects the 2.5 volts to the first op-amps output.

Resistor-capacitor pair

An electronic oscillator circuit featuring a series of resistor-capacitor elements and a silicon rectifier diode, designed to generate a specific frequency or waveform.

Quick note, that final voltage is also fed into the positive input of the op-amp, just as the final voltage of this next small circuit will be fed to the negative input of the op-amp.

The op-amps output will also be fed through another resistor.

And as the output is either 5 volts or ground, it will either charge or discharge this capacitor here.

The voltage that the capacitor is at will be shared with the negative input of the op-amp.

Electronic circuit board and handheld device with LCD screen and buttons, featuring integrated circuits, resistors, and breadboard connections for testing and measuring electrical parameters.

More testing, this time the capacitor, and I will now stop showing you that, as I suspect you get the point.

Electronics enthusiast works on a circuit board prototype, connecting components and testing with an old calculator for scientific notation calculations.

Now placing the resistor. But I also need a connection to the negative input.

So I decide to remove the resistor, do that wire first and then reinsert the resistor.

Electronic enthusiast works on a breadboard circuit, connecting components and preparing to test its performance with an oscilloscope. Portable oscilloscope captures electrical signal waveforms with precision and clarity, ideal for measuring and analyzing various signals in electronic circuits.

Time to hook up my oscilloscope and see the signal.

First the signal at the capacitor charging and discharging.

It should look more like sort of a triangle, but this is also good I guess.

Electronic circuit prototyping and testing on a breadboard, featuring capacitor charging and discharging signals and op-amp output measurements. Electronic frequency analyzer or oscilloscope displaying various waveforms and signal patterns on its screen, used for measuring and analyzing frequency content in a laboratory or workshop setting.

And now the "modified" op-amps output, that midpoint voltage with 3 resistors I mean.

Yikes, that should look more like a square-wave signal. Guess we will have to fix that!

But first, lets look at how this circuit actually works.

Explaining the first circuit

A hand-drawn diagram illustrating an electrical circuit featuring a transformer, lamp, switch, capacitor, and resistors, showcasing connections and controls for managing electricity flow.

The output of the op-amp goes high when the positive input voltage is greater then the negative input. And goes low when positive input is lower than the negative one.

Lets start with a high output and see what that does to the circuit.

The resistor divider voltage, that goes to the positive input, is close to 5 volts, but not all the way.

It also is charging the capacitor like this. And that will actually reach the 5 volts, and overtakes that other voltage.

Now the negative input voltage is actually greater than the positive one. And so, the op-amp switches it's output to ground.

The resistor-divider-circuit now goes the other way, voltage close to ground, but again, not all the way, so the discharging capacitor can again overtake that and the op-amp output will switch high again.

And so, that high-low sequence continues, making it an oscillator, very cool huh?

Fixing the signal

I suspect the 1 kilo-ohm resistor connected to the capacitor taxing the op-amp to much with to much current draw, deforming the square wave signal.

Lets change that to a 10 kilo-ohm resistor.

An oscilloscope display shows a significant improvement in signal quality after replacing a capacitor with a 10 kilo-ohm resistor, resulting in a more square wave shape and a triangular charging curve. Electronic signal analyzer displays waveform analysis with adjustable settings for measuring frequency content and amplitude of electrical signals.

That looks more square to me!

Also the charging curve looks more like a triangle.

Big improvement.

An electrical circuit diagram featuring a voltage source and resistor, showcasing current flow and grounding point.

Now we have a nice triangle signal, we can use that in the next circuit.

Variable duty cycle with potentiometer

Electrical circuit diagrams and notes on variable duty cycle with potentiometer and op-amp, illustrating concepts in electronics and electrical engineering.

The main component for the second circuit is also an op-amp.

This time we will be using a potentiometer.

It will let us choose any voltage between the voltage attached to it and ground.

Internally it is a variable resistor-divider, with a total resistance of 10 kilo-ohms.

That, together with the op-amp, will allow us to change the duty-cycle of the PWM signal.

We connect that output voltage to the positive input of the op-amp.

To the negative input, we connect the triangle signal that the previous circuit created.

And then..... done! The op-amp now outputs a variable PWM signal.

an op-amp circuit generates a variable PWM signal on a breadboard, with test probes and a digital multimeter monitoring the output. An engineer works on an electronic project, using a multimeter and soldering tool to test and assemble components on a breadboard. Electronic circuitry with op-amp outputting variable PWM signal, featuring resistors, transistor, and multimeter for testing and measurement purposes. An individual troubleshoots an electronic device with a printed circuit board, using a digital multimeter to measure electrical parameters while connecting wires and testing components in a workshop or lab setting.

First, the potentiometer, it has three wires and I do not know which one is what.

I try to find the two wires that have a fixed resistance no matter the position of the knob.

These will be the VCC and ground wires, the order does not matter.

The third one then will be the one outputting the variable voltage.

So I give it 5 volts and ground and then measure the output voltage of the third wire.

Did you spot the problem?

I forgot to power the circuit!

That's better! We have a variable voltage.

Electronic circuit board featuring an integrated circuit and various components, with connectors and wires connecting it to other parts of a larger system.

That output voltage now goes to the positive input of the second op-amp in the IC.

It is on the right side, remember that schematic of the IC?

An electronics enthusiast works on a breadboard in a lab setting, surrounded by components and tools, as they construct and test an electronic circuit.

Now we need to transport the output signal of the first circuit on the left, to the negative input of the second op-amp.

At this point, again, I am just following the schematics and remembering the connector strips at the back of the breadboard. So there is no thinking involved here.

Electronic enthusiast assembles prototype on breadboard, connecting components with wires and using pliers for precision adjustments in a lab setting. Visualizing electronic signals and waveforms on an oscilloscope screen, with multiple traces and measurement markers for analysis. Portable oscilloscope displaying various electrical signal patterns with amplitude, timebase, and measurement parameters for testing and analysis. An oscilloscope display shows two waveforms with varying frequency content and amplitude levels, allowing for analysis of electrical signals in various applications.

Time to hook up the oscilloscope again a have a look at the new output signal.

That looks great! When turning the knob of the potentiometer, we can see the duty-cycle change.

And at both 0 percent and 100 percent duty-cycle the signal flat-lines, either to 5 volts or ground.

Explaining

A hand-drawn schematic diagram illustrating an electrical circuit with a triangle signal and variable voltage from a potentiometer, exploring duty-cycle changes and flatlining at 0% and 100%.

Now how does al that work? Or better, why?

Well, first we have the triangle signal.

And then there is that variable voltage from the potentiometer.

As long as the positive input of the op-amp, the 3 volts, is greater than the voltage of the triangle-signal, the output of the op-amp is high, like this.

But then they cross, and the op-amp's output goes low, like this.

Until they cross again!

Now what if the 3 volts signal from the potentiometer was lower, like 2 volts?

In that case the first crossover would happen sooner, and the second later, making the output signal low, for longer!

Signal inverter

A hand-drawn diagram of a signal inverter circuit, featuring a transistor amplifier and diodes to amplify and invert an input signal.

This is the third and final circuit, the signal inverter!

And also non-overlapping like I said in the intro.

I'm starting to see a pattern here! More op-amps!

And another resistor-divider! This one is fancy, 3 resistors in series even.

The mid-points are connected to each there own op-amp, but not the same-input, very important.

This has to do with a sequence of events that have to happen.

The other inputs of the op-amps are connected to the same now-variable PWM signal.

And the final PWM output signals.

To understand why this works we need to know 2 things.

First: The input signal is a square wave, but zoom in close enough and the signal does not go from 5 volts to 0 volts or back in an instant, it takes some time.

Second: When the inputs of an op-amp flip, meaning, the other one is now bigger than the other, the output of the op-amp also flips from high to low or back.

So, the PWM signal dropping from 5 volts to 0 volts, first passes the 3.3 volts on the first op-amp, and then the 1.6 volts on the second.

And because the second one has the inputs switched, first signal 1 goes down and only after that signal 2 goes up, no overlap! Same goes the other way around.

Pretty clever right?

Electronic components on a breadboard, featuring voltage dividers and RC filters, showcasing a hands-on learning project in electronics or electrical engineering.

Here is the second IC with the other 2 op-amps we need.

Electronic circuit board featuring resistors and possibly capacitors or inductors, with connectors for interfacing with other circuits or systems.

Add some power.

Electronic components and wires connected to a breadboard, featuring a microcontroller IC1 and various resistors, capacitors, and possibly LEDs.

And the 3 resistors.

Electronics prototyping setup with microcontroller board, jumper wires, and various components for testing and building electronic circuits. Electronic prototype on breadboard featuring resistors, microcontroller, and diode, showcasing experimentation and circuit design.

Then feed the output of the previous circuit to the 2 inputs of both op-amps.

Electronic enthusiast's breadboard setup featuring an Arduino board, op-amps, and LEDs, likely used for a small project or experiment. Medical device captures electrocardiogram readings, displaying heartbeats in a waveform pattern with distinct colors and forms representing each pulse. Oscilloscope display shows multiple signal traces in different colors and patterns, allowing observation of constantly varying voltage signals over time.

Lets get this oscilloscope to work and look at both outputs together.

And that's it, circuit's done!

Video version

Alternative local hosted video







Page generation time: 0.0156 seconds