2
\$\begingroup\$

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?

\$\endgroup\$
2
  • \$\begingroup\$ Did you connect the probe ground to the circuit? Also see if you scope has a calibration signal lug on it, and learn to view that first since it should be a nice square wave (though beware that won't require connecting the ground, unlike probing a distinct circuit does) \$\endgroup\$ Commented May 20, 2019 at 20:35
  • \$\begingroup\$ I'm not up to speed on Arduinos... is analogWrite() the correct way to output a digital PWM signal? \$\endgroup\$
    – spuck
    Commented May 20, 2019 at 20:40

1 Answer 1

1
\$\begingroup\$

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).

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Thanks! I was using the wrong pin! (assumed that pin 3 would work). The other tips will definitely be helpful for the future as well! \$\endgroup\$
    – Seth Shill
    Commented May 21, 2019 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.