Wednesday, January 2, 2013

Giving Up on an IR Transmitter using the FT232R

I wrote previously about my trouble using the D2XX driver with MinGW. The reason I was doing this was to put the device into asynchronous bit-bang mode to drive an IR LED. This way I could turn my VCR on and off from my computer. No real reason why. Just for fun. Well I'm giving up on that. I'm just getting to much jitter to get a steady frequency for an IR driver. Allow me to explain.

When I tested out driving an LED with the D2XX driver in bit-bang mode, I could visibly see the LED flickering even though it was supposed to be steady and dim from using PWM. This shouldn't have been. FTDI wrote a helpful article explaining optimal transfer sizes for the D2XX driver (application note AN232B-03). In it is explained that there are 64 byte USB transfers, 62 of which are my data. Optimal transfers account for this. Also, the FT232R chip has a 128 byte transmit buffer, or 2 USB transfers. So data essentially needs to be streaming at a pretty steady rate over USB to get a steady output on the asynchronous bit-bang pins.

When I upped the baud rate, to something like 921600 or 1048576, it was clear that there was a 62 byte transfer, which toggled at the set rate, and then it was waiting for the next USB transfer, adding a noticeable delay. This delay varied between 21 μs and 75 μs. Now, assuming 90 μs USB transfers for each 64 byte transfer, that's almost 700 kB/s. That rate is more than fast enough for a 38.4 kHz IR signal. But when the baud rate was slowed down, the toggling output was not at a steady rate. I don't have good pictures from the oscilloscope to show but it was pretty bad. One bit might stay on for the expected 1/BaudRate seconds and then the next would stay on for three or four times that. Because of this, I don't feel like it would be effective to try to perform IR data streaming over USB using the FT232R.

In my previous post, I liked to this site, which is attempting to do the same thing. They have had some success but it is also clear that some people couldn't get their code to work with their FT232R setup. This, and the fact that I bought mine from China off of eBay, suggests to me that perhaps the surrounding components supporting my chip aren't that great, which wouldn't surprise me at all. I also can't put out of my mind that maybe the chip itself it counterfeit but I don't think that's the case.

What's my solution? Right now I think the best thing for me to try is to implement this on an MSP430, which would drive the LED, and communicate to it over a serial interface the parameters of the IR data stream. Maybe I would give the MSP430 the IRP and remote control button press data and it would send out the data accordingly. This is all for another day.