Web Oscilloscope: An Introduction to Visualizing Arduino PWM Signals

An oscilloscope is an essential tool for any electrical engineer, physics student, or electronics hobbyist. It allows you to visualize electrical signals and understand their characteristics, such as amplitude, frequency, and waveform shape. However, oscilloscopes can be expensive and complicated to use. Fortunately, with the advent of web-based oscilloscopes, anyone with a PC and an internet connection can visualize signals quickly and easily.

A web oscilloscope is a web application that allows you to view and analyze electrical signals using your web browser. It works by connecting the signal source, such as an Arduino PWM output, to the Line-In input of your PC system, and viewing the signal waveform on the online oscilloscope. This method is useful for those who don't have access to a traditional oscilloscope or want to quickly visualize simple signals without setting up complex lab equipment.

One of the most common signals that hobbyists and students work with is a pulse-width modulation (PWM) signal. PWM signals are widely used in electronic circuits for controlling the speed of motors, dimming LEDs, and generating audio signals. A web oscilloscope is an excellent tool for visualizing and analyzing PWM signals, allowing you to observe the waveform shape, duty cycle, and frequency of the signal. Not only it is useful for observing PWM signal but test electronics circuit signals such as BJT amplifier signal, audio amplifier signals etc. Here it is demonstrated how you can use online web oscilloscope to observe PWM signal with different duty cycle generated by Arduino.

To get started, you'll need an Arduino board and a few simple components, such as a potentiometer and a few jumper wires. The potentiometer will be used to adjust the PWM signal duty cycle, allowing you to observe how the waveform changes with duty cycle. First we will show the program that needs to be uploaded. Then we will show the hardware connection required.

Below is an example code of how to generate a PWM signal with different duty cycle adjusted using a 10KOhm potentiometer.

    
  const int POT_PIN = A0;     // Analog pin used for potentiometer input
    const int PWM_PIN = 9;      // Digital pin used for PWM output

    void setup() {
    pinMode(PWM_PIN, OUTPUT);
    }

    void loop() {
    // Read the potentiometer value
    int potVal = analogRead(POT_PIN);

    // Map the potentiometer value to a frequency range of 100 to 2000 Hz
    int dutyCycle = map(potVal, 0, 1023, 0, 255);

    // Generate the PWM signal
    analogWrite(PWM_PIN, dutyCycle);
    }
 

The program is very simple and easy to follow. If you need help in understanding the program, you can look into the tutorials like Programming Arduino Timer 2 in Fast PWM mode or Programming Arduino Timer 0 in Fast PWM mode.

Once you have the PWM signal generating, build the following hardware connection on breadboard or directly.

web oscilloscope arduino setup
 The picture shows, a 10KOhm potentiomter middle terminal connected to the analog pin A0, the other ends are connected to 5V and ground. The output PWM signal from pin 9 is connected to one end of 2nd potentiometer, the middle pin is connected to the 3.5mm audio socket right channel pin. The other side of the 2nd potentiomter is grounded. The 2nd potentiometer is used to control the voltage level that is fed into the line in input. The audio socket ground is connected to the common ground where the Arduino ground pin is also connected. Using 3.5mm audio cable(back to back male), is connected to the to the Line-In input of your PC system or mobile phone. When you connect the jack into your PC then you should see window asking what kind of input was inserted, there select Line-In. This is illustrated in the video provided below. 

Once you have connected the hardware, already uploaded the above program code into Arduino, you are ready to go. Turn on the web oscilloscope and it will ask for permission to use your system line-in input. After granting the permission required, you will initially see both the right and left channel traces. You can turn off the left channel using the left channel turn on and off button(see video below). Adjust the frequency of the PWM signal using the potentiometer, and you should see the waveform shape and frequency displayed on the web oscilloscope as shown below.pwm signal on web oscilloscope

You can zoom in and out to see the waveform more clearly if you want. You can take measurement with live measurement cursor. In this way you can visualize and analysis real time PWM signal on the web oscilloscope. 

Below is video demonstration of how to use the web oscilloscope.


 Using a web-based oscilloscope to visualize Arduino PWM signals is an excellent way to learn about signal characteristics and analyze simple signals without investing in expensive lab equipment. It's also a great way to get started with electronics and explore the possibilities of the Arduino platform. With a few simple components and a web browser, you can be on your way to visualizing and understanding electrical signals in no time.

If you are interested in instrumentation, such as signal generation and measurement the references below may be interest to you.

References

[1] How to build LM324 Instrumentation Amplifier & Test It

[2] Frequency Counter with Arduino 

[3] DIY LCR meter using PC

[4] Inductance meter with Arduino and LM393 

Post a Comment

Previous Post Next Post