(34 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
[[Category:AVR Tutorials]]
 
[[Category:AVR Tutorials]]
In this tutorial we will looking at interfacing a '''Seven Segment Display''' to Atmega32 MCU. We will also look at multiplexing 4 seven segment displays and programming them.
+
 
 +
In the earlier tutorials we saw how to interface the Leds to Atmega32 and wrote the code to blink, generate up counter, ringcounter etc. How ever the leds cannot be used to display any user information like numbers, char's etc. To display numeric values we can use seven segment displays.
 +
 
 +
In this tutorial we will interface a seven segment to ATmega32 and display a single digit hex counter(0-F).
 +
Later same will be extended to multiplex 4 seven segment displays to generate a 4-digit counter.
 +
 
 
=Seven Segment Display=
 
=Seven Segment Display=
 
[[File:BasicSevenSegmentDisplay.png|thumbnail|fig 1: Basic 7 segment Display]]
 
[[File:BasicSevenSegmentDisplay.png|thumbnail|fig 1: Basic 7 segment Display]]
[[File:7 segments Indicator.gif|framed|fig 2: Simulation]]
 
 
Well, the name 7 segments implies there are 7 LED segments arranged as shown in figure 1.  
 
Well, the name 7 segments implies there are 7 LED segments arranged as shown in figure 1.  
After LEDs they are the easiest interfaces to a microcontroller.  
+
After LEDs, these are the easiest interfaces to a microcontroller.  
 
There is also a decimal point or dp. It is used when decimal digits like 5.1 etc are displayed.
 
There is also a decimal point or dp. It is used when decimal digits like 5.1 etc are displayed.
 
==Applications==
 
==Applications==
 
Seven segment are widely used in applications where digits[0-9] are required to be displayed.Although they also display letters A to F as shown in figure(2) simulation.
 
Seven segment are widely used in applications where digits[0-9] are required to be displayed.Although they also display letters A to F as shown in figure(2) simulation.
 
This is a very simple and convenient way to display numbers in a bright fashion.  
 
This is a very simple and convenient way to display numbers in a bright fashion.  
==Form Factor==
+
==Form Factor==  
  
 
*'''Sizes''':They come in various sizes; 0.28”, 0.3”, 0.32”, 0.36”, 0.39”, 0.4”, 0.5”, 0.56”, 0.6”, 0.8”, 1.0”, 1.2”, 1.5”, 1.8”, 2.0”, 2.3”, 3.0”, 4.0”, 5.0”, 7.0”)  
 
*'''Sizes''':They come in various sizes; 0.28”, 0.3”, 0.32”, 0.36”, 0.39”, 0.4”, 0.5”, 0.56”, 0.6”, 0.8”, 1.0”, 1.2”, 1.5”, 1.8”, 2.0”, 2.3”, 3.0”, 4.0”, 5.0”, 7.0”)  
Line 17: Line 21:
 
[[File:Common Cathode 7Segment.jpeg|thumbnail|fig 3:Common Cathode Display]]
 
[[File:Common Cathode 7Segment.jpeg|thumbnail|fig 3:Common Cathode Display]]
 
[[File:Common Anode 7Segment.jpeg|thumbnail|fig 4: Common Anode 7 segment]]
 
[[File:Common Anode 7Segment.jpeg|thumbnail|fig 4: Common Anode 7 segment]]
Since these are basically LEDs arranged as a group they can either have anode in common or cathode.
+
Since these are basically LEDs arranged as a group they can either have anode in common or cathode thus they are named as Common-Anode/Common-Cathode displays.
*'''Common Cathode''': This type of 7 segments, requires a positive voltage(5v) to given to the segments '''a''' to '''g''' in order to glow. This is shown in figure(3). Providing a positive voltage with respect to common cathode makes the LED forward biased.
+
*'''Common Cathode''': In this type of segments all the cathode terminals are made common and tied to GND. Thus the segments '''a''' to '''g''' needs a logic High signal(5v) in order to glow.This is shown in figure(3). <br><br>
*'''Common Anode''': This type of 7 segments, requires a negativevoltage(GND) to given to the segments '''a''' to '''g''' in order to glow. This is shown in figure(4). A ground connection to cathode with respect to common anode again forward biases the LED which glows.<br />
+
*'''Common Anode''': In this type of segments all the anodes terminals are made common and tied to VCC(5v). Thus the segments '''a''' to '''g''' needs a logic LOW signal(GND) in order to glow.This is shown in figure(4).<br />
 +
 
 +
=Hookup=
 +
 
 +
[[File:Interfacing Seven Segment Displays with AVR bb.png|none]]
 +
 
 +
=Code=
 +
<html>
 +
<script src="https://gist.github.com/raghavendrahassy/05af8109f493afdddf47dc62fd115fde.js">
 +
</script>
 +
</html>
 +
 
 +
<html>
 +
<ul>
 +
<li>Explore Ultra AVR Dev Kit: <a https://www.exploreembedded.com/product/Explore%20Ultra%20AVR%20Dev%20Kit> Buy from EE Store </a></li>
 +
<a href="https://www.exploreembedded.com/product/Explore%20Ultra%20AVR%20Dev%20Kit">
 +
<img src ="https://www.exploreembedded.com/blog/wp-content/uploads/img-collections/explore-avr-pic-kit/1-dsc03897.jpg" width="480 px">
 +
</a>
 +
</ul>
 +
</html>
  
=Interfacing Single Seven Segment Display=
+
[[File:0Interfacing Seven Segment Displays with AVR.gif|none]]
==Schematic==
+
The seven segment is interfaced as shown in the schematic below. Notice that sending a '''logic one''' to segments '''a to g''' will turn them ON. With that we can create a sequence.
+
  
[[File:Schematic AVR Interfacing 7Segment.JPG|680px]]
+
=Video Tutorial=
[http://exploreembedded.com/wiki/images/1/17/Schematic_AVR_Interfacing_7segment4.pdf '''Schematic:4Segments''']
+
For those of you, who would like to watch instead of read we have made a video with all the gyan.
 +
<br>
 +
{{#ev:youtubehd|-lNAmSNV2-Q|640}}
  
==Code==
 
<syntaxhighlight>
 
  
#include <avr/io.h>
+
= Downloads=
#include <util/delay.h>
+
Download the complete project folder from the below link:
PORTC = 0XFF;
+
https://github.com/ExploreEmbedded/ATmega32_ExploreUltraAvrDevKit/archive/master.zip<br>
uint8_t seg_code[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
+
                                0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
+
uint8_t cnt =0;
+
int main(void)
+
{
+
while(1)
+
{
+
for(cnt =0; cnt<16; cnt++)
+
{
+
PORTC = seg_code[cnt];
+
_delay_ms(1000);
+
}
+
}
+
}
+
</syntaxhighlight>
+
  
[[File:Schematic AVR Interfacing 7segment4.JPG|680px]]
+
Have a opinion, suggestion , question or feedback about the article let it out here!
'''Code and explanation will be updated soon..'''
+
{{DISQUS}}

Latest revision as of 11:00, 4 May 2016


In the earlier tutorials we saw how to interface the Leds to Atmega32 and wrote the code to blink, generate up counter, ringcounter etc. How ever the leds cannot be used to display any user information like numbers, char's etc. To display numeric values we can use seven segment displays.

In this tutorial we will interface a seven segment to ATmega32 and display a single digit hex counter(0-F). Later same will be extended to multiplex 4 seven segment displays to generate a 4-digit counter.

Seven Segment Display

fig 1: Basic 7 segment Display

Well, the name 7 segments implies there are 7 LED segments arranged as shown in figure 1. After LEDs, these are the easiest interfaces to a microcontroller. There is also a decimal point or dp. It is used when decimal digits like 5.1 etc are displayed.

Applications

Seven segment are widely used in applications where digits[0-9] are required to be displayed.Although they also display letters A to F as shown in figure(2) simulation. This is a very simple and convenient way to display numbers in a bright fashion.

Form Factor

  • Sizes:They come in various sizes; 0.28”, 0.3”, 0.32”, 0.36”, 0.39”, 0.4”, 0.5”, 0.56”, 0.6”, 0.8”, 1.0”, 1.2”, 1.5”, 1.8”, 2.0”, 2.3”, 3.0”, 4.0”, 5.0”, 7.0”)
  • Colors: and varied colors too; Red, Green, Yellow, Orange, Blue, and White.

Working

fig 3:Common Cathode Display
fig 4: Common Anode 7 segment

Since these are basically LEDs arranged as a group they can either have anode in common or cathode thus they are named as Common-Anode/Common-Cathode displays.

  • Common Cathode: In this type of segments all the cathode terminals are made common and tied to GND. Thus the segments a to g needs a logic High signal(5v) in order to glow.This is shown in figure(3).

  • Common Anode: In this type of segments all the anodes terminals are made common and tied to VCC(5v). Thus the segments a to g needs a logic LOW signal(GND) in order to glow.This is shown in figure(4).

Hookup

Interfacing Seven Segment Displays with AVR bb.png

Code

0Interfacing Seven Segment Displays with AVR.gif

Video Tutorial

For those of you, who would like to watch instead of read we have made a video with all the gyan.


Downloads

Download the complete project folder from the below link: https://github.com/ExploreEmbedded/ATmega32_ExploreUltraAvrDevKit/archive/master.zip

Have a opinion, suggestion , question or feedback about the article let it out here!