Both sides previous revisionPrevious revisionNext revision | Previous revision |
en:examples:display:lcd_alphanumeric [2010/03/09 18:00] – Helen | en:examples:display:lcd_alphanumeric [2020/07/20 09:00] (current) – external edit 127.0.0.1 |
---|
====== Alphanumeric LCD ====== | ====== Alphanumeric LCD ====== |
| |
//Necessary knowledge: [HW] [[en:hardware:homelab:lcd]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [LIB] [[en:software:homelab:library:delay]], [PRT] [[en:examples:timer:periodic_interrupt]]// | //Necessary knowledge: [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [LIB] [[en:software:homelab:library:delay]], [PRT] [[en:examples:timer:periodic_interrupt]]// |
| |
===== Teooria ===== | ===== Theory ===== |
| |
Alphanumeric LCD is liquid crystal display, with the purpose of displaying letters and numbers. In basic LCD liquid crystal placed between transparent electrodes is used, which changes the polarization of the passing light in electrical field. The electrodes are covered by polarization filters, which assure that only one way polarized light can pass the screen. If the liquid crystal changes its polarity due to the electrical field, the light can not pass the screen or part (segment) of it and it looks dark. | Alphanumeric LCD is liquid crystal display, with the purpose of displaying letters and numbers. In basic LCD is used liquid crystal which is placed between transparent electrodes, and which changes the polarization of the passing light in electrical field. The electrodes are covered by polarization filters, which assure that only one way polarized light can pass the screen. If the liquid crystal changes its polarity due to an electrical field, the light can not pass the screen or part (segment) of it and it looks dark. |
| |
Main characteristic of alphanumerical LCD is the placing of its segments. The screen is divided into many indicators. Each indicator has either enough segments for displaying letters and numbers or it is formed from matrix of little square segments (pixels). For example, a matrix of 5x7 pixels is enough to display all numbers, and letters of Latin alphabet. There are usually 1 – 4 rows of indicators and 8 – 32 columns. Each indicator has a small difference like the letters in text have | Main characteristic of alphanumerical LCD is the placing of its segments. The screen is divided into many indicators. Each indicator has either enough segments for displaying letters and numbers or it is formed from matrix of little square segments (pixels). For example, a matrix of 5x7 pixels is enough to display all numbers, and letters of Latin alphabet. There are usually 1 – 4 rows of indicators and 8 – 32 columns. Each indicator has a small difference similar to the differences of the letters in text. |
| |
| |
[{{ :examples:display:lcd_alphanumeric:lcd_alphanumeric_abc.png?200|The text formed of alphanumerical LCD pixels' matixes.}}] | [{{ :examples:display:lcd_alphanumeric:lcd_alphanumeric_abc.png?200|The text formed of alphanumerical LCD pixels' matrixes.}}] |
| |
Alphanumerical LCD has besides screen, also controller which controls the segments of the screen according to the commands from the communication interface. There is a preprogrammed card of letters in the controller, where each letter, number or symbol has its own index. Displaying the text on the screen is basically done by sending the indexes to the controller. In reality there must be more control orders sent to the controller before anything can be displayed. For using LCD-s one has to introduce their data-sheets, because there are very different LCD-s. | Besides the screen Alphanumerical LCD has also controller which controls the segments of the screen according to the commands from the communication interface. A controller has a preprogrammed card of letters, where each letter, number or symbol has its own index. Displaying the text on the screen is basically done by sending the indexes to the controller. In reality there must be more control orders sent to the controller before anything can be displayed. It is important to get familiarize with each LCD data-sheet, because there are many different types of LCDs and they all are controlled differently. |
| |
Alphanumerical LCD-s are usually with passive matrix, where renewal of the electrical field of the segments is tone in turns. That is why the screens with passive matrix are slower and have not so good contrast as the active matrix screens where the charge of each segment is controlled by separate transistor. There are LCD-s with reflective back and with backlight sometimes even with several different backlights. But segment colors have alphanumerical LCD-s usually still one – black usually, but there is also screens with white and colorful writings. | Alphanumerical LCDs are usually with passive matrix, where renewal of the electrical field of the segments is tone in turns. That is why the screens with passive matrix are slower and have less contrast compared with the active matrix screens where the charge of each segment is controlled by separate transistor. Some LCDs are with reflective back and others with backlight sometimes even with several different backlights. But segment colour for alphanumerical LCDs is usually still one – which is black, however there are also screens with white and colorful writings. |
| |
| |
===== Practice ===== | ===== Practice ===== |
| |
To the digital module of the Home Lab connects a 2x16 symbol alphanumerical LCD WC 1602A. For controlling the screen, there is a 4-bit data-bus and 3 control pins, but its communication protocol is too capacious, to be explained here. For simplicity, there are corresponding functions in the library of the Home Lab for using the display. | HomeLabs Digital i/o module connects a 2x16 symbol alphanumerical LCD WC 1602A. For controlling the screen, there is a 4-bit data-bus and 3 control pins, but its communication protocol is too capacious, to be explained here. For simplicity, the library of the HomeLab has corresponding functions for using the display. |
| |
First thing that needs to be done to use the display is to adjust it. For that is the // lcd_alpha_init// function, with which can set a blinking cursor to the screen. There is all the time an active position of the cursor on the screen, where next letter is entered, regardless whether it can be seen or not. So before entering the text, the cursor must be taken to the desired place. For changing the position of the cursor is the lcd_alpha_goto_xy and for displaying it lcd_alpha_write_string functions. All the functions of the alphanumerical LCD are explained in its library. | Before using the display it is vital to adjust its settings. For this purpose is the // lcd_alpha_init// function, which sets a blinking cursor on the screen. On screen is always only one active position for the cursor where next letter is entered, regardless whether it can be seen or not. So before entering the text, the cursor must be taken to the desired place. For changing the position of the cursor is a function lcd_alpha_goto_xy and for displaying it lcd_alpha_write_string. All the functions of the alphanumerical LCD are explained in its library. |
| |
The following program code demonstrates the usage of alphanumerical LCD as a clock. The Time begins at 00:00:00 and grows approximately in every second. Since the counting of the time is done with the delay function, it is not very precise. The inaccuracy is explained in the exercise of the periodic interruption. The program counts the seconds and converts them into the minutes and seconds. To use clock time there is a standard function in the C-language: //sprintf//. | The following program code demonstrates the usage of alphanumerical LCD as a clock. The Time begins at 00:00:00 and grows approximately in every second. Since the counting of the time is done with the delay function, it is not very precise. The inaccuracy is explained in the exercise of the periodic interruption. The program counts the seconds and converts them into minutes and seconds. For using clock time is a standard function in the C-language: //sprintf//. |
| |
| |
<code c> | <code c> |
// | // |
// The example of using the alphanumerical LCD of the Home Lab. | // The example of using the alphanumerical LCD of the HomeLab. |
// The clock time starting at the beginning of the program is displayed on the LCD. | // The clock time starting at the beginning of the program is displayed on the LCD. |
// | // |
seconds % 60); | seconds % 60); |
| |
// Displaying the clock text in the beginning of the second row of the LCD. | // Displaying the clock text in the LCD. |
lcd_alpha_goto_xy(0, 1); | lcd_alpha_goto_xy(0, 1); |
lcd_alpha_write_string(text); | lcd_alpha_write_string(text); |