Another simple I/R transmission system

1 post / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Originally used in an 8051 based laser tag system although easily cross assembled into AVR assembler. No need for interrupts or timers, just simple timing loops.

Here is part of the original code:-


                JB TXD,LOOP1
                SETB TXD3  ;turn on I/R modulation
                JB TXD,TXD2HI  ;delay ~13uS
                JB TXD,TXD2HI  ;and check if Txd goes high
                JB TXD,TXD2HI  ;and exit if it does
                JB TXD,TXD2HI
                JB TXD,TXD2HI
                JB TXD,TXD2HI
                CLR TXD3  ;Txd went high,I/R mod off.
                NOP   ;38K timing balance 
                JB TXD,LOOP1  ;exit if Txd goes low
                JB TXD,LOOP1  ;delay ~13uS
                JB TXD,LOOP1
                JB TXD,LOOP1
                JB TXD,LOOP1
                AJMP TXD2LO  ;Txd still low, repeat 38K


Called immediately after sending a byte to the UART.

You will need to detect transmit buffer empty(UDRE) in LOOP1 and execute a RET.

Use  PINx to test the state of the Txd pin ( JB TXD)

Txd is the UART transmit pin and TXD3 is the port bit that drives an N channel FET, driving an I/R diode with series resistor to Vcc/Vbatt.

Works at baud rates up to 1600 or so.

Keep the overall timing loop to 25-26uS for 38KHz modulation.