2018.03.18 : BML project for using a $2 FTDI FT260Q for adding 14 bits of GPIO to any PC via USB with no device drivers required.
Ever miss the simple days of using a PC’s LPT1 parallel port to bit-bang GPIO over 8 output pins and 4 input pins of the DB-25 connector? I sure do. My first design project as a BSEE graduate in 1993 was to design a LPT1 controlled test fixture for the Motorola MDT-9100-T data terminal (shown below). Those were the days. By multiplexing 12 parallel port pins into 74HC dip CMOS latches and transceivers my test jig tested all the IO signals of the MDT-9100s 386sx motherboard. All of the diagnostic software could be written in C on my Windows 3.1 desktop thanx to this versatile interface. Those were the glorious simple days of computing. Sigh…. Then USB came along and killed the wonderfully easy parallel port interface.
But wait, FTDI has recently introduced a low cost and very versatile USB chip called the FT260Q. It is unique in that it requires no device drivers. It provides up to 14 IO pins that can be used for driving LEDs, reading switches, interfacing to LVCMOS circuits all while requiring very little support circuitry. This open source Black Mesa Labs’ project describes the DIP-18 breakout board for the FT260Q which may be built for under $5.
The 24 x 19 mm 2-layer PCB may be ordered here from OSH-Park for just about $3 for 3 PCBs.
[ Bill of Materials ]
Qty-1 : 768-1268-ND : FT260Q-T IC USB TO UART/I2C 28WQFN : $1.83 Qty-1 : 240-2390-1-ND : FERRITE BEAD 600 OHM 0805 : $0.11 Qty-1 : 609-4613-1-ND : CONN USB MICRO B RECPT SMT R/A : $0.42 Qty-2 : F4239CT-ND : TVS DIODE 24VWM 150VC 0603 : $0.65 Qty-3 : 445-4112-1-ND : CAP CER 10UF 6.3V X5R 0603 : $0.06 Qty-2 : 399-7918-1-ND : CAP CER 47PF 50V C0G/NP0 0603 : $0.10 Qty-3 : 445-5111-6-ND : CAP CER 0.1UF 25V X7R 0603 : $0.10 Qty-4 : Resistor 4.7K 5% 0603 Qty-2 : Resistor 33 ohms 5% 0603 Qty-1 : Resistor 1 Mohm 5% 0603
The FT260 is a USB device which supports I²C and UART communication
through the standard USB HID interface. This is very cool as it means it should work with any USB host platform without requiring any special device drivers. See the FTDI Application Note AN_394 User Guide for FT260 for details on programming the FT260Q, also the datasheet.
To send and receive HID reports from Windows ( or Linux ) in the Python environment, the module hidapi is needed. Download the appropriate hidapi Python WHL for your platform from this link https://pypi.python.org/pypi/hidapi/0.7.99.post21 . For example, at BML, currently running Python35 on 64bit Windows10, so downloaded both hidapi-0.7.99.post21-cp35-cp35m-win_amd64.whl and hidapi-0.7.99.post21-cp35-cp35m-win32.whl .
- Upgrade pip via “python -m pip install –upgrade pip”
- Install WHL via “pip.exe install hidapi-0.7.99.post21-cp35-cp35m-win32.whl”
With hidapi installed, you should now be able to run this example script from BML that will configure all the FT260Q pins as GPIO outputs and toggle them as fast as possible. Note the USB HIDAPI interface to HID-Class devices isn’t “bare metal” blazing fast. This sample Python toggles all the GPIO pins every 300-400uS, or about 1kHz. For Windows, the HID API interface requires all reports be 64 bytes in length, so the example Python here always pads reports with trailing 0x00’s to be exactly 64 bytes long. Untested, but padding the reports under Linux should not be required and may be considerably faster than Windows.
[ ft260q_toggle.py ]
import hid; h = hid.device();# See https://github.com/signal11/hidapi/blob/master/hidtest/hidtest.cpp h.open(0x0403, 0x6030) # FTDI FT260Q device ID h.set_nonblocking(1); print("System Status"); rts = h.get_feature_report( report_num = 0xA1, max_length = 255 ); print( [ "%02x" % (each) for each in rts ]);# list comprehension h.send_feature_report([0xA1,0x02]+[0x00] +[0x00]*61 );# GPIO ON, I2C OFF h.send_feature_report([0xA1,0x03]+[0x00] +[0x00]*61 );# GPIO ON, UART OFF h.send_feature_report([0xA1,0x05]+[0x00] +[0x00]*61 );# GPIO3 ON, Int OFF h.send_feature_report([0xA1,0x06]+[0x00] +[0x00]*61 );# GPIO2 ON h.send_feature_report([0xA1,0x07]+[0x00] +[0x00]*61 );# GPIO4,5 ON h.send_feature_report([0xA1,0x08]+[0x00] +[0x00]*61 );# GPIOA ON h.send_feature_report([0xA1,0x09]+[0x00] +[0x00]*61 );# GPIOG ON h.send_feature_report([0xA1,0x41]+[0x00]*8+[0x00]*54 );# GPIOE,H # 0xB0 : GPIO Write/Read Request # Byte-0 : 0xB0 # Byte-1 : GPIO[5:0] Value # Byte-2 : GPIO[5:0] Direction 0=Input 1=Output # Byte-3 : GPIO[H:A] Value # Byte-4 : GPIO[H:A] Direction 0=Input 1=Output # Output Loop : Configure all 14 GPIOs as Outputs and toggle them while ( True ): h.send_feature_report( [0xB0, 0xFF, 0xFF, 0xFF, 0xFF ]+[0x00]*59);# Toggle h.send_feature_report( [0xB0, 0x00, 0xFF, 0x00, 0xFF ]+[0x00]*59);# All GPIO pins # Input Loop : Configure all 14 GPIOs as Inputs h.send_feature_report( [0xB0, 0x00, 0x00, 0x00, 0x00 ]+[0x00]*59); while ( False ): rts = h.get_feature_report( report_num = 0xB0, max_length = 255 ); print( [ "%02x" % (each) for each in rts[0:6] ]);# list comprehension h.close();
[ GPIO Pin Power Up Defaults ]
Not all pins powerup in GPIO tri-state mode. If powerup condition is important, BML recommends using the non-tristate pins as inputs with series resistors between your circuit and the FT260Q. The tristate pins you should be able to pull high or low on powerup with appropriate (1K) resistor.
0 - Hard Low 1 - Tristate 2 - Tristate 3 - Tristate - pulled up 4 - Hard High 5 - Tristate 6 - Tristate 7 - Hard Low 8 - Tristate 9 - Tristate 10 - Tristate 11 - Tristate 12 - Hard Low 13 - Tristate
[ Future Plans ]
Black Mesa Labs has plans to use this IC as both a SPI PROM programmer and UART interface to future FPGA boards. The low cost, small size and minimal external components ( no crystal, PROM, etc ) make this an ideal IC for low cost educational FPGA development boards from Black Mesa Labs. Next tutorial on using the FT260Q will make use of the internal UART capable of 12Mbaud. Look for future Xilinx Spartan7 boards from BML with a FT260Q embedded for both PROM programming of a bootloader and UART interface for Mesa Bus transfers at 12Mbaud.
[ EOT ]