Electronic – Issues related to Bit-banging transceiver modules

infraredmicrocontrollertransceiver

I have two Infrared Transceiver modules from TFDU4101-TR3 on two separate boards each interfaced to ATMega164PA microcontroller. To drive these transceivers an endec is needed which I have not used in my design due to budget constraints.

So what I am trying to do is bit-banging. The RX and TX follow normal standard, RX is active low and TX is active high. I am toggling the TxD pin one 'Board A' 50 times at 5 Khz to send 50 pulses to the receiver. On 'Board B' I have implemented a PIN change interrupt which should technically receive 100 pulses (2 pulses for each transmit pulse that it receives). This is not the final design, I just learning and experimenting how to transmit data from one board to another.

Now the problem is that when I send 50 pulses from Board A to Board B, I do not get 100 pulses, but instead I sometimes get 90 or 81 or 98. In short I don't get the intended number of pulses. Is there something wrong with my approach?

Please let me know if any further information is needed.

Best Answer

The general approach sounds OK but you need to be careful that you don't exceed the maximum transmit pulse length. It appears from the datasheet 20 uS is a typical pulse length and if exceeded by too much you can see it will cause the LED driver to be disabled:

This Schmitt-Trigger input is used to transmit serial data when SD is low. An on-chip protection circuit disables the LED driver if the TXD pin is asserted for longer than 50 μs (max. 300 μs).

So assuming your 5 KHz is a square wave you'll have exceeded that pulse duration. Once that's sorted out things should be more reliable, although the last time I used an IrDA transceiver I was getting on or two percent of packets that were corrupted so it's worth considering error detection depending on what you're doing.

It's also worth noting that some Atmel (and other) microcontrollers have a USART mode that complies with IrDA timing, although after a quick look at the datasheet that particular part doesn't appear to have that feature.