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

Hello world,

I want 2 PWM outputs with a different period, adjustable on a analog input.
1 is OK i found in the examples and tutorials, and i'm using the timer1 library.
Now I want to have a second PWM output with a different period. If i'm going to study on timer2, or so, is that affecting any timing in the uno ??

 
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25721
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

With PWM, the usual important parameter is duty cycle, not frequency.
Can you explain why you need a different frequency?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

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

For a machine i'm workig at I want to control a powersupply by a PWM signal of appr. 230Hz with a dutycycle of 10% - 90 %.
second I want to use the arduino to control a pulstrain with a variable duty cycle and a variable period. This is for scientific research. I do not know the reason but a scientist asked me to program it. I could use 2 aurduino's but that is to easy. I use Timer1 and i beleive there are three ! 
Logged

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

This is how I think you can get 230Hz PWM.  I'm fairly new, so someone please correct me if I'm wrong.

Using 8-bit timer/counter 2:
TOP of 136
Prescaler of 256
Fast PWM mode.  Set on compare match, clear when the timer is cleared.

You should get a PWM frequency of 229.7Hz or approximately 230Hz.  Perhaps you can change the PWM frequency on the fly by modifying TOP, but I've never tried that, and I can't see any practical purpose for changing the PWM frequency.
Logged

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

Yes I'm going to try something like that. But the question is does timer2 affect anything else?
Logged

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

My experience is that modifying Timer/Counter2 doesn't affect any other Arduino functionality.

Modifying 16-bit timer0 does affect some other Arduino functions though.  To quote another user who helped me in another topic;


If anything in your code depends on the standard Arduino setup of Timer 0, it won't work if you change the settings of Timer 0.  This includes the functions micros(), millis(), delay(), maybe others.


Logged

Pages: [1]   Go Up
Jump to: