Pages: [1]   Go Down
Author Topic: PWM Output  (Read 505 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Edison Member
*
Karma: 23
Posts: 1173
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.    smiley-confuse   What kind of load do you have connected?

Quote
...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.
Logged

Offline Offline
Edison Member
*
Karma: 4
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

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.

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.

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

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* NewFile5.bmp (146.3 KB, 320x234 - viewed 9 times.)
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Pages: [1]   Go Up
Jump to: