Does your data *has* to be 8-bit, 1 start, 1-2 stop just as a normal RS232 communication ? I implemented an IR comm using the following steps. - Set up the PWM to generate the carrier (36 Khz in my case). - Wrote a couple of subs to send "start", "1", "0" and "stop" bits. The subs just enable/disable the PWM generator. Each bit is made up from a "on" and "off" time with different periods for each type of bit. So the PWM carrier is further PWM modulated with the data, in a way. The ons and offs are synced with the tmr2 overflow to get "clean" transitions and stable on and off times. - Created a "protocol" with about 12-14 bits of data (divided into "unit", "command", "value" and so on). - The recieving PIC waits for a rising edge from the IR receiver (TSOP) and then times the "on" period using a timer. The timer is stopped when the "on" period finish. - The "on" periods for the different bit types are such as each bit type corresponds to a specific bit in the timer beeing set. So it's just a number btfss (or btfsc) on the timer value to decode the different bits. Easy. - There is also a check bit at the end as a simple error checking. Each block is sent three times, and the receiver needs a correct check bit to accept the block. There is also a "block number" in the data to protect from multiple readings of the same block. The sender is a 18F1220 and the receiver is a 12F629, both running on the internal osc block. Jan-Erik. - > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Ishaan Dalal > Sent: den 4 december 2003 10:49 > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC:] IR serial transmission > > > As part of an (academic) project, I need to implement > point-to-point IR > transmission using an async serial format. As I understand it, IR > transmissions must use a carrier for preventing ambient IR > interference. 38 > KHz seems to be pretty common. > > I will be using a 16F877 [mandated :-( ]. The AUSART would be > ideal for > baseband stuff, and with an external 38 KHz clock and an AND > gate, this > would be simple. But we need to do as much in software as > possible, so I was > wondering if there was some clever way to directly let the > USART control the > IR LED, since the modulation is simply ASK. > > I thought the PWM module could be used to generate the 38 KHz > carrier, but > how would I use the USART to switch the duty cycle between 0 and 50%, > without some sort of external feedback connection? > > Another approach might be to run the USART at ~38.4 KHz and > "send" 0xAAs and > 0x00s to emulate 38 KHz ASK.... > > Of course, if I just used the PWM and wrote a bit-banged > custom USART these > questions wouldn't arise, but I would love to use the > hardware USART..... > > FYI, the source data is from a PC parallel port. > > Cheers, > Ishaan > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics