Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1]   Go Down
Author Topic: Can you modulate the PWM output pin? e.g. IR blaster LED.  (Read 1033 times)
0 Members and 1 Guest are viewing this topic.
Toronto, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some microcontrollers have a gated PWM output, others you can disable or tristate the PWM output pin.
example, you set the PWM module (carrier) for 38kHz and toggle out the output pin for the data (control pulses).
Are any of these features available on the ATmega328P?
Logged

Bill

Offline Offline
Faraday Member
**
Karma: 68
Posts: 2635
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why not do 38kHz "bursts" from an output pin?

<><>  http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
« Last Edit: November 13, 2012, 10:05:42 pm by Runaway Pancake » Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 535
Posts: 19769
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an example here:

http://www.gammon.com.au/forum/?id=11504


Scroll down to "Modulating a 38 KHz carrier with a 500 Hz signal".
Logged

http://gammon.com.au/electronics
Please post technical questions on the forum - not by personal message. Thanks!

Toronto, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you. So it still requires two GPIO pins? Are you generating the 38kHz signal with PWM (timer 1) and the 500 Hz with Timer 2?
Quote
generates a 38 KHz signal and then turns that carrier on and off with a 500 Hz signal (generated by Timer 2) with a variable duty cycle controlled by a potentiometer. The 500 Hz duty cycle is output on pin 3 which causes a pin change interrupt which is used to turn pin 9 on and off.
« Last Edit: November 13, 2012, 10:39:07 pm by BlueBill » Logged

Bill

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 535
Posts: 19769
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I used the second pin to generate the interrupt because I was trying to capture the PWM duty cycle. If you didn't care about that (or if a bit of imprecision didn't matter to you) you could generate an interrupt (without using a pin) and do the calculations in the ISR. In other words, only commit a single output pin to it. I was also trying to make it simple. As you can see from the code, there is only one line that is not inside an ISR (apart from setup).
Logged

http://gammon.com.au/electronics
Please post technical questions on the forum - not by personal message. Thanks!

Pages: [1]   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: