PWM Output

Just ran the fade sample program to see what kind output the arduino would produce and testing all the PWM output pins, I didn't get the advertised results. From the o'scope I only get a 0-2.7V peak and a frequency of 975.9 Hz. The data on the website shows 0-5V and according to the analogWrite() the default PWM signal is 490Hz. Has anyone else had these results? I duplicated all an analogWrite() to all PWM output pins (pins 3, 5, 6, 9, 10, and 11) and results are all the same. My objective is to put it through a low pass filter to get a DC value then run it through an opamp to amplify up to a 12V regulated signal. It works fine and I set the OPAMP resistors to get approximately what I need. Just wondering if other had the same results...

BTW is it on an Arduino Uno.

I haven't used PWM, but since the "analog" output is actually a digital output operating from 5V, I don't see how you can get anything other than (approx) 0V or (approx) 5V. :~ What kind of load do you have connected?

...and a frequency of 975.9 Hz.

How are you measuring/calculating that? Since it's about twice (half the period), it looks like the right timing for a single-pulse or a half-cycle. i.e. If your 'scope has a built-in frequency counter, it may not be triggering properly.

Remember th3 default pwm state is not perfect wave to say, it counts up until the numb3r and flip flops, another state which is slower but more accurate is where it counts up and then back down
Search arduino secrets of pwm for a better explanation

Have you set the pins to be an output before using them?
It sounds like you have not if you are only getting a 2.7V peak output. On the other hand have you measured the +5V with your scope to see if it is calibrated.
The other thing is that you could have too much of a load, like an LED without a current limiting resistor.

You forgot the current limiting resistor, which may have damaged all of the I/O pins that you attempted to connect a LED directly.

I have only connected pin 9 with an LED and resistor and plugged that output to the oscope with the result I previously discussed. Then modded the program to test all of the other PWM pins to see if I get the same result. I didn't hook up any resistor/LED to the other pins when testing they were directly connected to the oscope, so all the I/O pins could not all been damaged.

Grumpy_Mike:
Have you set the pins to be an output before using them?
It sounds like you have not if you are only getting a 2.7V peak output. On the other hand have you measured the +5V with your scope to see if it is calibrated.
The other thing is that you could have too much of a load, like an LED without a current limiting resistor.

i had a current limiting resistor but didn't set the pin's output mode... I'll try that first...Also tested to see if Arduino's +5V registered properly on the scope and it did.

DVDdoug:
How are you measuring/calculating that? Since it's about twice (half the period), it looks like the right timing for a single-pulse or a half-cycle. i.e. If your 'scope has a built-in frequency counter, it may not be triggering properly.

The oscope measured it. But I double checked it when I scaled the time/division and my visual measurement is compares to be the same.

winner10920:
Remember th3 default pwm state is not perfect wave to say, it counts up until the numb3r and flip flops, another state which is slower but more accurate is where it counts up and then back down
Search arduino secrets of pwm for a better explanation

I know that its not a perfect wave, I understand all about PWM. I'm just making sure that the Arduino is support to output from 0-5V. My follow on application of the signal is dependent on that output and the circuit will not work correctly if I don't design it to the correct voltages.

thanks all for the suggestions... I'll see if my mini produces the same results...

You shouldn't need to change the pinMode, it's the first thing that analogWrite() does.

What happens if you set a pin to OUTPUT and write a HIGH to it? What do you measure then?

For reference. Here's the output of my PWM pin 11 with measurements turned on.

NewFile5.bmp (146 KB)