Interfacing 7 Segment LED Display with FT232
In this tutorial we will interface a 7 Segment LED display serially using FT232 USB to serial converter chip and D2XX library from FTDI.D2XX is a library released by FTDI international,makers of FT232 and other FT series chip to access the advanced functions of the FT232 chip.The control program is written in standard C using D2XX library and is compiled using opensource GCC compiler on a windows 7 machine.Please note that this tutorial is specific to FT232 chip and will not work with USB to serial converter chips manufactured by other companies( like TUSB3410 from TI).
This article was featured on ,You can read the article on hackaday here.
Source Code and Circuit Diagram
Circuit Diagram for interfacing 7 segment LED Display with FT232 can be found here.
USB2SERIAL - An easy to use USB to RS485/RS232/Serial converter which can also be used as a FT232 development board .More Details
Here is a short video of FT232RL USB to Serial converter chip controlling and displaying characters on a 7 Segment Display without using a Microcontroller.
FT232 Bit Bang Modes
The FT232 chip has 3 modes besides the usual USB to Serial conversion mode,they are
- Asynchronous Bit Bang Mode,
- Synchronous Bit Bang Mode
- CBUS Bit Bang Mode
The Asynchronous Bit Bang Mode will convert the FT232 to a USB to 8 bit Parallel port converter,here we are going to use that mode to control a 7 segment LED display from a PC.
If you are new to the modes mentioned above you can check this tutorial to learn about them,the tutorial is quite comprehensive and covers setting up of GCC compiler,IDE,accessing the asynchronous and CBUS bit bang modes.
If you are not interested in all the nuts and bolts of FT232 and just the relevant parts,then you can check this tutorial about Asynchronous BBM.
LT543 Driver Circuit
Since we are interfacing a 7 segment display to a FT232 port pins, i have decided to use an octal buffer between the FT232 and the 7 segment display to be on the safe side. Here i am using 74LS244 octal buffer and the below figure shows the circuit of the LED driver module.
Here I am using a common cathode LED 7 segment display called LT543 which is easily available in the market.The Pinout of the LT543 display are shown below.The pins 3 and 8 (labelled in green font) are the common cathode (or ground) which should be tied together and connected to the ground of your circuit.
You can easily assemble the circuit on a general purpose PCB.The 74LS244 requires +5V to function which can be easily obtained from the USB port (FT232).The below figure shows the fully assembled circuit.
USB to Serial Converter Board ( USB2SERIAL )
We are going to control the LT543 7 segment display from a windows PC through a Virtual Serial port connection, for that you will require a FT232 Break out board.The program running on the PC will communicate with the FT232 board and which in turn will activate the LT543 pins displaying the various characters.Here I am using the USB2SERIAL board in which all the pins of FT232 are brought out.It also has extra 5V,3V and Ground pins available which can be used to power your LT543 driver board .The USB2SERIAL board can also be used for controlling RS485 networks from your PC.
The following figure shows the block diagram for controlling the 7 segment display.
The green board in the middle is a FT232 based USB to serial converter which is used to convert the USB signals into 8 bit parallel data stream.The USB to parallel conversion is achieved by putting the FT232 chip in Asynchronous Bit Bang mode by the software running on the PC.In Asynchronous Bit Bang mode, the serial pins of FT232 are converted to a 8 bit Data bus as shown in the below figure.
The data pins D0-D7 of FT232 are then connected to segments a - dp of LT543.
If you are using USB2SERIAL board ,the +5V and Ground are available at connector K2.The figure below shows the serial pins and their associated data pins for USB2SERIAL board in Asynchronous Bit Bang mode .
Controlling the Segments of LT543
The individual segments of the display can be controlled easily by making the corresponding bits high.
For example to switch on the 'segment a' ,make D0 bit high and the rest of the bits(D1-D7) low (0x01).
To switch on 'segment b' , make D1 high rest low (0x02).You can find the complete list in the code file download.
To create characters you can combine the codes for the individual segments (OR-ing them).For example to create the character 1, you can activate the segments b and c using the following code.
// to create 1
code = 0x02 + 0x04; //segment b +segment c
or you can use
code = 0x06; //to draw 1
The code for the tutorial is written in C using the functions provided by D2XX library to access the FT232 functions and compiled using opensource GNU C Compiler (GCC).If you are new to D2XX library,I would recommend reading the article about D2XX library first .
The below code shows the relevant section of the complete program used for controlling the display from PC using FT232 chip.The code shown below is used for controlling the individual segments of LT543.
// Open a connection to FT232 using FT_Open()
// Enter Asynchronous BBM
FT_status = FT_SetBitMode(FT_handle,Mask,Mode); //sets Asynchronous BBM
//Set Baud rate = 9600
//array containing the control codes
int i = 0;
The program opens a connection to the FT232 chip using the FT_Open() command.When you are using the FT_Open() command there is no need to provide the COM port number like COM31 or COM42 as D2XX library is automatically able to determine the name of the FT232 serial port.
After the connection is opened, the FT232 chip is put into the Asynchronous Bit Bang Mode by using the FT_SetBitMode() function.In this mode the pins of FT232 (TXD,RXD.......~RI) acts as an 8 bit parallel port.
The control codes for activating the segments of LT543 are stored in the array Segment_Characters .They are then written into the FT232 port using FT_Write() function Byte by Byte.
Compiling and Running your Code
The code is compiled using GCC.While compiling the code make sure that GCC is added to your system path so that you can invoke the compiler from anywhere.Please make sure that ftd2xx.lib and the the header file ftd2xx.h are in the same folder as your source file while compiling.
Running the Program after compiling
Connection between the USB2SERIAL board and LT543