Electronic – arduino – How to measure PWM on Oscilloscope

arduinooscilloscope

I’m measuring the voltage level from an Arduino Uno PWM pin using an oscilloscope. I’m using analogWrite(pin, voltage) in the loop with pinMode(pin,OUTPUT) in the setup.

I set the trigger to edge (rising), auto mode, but all I see is noise. Tried zooming in/out and moving up and down on the screen to find the signal at 3.3 V but couldn’t find it.

What am I doing wrong?

Best Answer

Here is Sparkfun's example code:

int PWM_out_pin = 9; // Must be one of 3, 5, 6, 9, 10, or 11
// for Arduino Uno
void setup() {
pinMode(PWM_out_pin, OUTPUT);
}
void loop() {
byte PWM_out_level;
PWM_out_level = ... // Code logic to set output level
analogWrite( PWM_out_pin, PWM_out_level);
}

Use code similar to that (you need to have that loop structure, and I suggest, as a test, setting the output level to 127 so you get close to a square wave).

Make sure you use one of the valid pins and have your probe connected to that pin and the ground lead connected to GND of the Arduino.

If you still see nothing, try the autoset function on your oscilloscope, or just set the sweep to about 1-2ms/division and the sensitivity to 0.5 or 1V/division. Make sure your probe and scope are set to the proper sensitivity (usually 10:1 is best) and make sure the probe is not switched to ground if that is an option. Most scopes have a cal output that you can hook the probe to, and it has a similar frequency to the Arduino PWM (use that to check your scope).

Some oscilloscopes will give very strange readings if you set the sweep too slow in comparison to the signal (due to lacking an anti-aliasing filter).