Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:iot-open:practical:hardware:itt:avr:segment_display [2025/08/26 08:09] – created ingmar05en:iot-open:practical:hardware:itt:avr:segment_display [2025/09/02 09:21] (current) raivo.sell
Line 1: Line 1:
 <pagebreak> <pagebreak>
 ====== 7-segment LED display ====== ====== 7-segment LED display ======
- 
-//Necessary knowledge:  
-[HW] [[en:hardware:homelab:digi]],  
-[LIB] [[en:software:homelab:library:module:segment_display]], \\ [LIB] [[en:software:homelab:library:delay]]  
-[PRT] [[en:examples:digi:led]]// 
  
 ===== Theory ===== ===== Theory =====
Line 11: Line 6:
 [{{  :examples:display:segment_display:7-seg.jpg?100|7-segment}}] [{{  :examples:display:segment_display:7-seg.jpg?100|7-segment}}]
  
-7-segmented LED number-indicator is a display which consists of 7 LEDs positioned in the shape of number 8. By lighting or switching off the corresponding LEDs (segments), it is possible to display numbers from 0 to nine as well as some letters.+7-segmented LED number-indicator is a display that consists of 7 LEDs positioned in the shape of the number 8. By lighting or switching off the corresponding LEDs (segments), it is possible to display numbers from 0 to nine as well as some letters.
  
-Electrically all anodes of the LEDs are connected to one anode pin //ca//. LEDs are lit by switching their cathodes (//a, b, c...//). Exists also reversed connections, where the indicators have a common cathode //cc//. Generally several number-indicators are used for displaying multi digit numbers - for this purpose the indicators are equipped with coma (point) segment //dp//. All in all one indicator has 8 segments, but they are still called 7-segmented according to the number of number-segments.   +Electricallyall anodes of the LEDs are connected to one anode pin //ca//. LEDs are lit by switching their cathodes (//a, b, c...//). There also exist reversed connections, where the indicators have a common cathode //cc//. Generallyseveral number-indicators are used for displaying multi-digit numbers - for this purposethe indicators are equipped with a comma (point) segment //dp//. All in allone indicator has 8 segments, but they are still called 7-segmented according to the number of segments.   
  
 [{{  :examples:display:segment_display:segment_display_leds.png?300|Positioning of the LED indicator's segments and electrical scheme}}] [{{  :examples:display:segment_display:segment_display_leds.png?300|Positioning of the LED indicator's segments and electrical scheme}}]
 [{{  :examples:display:segment_display:segment_display_driver_logic.png?300|The build-up of the LED driver's shift-index with corresponding segments of the indicator.}}] [{{  :examples:display:segment_display:segment_display_driver_logic.png?300|The build-up of the LED driver's shift-index with corresponding segments of the indicator.}}]
  
-LED number-indicators are easy to usethey can be controlled directly from the pins of the microcontroller, but there are also special drivers, which able to control number-indicators using fewer pins of the microcontroller. There are different colors of LED number indicators, which can be very bright and very large. For displaying the entire Latin alphabet exist indicators with extra segments. There are different drivers, but common drivers using a serial interface, which is similar to the SPI, where both clock signal and data signal are used. Different from SPI the chip-select is not used there, and is replaced with latch function. The above mentioned three lines are connected to the controller pins. +LED number-indicators are easy to usethey can be controlled directly from the pins of the microcontroller, but there are also special drivers, which are able to control number-indicators using fewer pins of the microcontroller. There are different colors of LED number indicators, which can be very bright and very large. For displaying the entire Latin alphabet, there exist indicators with extra segments. There are different drivers, but common drivers using a serial interface, which is similar to the SPI, where both the clock signal and the data signal are used. Different from SPIthe chip-select is not used there, and is replaced with latch function. The above-mentioned three lines are connected to the controller pins. 
  
   * Latch-signal   * Latch-signal
Line 31: Line 26:
  
 <code c> <code c>
-// Marking card +// Marking cardThe bits are marking the segments.
-// The bits are marking the segments. Lower ranking is A, higher ranking is DP+
 const unsigned char __attribute__ ((weak)) segment_char_map[11] =  const unsigned char __attribute__ ((weak)) segment_char_map[11] = 
 { {
Line 51: Line 45:
 void segment_display_init(void) void segment_display_init(void)
 { {
- // Set latch, data out and clock pins as output+ // Set latch, data outand clock pins as output
  pin_setup_output(segment_display_latch);  pin_setup_output(segment_display_latch);
  pin_setup_output(segment_display_data_out);  pin_setup_output(segment_display_data_out);
Line 57: Line 51:
 } }
    
-// Displaying number on the 7-segment indicator+//Displaying number on the 7-segment indicator
 void segment_display_write(unsigned char digit) void segment_display_write(unsigned char digit)
 { {
Line 75: Line 69:
  pin_clear(segment_display_latch);  pin_clear(segment_display_latch);
    
- // Sending he bits. Higher ranking goes first+ // Sending the bits. The higher ranking goes first
  for (i = 7; i >= 0; i--)  for (i = 7; i >= 0; i--)
  {  {
Line 81: Line 75:
  pin_set_to(segment_display_data_out, bit_is_set(map, i));  pin_set_to(segment_display_data_out, bit_is_set(map, i));
    
- // The clock-signal as high for a moment+ // The clock-signal is high for a moment
  pin_set(segment_display_clock);  pin_set(segment_display_clock);
  _delay_us(1);  _delay_us(1);
    
- // The clock-signal as low+ // The clock signal is low
  pin_clear(segment_display_clock);  pin_clear(segment_display_clock);
  _delay_us(1);  _delay_us(1);
Line 95: Line 89:
 </code> </code>
  
-For displaying numbers and the letter “E”, is created a "weak" constant array //segment_char_map//, where lighting of all 8 segments is marked with bit 1 and switch off is market with bit 0. The bits form lower to higher (from right to left in binary form) are marking segments A, B, C, D, E, F, G ja DP. The control interface of the driver is realized through software SPI, i.e. by using a software for controlling the data communication pins in the program.  All three pins are set as output with // segment_display_init// function. // segment_display_write// is for displaying the function, which finds the segment-card of the mark from the array and transmits bit by bit  all values of the segments to the driver. The frequency of the clock signal with the software delays is now approximately 500 kHz. When a user defines a variable segment_char_map its own code, it is possible to create other characters on the screen (eg, text, etc.)+For displaying numbers and the letter “E”, a "weak" constant array //segment_char_map//is created, where the lighting of all 8 segments is marked with bit 1 and switching off is marked with bit 0. The bits form lower to higher (from right to left in binary form) are marking segments A, B, C, D, E, F, G ja DP. The control interface of the driver is realized through software SPI, i.e. by using a software for controlling the data communication pins in the program.  All three pins are set as output with // segment_display_init// function. // segment_display_write// is for displaying the function, which finds the segment-card of the mark from the array and transmits bit by bit all values of the segments to the driver. The frequency of the clock signal with the software delays is now approximately 500 kHz. When a user defines a variable segment_char_map in their own code, it is possible to create other characters on the screen (eg, text, etc.)
  
-The following is a more concrete example of a program for using the number-indicator.  Previously described function of the library is described in the program. The program counts numbers from 0 to 9 with approximate interval of 1 second and then displays letter E, because two-digit numbers is not possible to show on the one digit indicator.+The following is a more concrete example of a program for using the number-indicator.  The previously described function of the library is described in the program. The program counts numbers from 0 to 9 with approximate interval of 1 second and then displays letter E, because two-digit numbers is not possible to show on the one digit indicator.
  
  
Line 128: Line 122:
 } }
 </code> </code>
 +
 +==== Task to be implemented ====
 +  - Present numbers in the hexadecimal system randomly on the 7-segment display. The frequency is 1 Hz.
 +  - Light in circular sequence six outside segments on the 7-segment indicator with a period of 500 ms.
 +
en/iot-open/practical/hardware/itt/avr/segment_display.1756195767.txt.gz · Last modified: 2025/08/26 08:09 by ingmar05
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0