Introduction: Displaying PWM on an Cathode-ray oscilloscope

I believe I experience made this Instructable easy to understand. Withal, if after recitation this you have any questions, please feel disengage to pull in touch with Maine directly. You can contact me at transiintbox@gmail.com. (Please replace the second 'i' with an 'e' to contact me. Thank you.)

If you do regain this article helpful, even if it is relative to when you see information technology some months or years old, please be kind enough to pussyfoot click "Favorited" at the top of this Instructable. Your support is appreciated.

Therein Instructable, we see how to show Pulsation Width Modulation (PWM) on an oscilloscope. In the process of doing this, we place any ways to calibrate our oscilloscope poke into(s), and our oscilloscope.

I use a Rigol DS1054Z benchtop oscilloscope upgraded with software to a Rigol DS1104Z. Still, almost any digital benchtop oscilloscope should work as well.

The Rigol DS1104Z is a quartet channel scope. Alternatively, a single Beaver State treble TV channel oscilloscope will too knead to display PWM.

In the examples below, we utilization PWM to brighten and darken an LED using an ESP32 (an Arduino UNO will also work).

Two examples are ill-used, one with hyperbolic step size and delay to provide visible changes in brightness that can be compared to the oscilloscope images.

Supplies

- An oscilloscope (As noted, I used a Rigol DS1054Z upgraded by software to a 1104Z in this Instructable). All the same, any benchtop oscilloscope will work.

- An oscilloscope examine.

- A 400 hole breadboard

- An LED (I ill-used a 10mm red LED). However, a 3mm, 5mm, 8mm, LED of any color, will also mold. Note: the voltage specifications change with size and color. For a 10mm LED, such as I used, the potential values are shown below for different colors:

Yellow: 1.8 - 2.2 (VDC)

Red: 1.8 - 2.2 (VDC)

Blue: 2.8 - 3.0 (VDC)

Green: 2.8 - 3.0 (VDC)

Tweed: 3.0 - 3.2 (VDC)

Although the actual up-to-the-minute depends on the value of the resistor, the current is approximately 20ma.

- A 220 ohm (I used a 1 W) resistor. Most any electric power resistance, 1/4 watt or greater, and any resistance from 220 ohm to 560 ohm will work.

- An ESP32 development board (Almost any ESP32 development board will work, as will an Arduino UNO).

- Four male to male Dupont jumper wires (any size up 10 centimeter in length or thirster will work.).

Step 1: Calibrating Our CRO Probe

In front we start we need to calibrate our oscilloscope probe(s).

This is done using the calibration screw on the probe. This screw is normally located either on the distal end of the probe itself surgery at the proximal end, approach it's BNC connector, i.e., the attachment to the oscilloscope (see attached photographs).

A sawtooth reference generator can embody found at the bottom right (2 flat bronze connectors with central square holes) on the Rigol oscilloscope used in this Instructable.

A test calibration generator is unremarkably enclosed with all benchtop oscilloscopes, and may appear in a slightly different form, i.e., not as metal plates, than the one used in this Instructable. However, there is almost always a sawtooth reference signal generator along benchtop oscilloscopes.

One may wish to press "Car" on your oscilloscope if the square wave does not show, operating room is shown only when partially.

The goal is to use the improved in square curl generator to perplex the sawtooth wave shown as "horizontal" As possible without any curves upwards or down (see affiliated video).

When this is realised, the adjusted/calibrated probe is ready to use.

However, we should calibrate the oscilloscope itself, before it is ill-used (see close step).

Step 2: Calibrating Our Oscilloscope

Before we use the oscilloscope it it an first-class idea to graduate IT, with its personal internal calibrator.

Before we wont the calibrator we should leave the oscilloscope on for 30 minutes or thus to insure that all components are adequately "warmed" up.

We should also disconnect all inputs to the cathode-ray oscilloscope.

The bill of fare to do this is often found through a button such as "Utility", on the Rigol, or on another oscilloscopes something synonymous.

We and so choice "Self-Cal", or its equivalent, and after selecting IT, we are conferred with some options, on the Rigol and replaceable oscilloscopes, these are "Start" and "Expire".

We select "Start" to begin the self-calibration process (picture betrothed television). When the ego-standardisation is complete we select "Exit" to end the physical process (see attached picture).

This sue is quite an semipermanent and bottom take some minutes. So, delight be patient. Unhappily, this process cannot be rushed.

Afterwards the self-calibration process for the oscilloscope is completed, and presumptuous we have calibrated a probe(s) as well, we are ready to start using the oscilloscope and poke into.

Step 3: Pulse Width Modulation (PWM) Working Example

This is the example of PWM from my previous Instructable "ESP32 Tutorial:Touch, Lobby, I2C, PWM, ADC, & DAC". It will beryllium the configuration we role with our oscilloscope in the side by side Step to see a PWM signal.

I repeat this instance here to eliminate the necessitate to change to an earlier Instructable, and to provide us with a operative example of PWM in action at law.

Almost every bowling pin happening the ESP32 developing board, used here, accommodates PWM, except for the inferior two pins on both the left and right-side, and the top pin along the left-hand side. This is with the development board face up, and the USB connector bound down.

PWM allows United States of America to simulate analog voltages using digital means. Information technology is often used to fade an Light-emitting diode up and down, or control a centrifugal.

In the example that follows, we bequeath use PWM in conjunction with an ESP32 development board to wither an Light-emitting diode up and downcast. We use more resolution for PWM than is available along the Arduino UNO which defaults to 8-bits, i.e., 0-255.

Hera we use 15-bits, so the range is from 0 to not quite a 33,000.

/*
* Program away R. Jordan Kreindler

* showing the use of the PWM capabilities

* of an ESP32 Development board.

*/

#define ledChannel 0 // Canalise 0 chosen, from 0-15 choices

#delineate resolution 15 // Resolution is chosen as 15 bits

#define frequency 5000 // 5,000 Hz frequency

#define LED 15 // LED connected via 330 ohm

// resistor to pin 15

// Other cease of LED

// to GND

int delay1 = 20; // Retard in milliseconds

evacuate setup() {

ledcSetup(ledChannel, frequency, declaration); // Set-up a channel

ledcAttachPin(Light-emitting diode, ledChannel); // Attach a channel to a pin

}

annul loop() {

// In the for() loops, adding and subtracting

// deuce hundred (200) is necessary unpaid to the greater

// resolution provided by 15 bits, compared to the UNO

for (int i = 0; i < 32768; i = i + 200) { //curl to fade up

ledcWrite(ledChannel, i);

delay(delay1);

}

for (int i = 32767; i > -1; i = i - 200) { //loop to fade pop

ledcWrite(ledChannel, i);

hold up(delay1);

}

}

Step 4: Display Pulse Width Modulation (PWM) on the Oscilloscope.

PWM works by pulsing DC current, and varying the measure of clock time that for each one pulse stays On and Off. Thereby controlling the amount of "brightness" we comprehend. PWM signals are typically square/rectangular waves.

Dimming an LED with PWM depends on the power of the eye to average the amount of time the LED is turned On and the amount of time it is turned Dispatch.

We can see PWM in action mechanism with the oscilloscope.

IT is easy to get in touch the oscilloscope to see PWM in our example. First, we insert two additional male to male Dupont jumper wires in the bread board, in electrical adjoin with the existing ground pin and pin D15. The unconnected male ends of these wires are connected to our cathode-ray oscilloscope examine. Ground to the ground wire on our probe, and the hook on our dig into to the wire connected to D15. (See involved pictures).

A celebrated, PWM works by turning the LED Off and on for a portion of each period. The period for PWM here is the period of a square waving. These square wave periods are quite short, allowing our brain to "average" the sentence an LED is Off and on.

In fact, if we select the "Pointer" operate in "Manual" mode and step the period's length, shown on the scope, we can see this period is indeed quite short.

A time period is measured in seconds, it is usually denoted by the symbol "T". It is the time from the leading edge of one beckon to the leading boundary of the next. Eastern Samoa the absolute frequency of a wave is increased the meter period decreases. Here we take over a period of astir 400 microseconds. Since the frequency (f) and the period of a wave are reciprocally consanguineous; we receive a frequency, in our example, of approximately 1/T, or about 2.5 kHz. This speed is faster than that detectable by the human eye. Olibanum, human eyes mediocre the results out.

The number of time the LED stays On is controlled away the "duty cycle", i.e., the fraction of clock the LED is turned On compared to the time the LED is turned Off.

In the third involved hush photo, the LED is Connected about half the clip so we perceive IT at about 1/2 brightness.

In the fourth attached all the same photograph the LED is On about 1/3rd of the time and Off about 2/3rds of the time. So, we comprehend IT at virtually 1/3rd brightness.

In the twenty percent loving distillery exposure, the LED is On nearly each the time, so, we perceive that it is almost at its maximum brightness.

In all the above cases, the LED is actually flashing Off and on highly quickly. However, these On and Offs are quicker than the eyeball, i.e., the cones in the eye, can observe. So, we reckon the LED arsenic Off, palely lit, at some level of brightness above dim and below bright, or lambent contingent the duty cycle.

In the second picture the sizing of a step was increased to 2,000 and the delay also multiplied to 2 seconds (determine the sketch below). These program changes provide for incremental and discrete changes in brightness that we can see.

In the first picture we can clearly construe the duty bike for PWM go smoothly from zipp to 100%, and the LED's light concurrently go from its beingness extinguished to the LED's light at its maximum brightness.

Without the oscilloscope display only the brightness of the LED would embody visible to us. Neither a Multimeter operating theatre our eyes (i.e., without an oscilloscope) would allow us to see how the PWM signal worked to obtain this changing brightness.

In the arcsecond video we see a similar PWM signal, showing luminance and PWM in more discernible, incremental, steps.

_________________________________

This is optional, and Rigol scope specific: It English hawthorn be useful if one decides to keep the signaling to label the x-axis, so in the future we will know that this is the PWM signal we saved.

To do this, on the Rigol oscilloscope secondhand here, insistency channel 1 (CH1), then the down arrow on the right side of the CRO display. Select Label, then Label Edit. A keyboard will appear in the middle of the display.

Obviously, this march will be different on different brand oscilloscopes.

Use the upper leftmost knob, along the Rigol victimized hither, to select the letters "pwm". The 2nd row of the screen keyboard is selected by turning the boss past the 1st row. In a similar manner the 1st row is then selected, if you are on the 2nd row, by flying the knob past the second dustup.

A letter is selected by using the upper, left knob to place the selection people of colour over the letter and pressing the knob to select the letter we are over.

(Get a line the bespoken photos.)

An intended pictorial matter shows the results, where the x-axis is labeled "pwm".

The final results tush be saved to a Fat formatted USB drive, placed into the oscilloscope, and pressing the printer (lowest green) icon button on the oscilloscope put-upon present (See photographs).

Since a Rigol oscilloscope is favourite among more makers, although arguably not the top of the business line in oscilloscopes, the above may demonstrate expedient to many an readers, and so is worth including here, even though the material, as used hither, is specific to the Rigol oscilloscope shown in that Instructable.

At the stop of this Step is a still picture showing the signal as captured from the cathode-ray oscilloscope onto a USB flash drive, and displayed on a proctor.

This ends the optional material started immediately to a higher place.

_________________________________

As antecedently noted, one program that does this is shown below.

/*
* Program aside R. Jordan Kreindler

* showing the use of the PWM capabilities

* of an ESP32 Development board. */

#define ledChannel 0 // Channel 0 chosen, from 0-15 choices

#define resolution 15 // Resolution is chosen A 15 bits

#define frequency 5000 // 5,000 Hz frequency

#define LED 15 // Light-emitting diode connected via 330 ohm

// resistor to flag 15

// Other end of LED

// to GND

int delay1 = 2000; // Delay in milliseconds = 2 seconds

void setup() {

ledcSetup(ledChannel, frequency, resolution); // Set-risen a channel

ledcAttachPin(LED, ledChannel); // Attach a channel to a rowlock }

void loop-the-loop() {

// In the for() loops, adding and subtracting

// two hundred (2000) is requirement due to the greater

// solving provided by 15 bits, compared to the UNO

// and the desire to "see" the brightness changes

for (int i = 0; i < 32768; i = i + 2000) { //loop to melt up

ledcWrite(ledChannel, i);

time lag(delay1);

}

for (int i = 32767; i > -1; i = i - 2000) { //loop to slice down

ledcWrite(ledChannel, i);

delay(delay1);

}

}

Luckily, these changes only requisite minor modifications of the original program.

We buttocks immediately see on the scope that when the PWM signal has information technology maximum Duty Cycle the LED is at its maximal brightness. Conversely, when the Duty Cycle is zero the LED light is extinguished.

Step 5: Afterwards

If you have touch on this point - kudos. You should right away have a basic perceptive of one way to show PWM happening an oscilloscope, i.e., As covered in this tutorial. I hope you found this Instructable interesting and of esteem.

Also, if you liked this Instructable, please make up kind sufficiency to check "Favorited" box at the top of this Instructable. Thank you.

If you have some comments, suggestions, or questions side by side to this Instructable, please attention deficit disorder these to the comments below, if there are whatsoever.

If you have whatsoever thoughts or questions, related to PWM in broad, but non covered therein Instructable, or any suggestions for how I could improve this Instructable, I would be pleased to discover from you. You can contact Pine Tree State directly at transiintbox@gmail.com. (Please replace the second 'i' with an 'e' to contact me).

Be the First to Share

Recommendations

  • Anything Goes Contest 2022

    Anything Goes Contest 2022