FT232 USB to Serial Converter chip development using D2XX library

Pinterest icon

Photo showing FT232 chip development using D2XX library and USB2SERIAL board

In this article we will learn to use the D2XX library from FTDI to extend the functionalities of FT232 USB to Serial Converter chip.Most of the people in the embedded field are familiar about the easy to use USB to Serial converter chip FT232 which can easly add a USB Serial port to any microcontroller with an UART.With a  little bit of code and a library (D2XX) from FTDI (makers of FT232) you can easily convert the humble chip into a USB to Parallel converter (8 and 4 bit),USB to RS485 Converter and off course USB to Serial Converter.

Even though this article is written as a companion guide to the USB2SERIAL Converter sold at this website, you can use any FT232 based USB to serial converter board to test the examples present in this article. The only requirement for your hardware module is that you should be able to identify the required pins of FT232 from your board and use it.

Prerequisites

The user is expected to know C language as all the programs are written in it. It is also possible to use D2XX library from other languages like JAVA, Visual Basic, C# etc, their use is not covered in this tutorial. The FTDI website has the relevant information regarding the use of other programming languages.

Application Note AN_232R-01 for the FT232R and FT245R Bit Bang Modes  from FTDI has excellent information about the various bit bang modes available in FT232.

D2XX Programmer's Guide from FTDI gives a detailed explanation of all the API's available from D2XX library to communicate with the chip along with code snippets.
 
 
Software Required
In this example we are using the D2XX library from FTDI to access the various mode of FT232 chip. It is a proprietary library from FTDI that can be used for commercial or non commercial applications. D2XX library is available for both Linux and Windows in this article we are concentrating on the windows version. If you want a community developed open source library to do the same try libftdi.
 
All the examples in the tutorials are compiled on a windows platform(Windows 7) .
 
You will need compiler to compile the c source codes, here we are using MinGW a windows port of GCC along with other tools like make, gdb,g++ etc.
The two IDE's used are Code::Blocks and Eclipse CDT .Both of them are frameworks and do not come with a compiler or debugger, the user should link the require tool chain with them .
 
    
Hardware Required

Buy USB to RS485 converter online from here   Buy USB to RS485 converter online from here (made in India )

Here I am using a USB2SERIAL Converter board from the site. The board has an FT232RL chip for USB to serial conversions. All the output pins of the chip(TXD, RXD...RI, DI) are brought outside to berg strips for easy access. The board can also be used for standard USB to RS232/RS485 conversion. There is a voltage level selector to select between 3V and 5V logic levels. The full specs are available here.
 
Source Code and Library

link to xanthium enterprises repo containing D2XX programming code on github

All the C sourefiles along with D2XX library used in this tutorial can be downloaded from our GitHub Page.If you are new to Github Check this article to download code .

Tutorials
 
The tutorials are organized into 8 sections ,each one building on the other one.It is better to check out the tutorials sequentialy if you are starting out .