Transcript for:
Interfacing Seven Segment Display Tutorial

hello and welcome back to this channel dear students today's topic is interfacing of seven segment display before this i have created one video related to interfacing of led so this is interfacing of seven segment display device so this seven segment display device is also referred as ssd seven segment display device Before talking about the actual interfacing diagram, let me first explain you some basic things. In the previous video, I explained to you that there are two types of connecting LEDs. One is common anode and another is common cathode. In case of 8051, we will prefer common anode connection. Reason is, in common cathode, cathode is connected to the port of 8051, which requires minimum 20 mA current. which is not possible for 8051 so uh whatever led you want to glow you you want to switch it on that will be dim led so to avoid this we will be using common add-on connection is case may so that the current from the anode which is 20 milli amperes goes inside the 8051 which is called as a sink current and 8051 can sink that much current so we will be preparing common anode connection up general seven segment display structure is i have written some uh values like letters like a b c d e f g and this is the decimal point this is the symbol of led this is the anode terminal this one remaining is cathode terminal these are the light rays coming out from the led up the things are very simple just like a sip mujhe eight display So if I want to display 8, that means this decimal point should not be displayed. Means I have to manage only this decimal point. And all the LEDs, see this diagram which I have made, symbol, it represents for one segment. Means for A, here will be an LED, for B, here will be an LED and so on. So to display 8, means to display the whole number 8, then this decimal point should not be displayed. Suppose I want to display 1, then segments. LEDs related to segment B and C should glow only suppose I have to display 5 segments related to A F G C D should be displayed so this is the way how you have to select which LED should be switched on and which should be switched off now we will discuss in programming how to manage this Now this chart, this is important chart, you can make it yourself, you might be thinking this is very lengthy chart, it is not at all. I have written the codes for 0 to F. We are using hexadecimal and this is common anode configuration. How to enter the values? So, the first row is digits. So, I have written the digits from 0 to F. As I have just told you that we have to display 8, that means we have to glow the whole segment. But keep in mind, we are using common anode structure. This means, For the segment which has to glow, zero has to be applied and for the segment which has to not glow, which has to not be turned on one has to be applied because it is a common anode connection So, I just have to turn on the decimal point and all the other segments So, I have not written anything for the segment which has to be turned on Ideally, as I am discussing about 8, for the segment which has to be turned on I have to give zero, logic zero and the off point, this decimal point has to be off for that we have to give 1 so this is the format means if we want to display A to DG then all the segments A to G, logic 0, B to logic 0 C to logic 0, like this and for DC, decimal point logic 1 should be applied now how to write this value, it is very simple we know the procedure in binary we write like this, 1, 2, 4 after calculating in binary look at the values do the relative groups, last 4 lines it is 0 0 0 1 so it is I mean I will write it over here it is 0 0 0 1 so 1 into 1 1 over here sub 0 so last digit I it's a relative yeah one because this is one yeah one day coming in but keep sub 0 day so I mean it's a political bit sub 0 day so everything will be 0 chat chat you groups current 0 0 0 0 so I have written 0 so it is 0 1 likewise If I want to display 5, then the corresponding segments will be like this. This which I am making with black ink, this will only glow. This means that this is the color of this. The values related to this, we have to do only logic 0. Rest we have to do logic 1. What we have to do is, segments B, E, C I mean B, B, E and DP so look at 5 B then E and DP whatever wherever values I have not written any values by default these values are logic 0 to year over a format logic 5 I mean number 5 display correctly up is the hex value can say calculate can you feel say charge our groups below yes I say yeah Charaka group parameter so it will be 1 0 0 1 so 1 into 1 1 This is 0, 8 into 1, 8, 8 plus 1, 9. So, here 9 is given. Then, make this charge group. So, it is 0, 1, 0, 0. So, its value is 4, rest is 0. So, this is 4. And it is exact decimal. So, I have written 0, X, 4. Likewise all the values I have written. And this is hexadecimal so we know the rule after 9 does not come 10. It is A, B, C, D, E and F. So this is the table which is required to apply coding when you are interfacing 7th segment display to the microcontroller. Next part is interfacing multiplexed display. Suppose we have this requirement, we need to make use of 4 7 segment displays. Like shown in this diagram. 1, 2, 3, 4. Use 4 7 segment displays. then we know that we can connect one seven segment display to one port so naturally we will be requiring four ports is 8051 port 0 port 1 port 2 or port 3 all ports will be engaged for this particular interfacing so if any other input output device apart from this thing if needs service from 8051 then it will be difficult to avoid this we use a concept that is the multi interfacing of multiplex display what is this concept the see generalized block diagram a pin diagram of IC 8051 we already discussed xtl1 xtl2 is the which may crystal oscillator connect cartel this company say 11.0592 megahertz then we have already discussed in earlier videos functioning of all other pins these are immortals as far as this seven segment display interfacing is concerned up the code we have discussed that we will be using common anode configuration with a break and or common Karna and then it will be applied to a particular port. Now, how does it work? I have shown four seven segment displays. These four are connecting, I mean, are interfacing to the microcontroller 8051. This CA pin indicates common anode configuration or common anode pin. Now, one of the four, at a time, we need to activate one particular display. I mean, at a time, even though four seven segment are connected it work a key seven segment display activate come I look at the diagram for four devices for four SSDs this is also abbreviated as SSD seven segment displays for four SSDs for PNP transistors are connected is the arrow the career arrow so it is PNP configuration is covered other transistor is used in PNP configuration base matter logic If we apply pin 0, then that particular transistor will get activated. For example, this CA pin is connected to the last PNP transistor. See the base connection of this. I will use different pin to show this connection. This base connection is connected to P2.0 pin. This is a pin of port 2. Suppose I have to activate only this pin. This is a pin of port 2.0 pin. We have discussed this earlier. These 1 kilo ohm resistors are current limiting resistors. In every display, this line, say, A, B, C, D, E, F, G and D, P, that we have already discussed, again, all these things, all these resistors connected with each segment, A, B, C, D, E, F, G and D, P, decimal point, are having 1 kilo ohm resistors, whereas these resistors are 10 kilo ohm each. And this is the 5 volt supply. So, it is the common mode of... common anode configuration I just have to activate this last line because this pin P2.0 pin is connected to the base terminal of this transistor. So I have to activate this. That means I will have to apply logic 0 to this terminal. This is pin corresponding to 2.0. So I have to give 0 here. The other pins, look at other pins 2.1, 2.2, 2.3. These are connected to different transistors, remaining three transistors. So this is the model. logic 1 apply karnah hai matlab this configuration will be 0 1 1 1 if we will maintain this then at a time at one time only this last transistor will be enabled and this particular display this particular shd seven segment display will be interfaced at one particular time because we are applying logic 0 to pin number 2.0 whereas logic 1 to pin number 2.1 2.2 and 2.3 is cut in another language what we have to do the sequence the code this is 0 1 1 1 we know that in case of a binary the sequence is like this 1 2 4 8 16 and so on to a 0 head so this becomes 4 into 1 plus 2 into 1 plus 1 into 1 so it is 4 plus 2 plus 1 it is 7 that means if we apply 0x this is representing a hexadecimal 0 7 then it will activate only last SSD that is the SSD 7 segment display which is connected to pin 2.0 likewise humlok other is cool 0 carrying a it's good logic drop like an all remaining three bits will maintain it at logic one then this particular 7 segment display will be activated. But the requirement is that for the user, these four displays at a time, I mean, user should feel that all these things are working simultaneously. So, how to achieve this task? How to achieve this thing? Like I told you that this particular seven segment display is activated just after 20 milliseconds. Why 20 milliseconds? Because this is beyond the persistence you are. of our eye. That is beyond the persistency of human eye. So we feel that it is a continuous display. So this is about interfacing of multiplex display for 8051. From the example of your question related to this is a draw and explain the interfacing of multiplex display for for microcontroller 8051. Now, let us solve one numerical related to interfacing of 7-segment display. Draw interfacing diagram of 7-segment display connected to mode 1 to display hex counter and write the program. I mean write the program in embedded C by default. Assume delay 10 milliseconds. If delay is not given, then you can assume it on your own. Let us say given delay is 10 milliseconds. Then we program explain cut. then I will draw the interfacing diagram now we have to remember some basic concepts for delay like T in is a fixed value of 1.085 microsecond which means 1.085 x 10-6 then we have to calculate N which is required delay upon T in now see here the required delay is 10 ms so how will we calculate N? this is the fixed value of 10 ms upon T in to minus 6 yeah millisecond a is late 10 into 10 raise to minus 3 to scan so I am 9 to 1 6 point 58 in normal division Kia out you can question you important a hurry delay clear concept a other of low counter Kelly I'm an avid user character for 0 killing a formula more 1 more 2 up yeah when you answer I ahead this is 5 6 3 2 0 so we have to select more 1 because it is less than 6 five five three six so I am selecting mode one is silly is a related come and look at six five five three six minus yeah so minus yeah yeah decimal point skip here yeah so answer is five six three two zero I have to convert it into X form so after converting the answer is DC 0 0 is come at level two two bits competition carrying a 0 0 will be applied to TL 0 00 will be applied to TNG and this DC will be applied to TH 0 0 means timer 0 so we are using timer 0 and mode 1 why mode 1 because calculated value is this much all right now see what is the meaning of hex counter It is hexadecimal, means 0, 1, 2, 3 up to 0 to 15 count but we know that in case of hexadecimal numbers will be 0, 1, 2, 3 means we have to display like this 0, 0, 0, 1 up to this 0 9 but in hexadecimal there is no 10 number so it is 0 a then 0 b up to 0 f this is the basic concept so include this header file is included for 8051 then a display defined care display people define uh dspp one wide main void then your display initialize kia DSP P 1 0 X 0 0 X a decimal initialize correct 0 0 the kinesis let's get a integer defined k integer G a big loop up like a deco homologous 16th account karma a 16 numbers total 16 digits to display karma to 0 to 15 um come correct so J equals to 0 J less than or equals to 15 and J plus plus we know that this is normal for loop Harvard DISP is equal to J J value will be displayed and we will call a delay function over here. This particular thing is condition for while 1 After that this loop will be executed Then Delay, now this is the standard format of delay Void, delay, void. Now see, we have already discussed T-Mode register. We do remember that we are using timer 0 and mode 1. So, T mod is equal to 0x, 0x is hexadecimal, 0x1 is number indicates timer 0, mod 1. We have already discussed the concept of T mod in earlier videos. Now, as you can see, according to this calculation, 00J should be loaded into TL0, then DC should be loaded into TH0 and TR0 should be made 1. We have also discussed T mod register, we have learnt this concept. Now, while this, till when this... applicable while this flag tf0 is equals to 0 means its value will be 0 till then it will be execute after that you need to reset all the flags so TR 0 and TF is equals to 0 this is the void delay program so this is about the programming part now let me draw the interfacing diagram one more thing what can be the variation in this this program is standard in this variation sir village or jelly will change this calculation will change accordingly you will have to select uh mode uh zero mode one or mode two but timer zero or timer one is optional if nothing is mentioned in the question now let us discuss about the interfacing diagram this is the interfacing diagram for uh interfacing of seven segment display i have already explained the things while discussing the programs then this is the set terminal we already discussed this point port one co uh interface so there are eight lines this is display driver jo many multiplex k diagram so readymade is available seven four two four zero which acts as a display driver so these are corresponding segments a b c d up to f g and this is the seven segment display so you need to draw this interfacing diagram and you need to write the program so dear students That's it for today's session. So thank you. Thanks a lot for watching this video.