Microcontroller 7 Segment Display

0 views
Skip to first unread message

Cándida Jolie

unread,
Aug 5, 2024, 1:34:18 PM8/5/24
to hutchmuttcalto
Ineed to drive a large seven segment display (segment length is a about 2 inches) using a micro-controller (PIC 16F877). I've driven normal seven segments directly from PICs without issues, but I found that 5v is not enough to drive this one. It needed something around 9 volts (is this normal?)

I've supplied 12v to this circuit and used the RV1 preset to adjust it (to make it 9V or something close). 8 inputs to the transistors come from the micro-controller. So I can drive the large 7 segment (which require 9v) this way...


Anyway, then I tried putting the resistor to the collectors side. And took the output from collector pin. That was somewhat ok. But the brightness was varying with the number of lighting segments...(When lighting only one segment, there was very little brightness. It's almost not visible. But when lighting all the segments, brightness was too high. Felt like the display will blow.)


Then, your circuit is a common collector circuit. One of the disadvantages is that it can't drive a load higher than the control voltage - 0.7 V, that's 4.3 V, too little for the LEDs. That's where you're lucky, if it were 3 V LEDs they would have been driven with no current limiting at all \$\rightarrow\$ magic smoke.


The more common way is to drive them common emitter. That is emitter to ground, and LED + resistor in series on the collector side. For a common emitter you'll also need base resistors. 1 kΩ will give you 4.3 mA, which should be enough to drive the BC547 in saturation. You can also use a ULN2803, which is a transistor array of 8 transistors with their base resistors built in. Then you only need one part (except for the current limiting resistors).


Your resistor values are also too high. If each segment needs 9 V and your supply is 12 V then the current though a segment is 3 V/ R. With 10 kΩ resistors that's 300 A, and that's too little for any LED. A typical 20 mA LED would need a 150 Ω resistor. But check the display's datasheet for both voltage and current.


It has constant current outputs, so you don't need the series resistors anymore, brightness won't depend on input voltage variations, and you save I/Os on your controller because it's serially driven. You only need data out, clock, and latch. The current is set with a resistor.


Michael would still use series resistors, but they're probably not required. If you have 20 mA and a 3 V drop (from 12 V to 9 V) then all LEDs on will give you less than 500 mW, which a 16-pin DIP certainly can handle. At higher currents or input voltage they may be a good idea, though.


I have had great success driving large format 7-segment displays using the TLC5916 chip from TI. One chip can drive one display module and if you had multiple modules the TLC5916 chips for each can be connected in series. From the perspective of the microcontroller the display connects with just a few pins as a serial shift register. Simple software can bit bang the interface to output the data for each display update.


The TLC5916 chip can drive displays that are connected to 9V. It also will use a constant current technique for each segment to keep brightness even for all segments. It may be advisable to still put some resistance in series with each segment before connecting to the TLC5916 outputs to share some of the voltage drop and reduce power dissipation in the driver chip.


After seing this (and also this and this) chainable and adressable 7-Segment display it was clear what to do: Why would you use three WS2811 ICs to control a single 7-segment display when a single microcontroller could do it better at a lower cost?


The figure above shows the general concept: Each segement has a serial data input and a serial data output which allows controlling the content of the display. The data from the input of each segment is forwarded to the next, so that it is possible to connect the next digit directly to the output of the previous. Power supply will be routed through all devices.


An important question is which protocol to use: To simplify control, I set myself the target allow control by a standard UART in 8N1 configuration. This is in contrast to e.g. the WS2812, which is controlled in a nonstandard protocol with challenging timing.


I elected to use a PADAUK PFS154-S16 as microcontroller for each segment. This device has flash memory and sufficient I/O to control a 7 segment display without multiplexing. The cost is only $0.07, so it is cheaper than, for example, using multiple WS2811 instead. The data input pin is connected to PA0, which allows using a pin change interrupt to detect incoming transmissions. Data out is PA6, while PB0-PB7 are used to control the display. The schematic is shown below.


To avoid having to add a resistor for each segment, I decided to only use a single current limiting device and run the display in multiplex mode, so that only a single segment is turned on at a time. Originally I planned to use a NSI50010, which is a two terminal current source. Unfortunately it turned out that the voltage drop accross the 7 segment display was too large to allow sufficient voltage for the current source. Therefore I replaced it with a resistor and forfeited on the multiplexing.


The PCB design is shown above. The 7 segment display is attached to the rear side. Angled connecters are used to connect the individual segments of the display. Originally I planned to use the right connector for programming, however it turned out to be much easier to use a SOIC8 clamp to directly connect to the microcontroller.


The challenge is that timing accuracy requirements are getting more strict the more bits are following the start bit. Assuming we are sampling in the center of a bit, the maximum clock deviation needs to be less than 50% of one bit timing. One can show that this is met when the maximum relative clock deviation is less than delta


The relationship between number of bits per frame and maximum allowable clock deviation is shown above. One has to consider that the tolerance is shared between transmitter and receiver. For example, for the 1N1 protocol, the transmitter may skew by -17% and the receiver by +17%.


The practical limit would be given by the power supply. There is no voltage stabilization in the current implementation, so at some point there would too much drop in the supply. That could be solved by feeding in the supply at multiple points in the chain. There is no practical length limit in the comminucation protocol, although the propability of communication issues obviously increases with higher length of the chain.


The 7 segment display is widely used to display numeric data. They are limited by the number of segments (LEDs) they have and hence are not suitable for displaying text. There are some variants of this kind of displays that have 11 segments which enables them to display text also.


This post will deal with the basics of 7 segment displays and how to interface them with microcontrollers. As the name suggests, there are 7 segments to display a number and an additional decimal point. These are essentially LEDs that turn on according to the excitation given by the controller that gives the appearance of the number.


These segments are named with alphabets A through G with a DP (Decimal Point) or in some cases an eighth alphabet H. These 8 pins corresponding to each of the segments are connected to the port pins of a microcontroller.


Yes, there are two types of 7 segment displays. They look alike and there is no way to tell which one you have by just seeing it. If you desoldered it from somewhere, hope you have some marking over it. Though it is not impossible, you will have a difficult time making out what-is-what without part names.


These types are based on which type of pin each LED is tied together. If all the cathodes are grouped to give a singe cathode it called Common Cathode type displays. Similarly there is a Common Anode type which as the name suggests, has the cathode of all the LED put together to form a single cathode.


The human eye has the ability to hold a memory of light signal for some time after they are gone. Put it numerically, your eye will hold the light signal for a little over one quarter of a second. This time is directly proportional to the brightness of the light signal.


In an older article, have already discussed persistence of vision at lengths. You can check that out if you have any uncertainties. Here is the video from that post, just in case you are too lazy to follow the link.


Once you have all the values to be written to the display you have to create the lookup table. The lookup table is nothing but an array which has all the above values. So the code looks into this array and fetches the data to be written to the display.


Siddharth is a Firmware Engineer, techie, and a movie-buff. His interests include, Programming, Embedded Systems, Linux, Robotics, CV, Carpentry and a lot more. You get to know him on the following social channels.


Embedjournal is a blog focusing on embedded software/hardware design and a bunch of other - somewhat - related things. Embedded systems play a vital role in our day-to-day lives, even without our knowledge we are using dozens of embedded devices. This journal is dedicated to all enthusiasts and hackers out there.


I have some attiny85's I wanna use with my one 7 segment display. Does anyone have a schematic that shows how to wire it up and some code that does something basic like count down or something similar. Thanks!


Now a 7 segment display has eight segments including the decimal, so you need eight control pins to fully utilise it or seven if you fancy you don't need the decimal. You are short at least two pins, and if you want to control the display, even more so.


So you could use a shift register like a 74HC595 and if you really want to do that, well, just Google for 7 segment and 74HC595. That will take three control pins - there are ways of fudging it to use fewer.

3a8082e126
Reply all
Reply to author
Forward
0 new messages