Ftdi FT230X based receiver gives incorrect timings for received IR pulses.

John Penfold <[email protected]>
Newsgroups gmane.comp.hardware.lirc
Message-ID <1584122.NuBXiXglZR@donibristle>
Hi All,

I have built a USB infra-red receiver based on ftdi's FT230X chip. For testing 
I used a pc that was already set up as a MythTv frontend with LIRC using the 
serial port (lirc-serial), running Debian GNU/Linux 9.0 (Stretch), with lirc 
version 0.9.4c-7 and libftdi version 1.3-2+b2
After reconfiguring it to use the ftdi driver, mode2 produced output when 
buttons on the remote were pressed but there was no output from irw. 
Investigation revealed that LIRC could not find a remote control config with 
timings that matched the received signal.

Comparison between the mode2 outputs when using the ftdi receiver and the 
serial port receiver showed that the ftdi receiver pulses were twice the 
width. The signal going into the FT230X was the correct width.

The device was built for receiving only, but I tried sending by connecting the 
transmit output pin to an oscilloscope, the pulses were half the width they 
should have been (with discontinuities in the modulation pulses). I tried it 
with the ftdix driver which gave the correct output.

Looking through the code in ftdi.c i found in parsesamples() the following 
(from line 151)
		/* Convert number of samples to us.
		 *
		 * The datasheet indicates that the sample rate in
		 * bitbang mode is 16 times the baud rate but 32 seems
		 * to be correct. */
		usecs = (rxctr * 1000000LL) / (rx_baud_rate * 32);
I wanted to verify this, and tried using the libftdi python bindings to write 
a small python program to do it. I found that if you set the baudrate before 
entering bitbang mode, the bitbang clock will be 16 times the baudrate you 
set, if you set the baudrate when in bitbang mode the clock will be 64 times 
the baudrate you set.
This is caused by libftdi's ftdi_set_baudrate(), when you are in bitbang mode 
it multiplies the baudrate by 4 before setting the chip. I could not find any 
mention of this "feature" in the documentation.:

In lirc the baudrate is set while in bitbang mode, the bitbang clock is 
therefore 64 times the baudrate you set. This suggests that the 32 in 
parsesamples() should be 64, which would halve the number of microseconds of 
the pulse, giving the correct result.

Does the ftdi driver work correctly with any other ftdi chip (e.g. FT232R)? Is 
it only the FT230X that causes problems?


       John.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.