IR transmitter

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

hi there ,
I want to generate a IR radiations of 38Khz for TSOP1738
For that i want to transmit the input to the IR tranmitter .
This is the coding for transmitting the IR signal for TSOP
I need to toggle the OC pin for 13 times , i.e. high then low
13 times(periods) and then continuous Low for 32 Periods . and so on

|---| |---| |---|
| | | | | |
----| |---| |---| | (13 times this )----------------------------------------(32 times)
( 13 square pulses) and then stop for 32 periods and then again 13 pulses
and so on .........
I am thinking to toggle the OC pin ( i am using Mega8) 13 times and then stop for 32 periods

But how should i go about this in assembly language (with Timers )....

Thanx
Ankur

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

Ankur,
The TSOP1738 is an IR receiver that acts as a demodulator for a modulated data signal. That means you need to send it a modulated signal for it to decode. The signal you send it can be anything from DC up to a few KHz. My signals class is a little hazy in my memory so I forget the exact upper limit for data frequency versus carrier modulation but it is at least as bad as 1:2 ratio (Nyquist). Now, assuming you have your circuit uses an external modulator and is set up correctly and your data rate is not too great for the modulator, how you go about transmitting from the MCU depends on how long your "periods" are. If they are in the KHz range, use a Timer interrupt from hardware to bit-bang the data onto a pin. If it is a lot slower than that, use the Timer overflow as a tick input to a clock and base your time units off that. I'm guessing this is not just a simple UART or similar transmission scheme where you could use the hardware to send more than a bit in one go. That means you'll want to implement a shift register or two in software and use that as the input buffer for your pin toggling.
In case I'm reading your post correctly and you're trying to do the 38KHz modulation directly from the AVR... my hat is off to you if you get it to work. That would be a royal pain in the rear if it is even possible. using external hardware to modulate would be so much easier...
-Will

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

hi there ,
I think u have misjudged my question , lemme define it clearly
lets say i want to generate a Square Pulse of 38Khz from AVR
and i want to toggle the OC Pin at 38KHz , cant i do it and leave the
UART now , how should i go to generate the Pulse of 38KHz ..........
about ...
Many Thanx
Ankur

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

Use a timer in CTC mode (OCR1x)

That would put absolutely no load on the cpu ..

/Bingo

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

ankurhanda wrote:
hi there ,
I think u have misjudged my question , lemme define it clearly
lets say i want to generate a Square Pulse of 38Khz from AVR
and i want to toggle the OC Pin at 38KHz , cant i do it and leave the
UART now , how should i go to generate the Pulse of 38KHz ..........
about ...
Many Thanx
Ankur

I guess I'm a little confused why you mentioned the TSOP1738 in your original post. As Bingo pointed out, a square wave at 38KHz is just a matter of setting up a Timer as either an interrupt or let the hardware toggle automatically. Make sure you up your frequency to 76KHz to account for both the low-hi and hi-low transitions.
Now, back to the whole modulation and useful data transfer using the TSOP1738... The 38KHz signal that the reciever is expecting is in the shape of a sine wave (pure 38KHz) not a square wave. Square waves are made up of a lot of different harmonics of their fundamental frequencies. You're likey to get a lot of crap if you try to use one as a carrier wave.
-Will

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

Quote:
The 38KHz signal that the reciever is expecting is in the shape of a sine wave (pure 38KHz) not a square wave.Square waves are made up of a lot of different harmonics of their fundamental frequencies. You're likey to get a lot of crap if you try to use one as a carrier wave.

The Vishay TSOP1738 data sheet says otherwise.

Figures 7 and 8 of the Vishay data sheet specifically show square pulses. The words "sine" or "distort" or "harmonic" do not appear anywhere in the data sheet.

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

When you XOR the 38KHz carrier and the data stream, isnt the resultant encoded data stream the same as single density floppy FM? Don't they call this 'biphase mark'? Funny how this encoding protocol stuff keeps getting reinvented for different media (HDLC serial cables, IR, floppies, etc). Anyway, the IRDA site has a good explanation of the IR5 protocol. The decision to get a chip that does it (chip costs money) or try to 'push it into software' (programmers cost money) usually has to do with how many you are going to make. 1000s? 10000s?

Imagecraft compiler user

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

whein wrote:
the 38KHz signal that the reciever is expecting is in the shape of a sine wave (pure 38KHz) not a square wave. Square waves are made up of a lot of different harmonics of their fundamental frequencies. You're likey to get a lot of crap if you try to use one as a carrier wave.
-Will

I'm not so sure about that. If you think about it, whether the data is transmitted through a wired or wireless medium, every protocall I have ever seen uses squarewaves. A sinewave (or a rounded off squarewave) takes less bandwidth to transmit, but from what I have studied nothing leads me to believe a squarewave will crap all over any part of the recieving circuit. Maybe someone could prove otherwise though.

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

ankurhanda wrote:
hi there ,
I want to generate a IR radiations of 38Khz for TSOP1738....

Did you give up so quickly on the ADC?

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

hi there ,
I didnt give up , i am doing 2 Projects Simultaneously ....
Can somebody tell me how to generate a 38KHz pulse at the
OC2 pin ... . Can i generate accurate 38KHz pulse ... ??

Thanx
Ankur

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

Does it need to be encoded with some data, or just a 38khz square wave? See previous post from bingo600 on how to generate 38khz wave

Imagecraft compiler user

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

hi there ,
I am using ATmega8 which is running at 1MHz 1.e. it counts 1 Million
pulses in 1 sec , now suppose i want to run the Timer at 38Khz then i
would have to count 1000000 * ( 1 / 38000) , but they are coming
out to be 26.311. I Think its wrong !!!

Ankur

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

I did a 38KHz IR transmitter (and receiver) on the AT902313, with RS232 to a PC.
I let the hardware generate the 38KHz witout interrupts. I turned the 38KHz output on/off as the bits are shifted out at about 1mSec per bit.

Receiving was more difficult as it handles any coding scheme.

I think but I'm not sure, that I uploaded this C code here.

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

can u post it again to me , ill be very thankful to u !
Ankur

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

ezcomp wrote:
every protocall I have ever seen uses squarewaves. A sinewave (or a rounded off squarewave) takes less bandwidth to transmit, but from what I have studied nothing leads me to believe a squarewave will crap all over any part of the recieving circuit.

Well, right off the bat I can think of AM radio. Granted that is an analog waveform to begin with since it is sound data. It wasn't so much the crapping on the receiveing end as distorting the encoded signal. When a signal is modulated it is roughly the same as saying Vout = Vsignal*Vcarrier. So if Vcarrier is actually several different frequency (sine waves since all periodic signals can be written as a combination of sine waves at different frequencies) then you actually get Vout = Vsignal * (Vcarrier_1 + Vcarrier_2 +...+Vcarrier_n). When you add those together they sometimes overlap and cancel. So depending on whether the demodulation uses the exact same carrier signal to decode the signal, or merely uses the dominant term (38Khz here) will affect how closely the input and output signals match. Maybe for digital input this doesn't matter so much but for analog (sound) it matters a great deal.
-Will

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

Quote:
Well, right off the bat I can think of AM radio.

Many of us know the math for AM radio. But this isn't AM radio, it is the pulse code modulation input to the TSOP1738. The data sheet says it expects a square wave. The data sheet also describes in detail how the output relates to the input signal for various cases.

Do you have evidence that the TSOP1738 data sheet is wrong????

Quote:
for analog (sound) it matters a great deal

The OP asked how to generate accurate pulse trains, because the TSOP1738 data sheet says that's what it expects to receive.

[edit] I just did a quick patent search... found at least two patents where the harmonics are actually required, to validate that the incoming is a square wave. (Panasonic, Hitachi) It makes sense to actually take advantage of the fact that all remote controls generate square waves. Then any sinusoidal "signals" can be rejected. [/edit]

Last Edited: Fri. Dec 9, 2005 - 12:44 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

whein wrote:
ezcomp wrote:
every protocall I have ever seen uses squarewaves. A sinewave (or a rounded off squarewave) takes less bandwidth to transmit, but from what I have studied nothing leads me to believe a squarewave will crap all over any part of the recieving circuit.

Well, right off the bat I can think of AM radio. Granted that is an analog waveform to begin with since it is sound data. It wasn't so much the crapping on the receiveing end as distorting the encoded signal. When a signal is modulated it is roughly the same as saying Vout = Vsignal*Vcarrier. So if Vcarrier is actually several different frequency (sine waves since all periodic signals can be written as a combination of sine waves at different frequencies) then you actually get Vout = Vsignal * (Vcarrier_1 + Vcarrier_2 +...+Vcarrier_n). When you add those together they sometimes overlap and cancel. So depending on whether the demodulation uses the exact same carrier signal to decode the signal, or merely uses the dominant term (38Khz here) will affect how closely the input and output signals match. Maybe for digital input this doesn't matter so much but for analog (sound) it matters a great deal.
-Will

We can talk signal theory until we're blue in the face, but it's pointless ... A working piece of hardware is not hard to come by.

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

Why do so many turn simple stuff into complicated ?
There is absolutely no reason for an external 38Khz oscillator. The task of modulating a 38Khz square wave in firmware is super simple, using timers or bit banging.
I've used the Vishay TSOP34838 demodulator module. All it requires is between 10 and 70 complete 38Khz (square wave) cycles per burst with a minimum 14 cycle time period rest between each burst.
13.15us high and 13.15us low, sent to an I/O pin gives one 38Khz cycle output. Repeat this 10 times and you've successfully transmitted a legitimate 38Khz burst, which will appear as a 263us pulse on the TSOPxxxxx output pin. It's as simple as that. You can't use the UART because data must be sent using bi-phase method. I just created my own protocol. This was actually less time consuming than trying to learn somebody elses.
These Vishay IR receiver modules are just the coolest thing, with lens, pin diode, agc, bandpass and demodulator all in one 3 leaded chip. The only other hardware required is an IR diode with current limit resistor for transmit side. Although It's best to drive your IR diode with a single transistor driver stage for higher current output. Throw one of these receiver modules into a big torch parabolic reflector and transmit using an old CD rom IR laser diode and you can send data for kms. Data rate is relatively slow of course, but the hardware required couldn't be simpler.
Another trick I used was to use a 'learning remote' to learn my new protocol. As long as you keep the data rate roughly the same as standard TV/VCR remotes, you won't have any problems with learning remotes.

JimK

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

Jim you're pretty clever .. I like the cdrom diode and learning remote.. heh.

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

JimK wrote:
Throw one of these receiver modules into a big torch parabolic reflector and transmit using an old CD rom IR laser diode and you can send data for kms. Data rate is relatively slow of course, but the hardware required couldn't be simpler.

Cool... so by kms what you really mean is ???

Does a CD IR laser diode need a parabolic reflector? Does it have a lens that narrows the beam to a point on the CD, thus causeing it to spread at further distances? Could you remove the lense and have a tight beam IR laser?

You don't by any chance have this project written up do you?

Curiously yours,
Smiley

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

"kms" == "kilometers"??

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

Ankur

Check out these application notes.

from http://www.atmel.com/dyn/product...

AVR410: RC5 IR Remote Control Receiver (10 pages, revision B, updated 5/02)
This Application Note describes a receiver for the frequently used Philips/Sony RC5 coding scheme

AVR415: RC5 IR Remote Control Transmitter (5 pages, revision A, updated 5/03)
In this application note the widely used RC5 coding scheme from Philips will be described and a fully working remote control solution will be presented. This application will use the ATtiny28 AVR microcontroller for this purpose.

Peter

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

smileymicros wrote:

Cool... so by kms what you really mean is ???

Groups of 1000 metre distances (kilometers)

smileymicros wrote:

Does a CD IR laser diode need a parabolic reflector?

It's next to impossible to get a pinpoint laser dot over long distances.
The beamwidth spreads, even with a really accurate collimator lens. Some form of lens or parabolic reflector on the receive end, just focuses it back to a tight spot again.

smileymicros wrote:

Does it have a lens that narrows the beam to a point on the CD, thus causeing it to spread at further distances? Could you remove the lense and have a tight beam IR laser?

An IR laser diode with no lens at all, does not give a tight beam.
Must use collimator lens, same as in laser pointer.
I only mentioned the word CD because this is a commonly available source for free IR laser diodes. Use an old laser pointer's collimator lens with it.

smileymicros wrote:

You don't by any chance have this project written up do you?

I've just written it up, in this and my previous post.
Inserting a TSOP34838 into a torch reflector requires no additional write up.
Driver circuits for laser diodes are already written up in 'SAM'S laser faq"
Anything else I've written up is in 'ASM' and you've battled with me in the past over this disgusting habit of mine. I have no desire to upset you with bit bashed ASM. I've been thinking about buying your C book,by the way, but for Christ's sake ... don't tell anyone.

JimK

Last Edited: Sat. Dec 10, 2005 - 02:58 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ezcomp wrote:
Jim you're pretty clever .. I like the cdrom diode and learning remote.. heh.

Thanks, but my idea of clever is those dudes who send and land machines on Mars. They are clever.

JimK

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

There's an avr freak that works at JPL. He knows how the Mars Rovers work. I've picked up from ads and such that they are mostly Commercial Off The Shelf components... vme boards and vrtx os I think. Don't know what language though

Imagecraft compiler user

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

bobgardner wrote:
There's an avr freak that works at JPL.

Hi Bob,

What's his AVR Freaks handle ?

JimK

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

JimK wrote:
Anything else I've written up is in 'ASM' and you've battled with me in the past over this disgusting habit of mine. I have no desire to upset you with bit bashed ASM. I've been thinking about buying your C book,by the way, but for Christ's sake ... don't tell anyone.

Battled? Me? :wink:

Smiley

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

Quote:
Inserting a TSOP34838 into a torch reflector requires no additional write up.

Sure it does! Nothing is so simple that it cannot be misunderstood.

#ifdef US_ENGLISH
#define torch flashlight
#endif

Ah, much better.

(Or maybe I'm the only one who mentally stumbled on that one, envisioning villagers chasing Dr. Frankenstein's monster with pitch forks in one hand and TSOP34838-equipped torches in the other).

Mike