Interfacing 7 Segment LED Display with FT232

Pinterest icon

lt543 7 segment LED Display  interfaced with FT232 usb to serial converter using D2XX library

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  link to article in hackaday,You can read the article on hackaday here.

 

Source Code and Circuit Diagram

link to xanthium enterprises repo containing Serial Programming Code using Win32 API on GithubAll 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 .

Circuit diagram for the tutorialCircuit Diagram for interfacing 7 segment LED Display with FT232 can be found here.

 

Hardware Used 

USB2SERIAL - An easy to use USB to RS485/RS232/Serial converter which can also be used as a FT232 development board .More Details 

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

 

Video

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.

7 segment LED driver circuit for interfacing with FT232

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.

pinouts of LT543 common cathode 7 segment display

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.

fully assembled 7 segment LED driver circuit on a general purpose PCB                               

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.

photo of usb to serial converter based on FT232 from FTDI

The following figure shows the block diagram for controlling the 7 segment display.

block diagram for interfacing Ft232 with Lt543

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.

pin details of FT232 in Asynchronous bit bang mode

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 .

pin configeration of USB2SERIAL

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
char code;
code = 0x02 + 0x04; //segment b +segment c

or you can use

code = 0x06; //to draw 1

Code

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()
FT_status = FT_Open(0,&FT_handle);

// Enter Asynchronous BBM
Mode = 0x01;              // Select Chip mode as Asynchronous Bit Bang
Mask = 0xff;              // Direction Mask,8 bit port all output

FT_status = FT_SetBitMode(FT_handle,Mask,Mode); //sets Asynchronous BBM

//Set Baud rate = 9600
FT_status = FT_SetBaudRate(FT_handle,BaudRate); //Sets FT232 to 9600 baud

//array containing the control codes
UCHAR Segment_Characters[]  = {0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0xFF};

int i = 0;
for (i = 0;i<sizeof(Segment_Characters);i++)
    {
        Buffer = Segment_Characters[i];
                
        FT_status = FT_Write( FT_handle,       // handle to the chip
                              &Buffer,         // address of the data
                              sizeof(Buffer)// Size of the Buffer
                              &BytesWritten    // Number of bytes written
                            );
                                    
        if(FT_status == FT_OK)             // Error Checking
            printf("\n\n\t  0x%x data written",Segment_Characters[i]);
        else
            printf("\n\t  ERROR! in Writing to Port");
    }

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.

compiling the code for controlling the display using gcc and D2XX library from FTDI

Running the Program after compiling

running the code

Connection between the USB2SERIAL board and LT543

 

 

Comments

sharu007's picture

is that buffer really required ?

its safe to add one

uclover's picture

is it possible to add two or more seven segment displays

yes,
you could do that by using 74LS47 BCD to seven segment converter chip,
use the first 4 bits of FT232 ports to provide the BCD code and the other 4 bits to enable the displays one by one .
you can drive upto 4 7 seven segment displays like that.

Data sheet of the IC here
http://www.ti.com/lit/ds/symlink/sn74ls47.pdf

paulythomas's picture

wat abt uln2003

its better to use uln2003 if you are using more than 1, 7segment display.
.Just connect the abcd..f pins of 74LS47 chip to ULN2003 inputs.

uln2003 can provide more current compared to 74ls244