pulse train for IR led

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello, 

i want to make a pulse train, needed for steering of a IR led.

i don't see how to do that on a easy way.

i use a atmega 16, running on a 8Mhz X-tal.

 

thanks in advance.

 

Last Edited: Fri. Mar 27, 2020 - 10:27 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is this for a Remote Control?

 

If so, try a search - it has been covered many times before.

 

eg,  https://www.avrfreaks.net/forum/infrared-rc5-decoding-without-reciever

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

no remote control,..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

>i don't see how to do that on a easy way.

 

Start by creating the 26us pulse train. At 8Mhz, 208 clocks is 26us (will assume 26us is the cycle period). Use an 8bit timer in ctc mode with top at 103 (208/2-1), and have the waveform output toggle a pin on compare match, that should get the fast pulse train going. Not so hard. Now you simply have to enable/disable the output in 500ms intervals, which should be the easier part.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

that is exactly what i'm trying now.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I use a timer to generate the 37 or 38 KHZ wave. See your datasheet for how to use pwm mode of the timer. I also use a timer to give me a time base, perhaps just an interrupt from the pwm timer.

 

Now, in my application loop, I see what time it is, perhaps something close to millisecond. AND this with 3 or something. If you get 0, turn the pwm output on in the timer control register. If you get 1, look to see if you're detecting the signal, then turn the pwm output off.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut.