Ремонт частотника

Auteur  
# 07/02/2017 à 08:23 jynkvbat (site web)
tion displays text at the current cursor position. For example, to display text Computer at the current cursor position the function should be called as: Lcd_Out_Cp ("Computer"); LcdChr The LcdChr function displays a character at the specified row and column position of the cursor. The function should be called with the parameters in the following order: row, column, character For example, to display character K at row 2 and column 4 of the LCD we should call the function as: LCD_Chr(2, 4, 'K' ); Lcd_Chr_Cp The Lcd_Chr_Cp function displays a character at the current cursor position. For example, to display character M at the current cursor position the function should be called as: Lcd_Chr_Cp ( 'M' ); LcdCmd The LcdCmd function is used to send a command to the LCD. With the commands we can move the cursor to any required row, clear the LCD, blink the cursor, www.newnespress.com Functions and Libraries in mikroC 197 Table 4.4: LCD commands LCD command Description LCD_CLEAR Clear display LCD_RETURN_HOME Return cursor to home position LCD_FIRST_ROW Move cursor to first row LCD_SECOND_ROW Move cursor to second row LCD_THIRD_ROW Move cursor to third row LCD_FOURTH_ROW Move cursor to fourth row LCD_BLINK_CURSOR_ON Blink cursor LCD_TURN_ON Turn display on LCD_TURN_OFF Turn display off LCD_MOVE_CURSOR_LEFT Move cursor left LCD_MOVE_CURSOR_RIGHT Move cursor right LCD_SHIFT_LEFT Shift display left LCD_SHIFT_RIGHT Shift display right shift display, etc. A list of the most commonly used LCD commands is given in Table 4.4. For example, to clear the LCD we should call the function as: Lcd_Cmd(Lcd_Clear); An example illustrates initialization and use of the LCD. Example 4.12 A text-based LCD is connected to a PIC18F452 microcontroller in the default mode as shown in Figure 4.19. Write a program to send the text My Computer to row 1, column 4 of the LCD. Solution 4.12 The required program listing is given in Figure 4.20 (program LCD.C). At the beginning of the program PORTB is configured as output with the TRISB = 0 www.newnespress.com Figure 4.19: Connecting an LCD to a PIC microcontroller WRITING TEXT TO AN LCD A text based LCD is connected to a PIC microcontroller in the default mode. This program displays the text My Computer on the LCD. Programmer: Dogan Ibrahim File: LCD.C Date: May, 2007 void main() TRISB = 0; Configure PORTB as output Lcd_Init( PORTB); Lcd_Cmd(LCD_CLEAR); Lcd_Out(1, 4, My Computer); Initialize the LCD Clear the LCD Display text on LCD Figure 4.20: LCD program listing www.newnespress.com Functions and Libraries in mikroC 199 statement. The LCD is then initialized, the display is cleared, and the text message My Computer is displayed on the LCD. 4.3.3 Software UART Library Universal asynchronous receiver transmitter (UART) software library is used for RS232-based serial communication between two electronic devices. In serial communication, only two cables (plus a ground cable) are required to transfer data in either direction. Data is sent in serial format over the cable bit by bit. Normally, the receiving device is in idle mode with its transmit (TX) pin at logic 1, also known as MARK. Data transmission starts when this pin goes to logic 0, also known as SPACE. The first bit sent is the start bit at logic 0. Following this bit, 7 or 8 data bits are sent, followed by an optional parity bit. The last bit sent is the stop bit at logic 1. Serial data is usually sent as a 10-bit frame consisting of a start bit, 8 data bits, and a stop bit, and no parity bits. Figure 4.21 shows how character A can be sent using serial communication. Character A has the ASCII bit pattern 01000001. As shown in the figure, first the start bit is sent, this is followed by 8 data bits 01000001, and finally the stop bit is sent. IDLE 1 1 0 0 0 0 0 0 START STOP 0 Figure 4.21: Sending character A in serial communication The bit timing is very important in serial communication, and the transmitting (TX) and receiving (RX) devices must have the same bit timings. The bit timing is measured by the baud rate, which specifies the number of bits transmitted or received each second. Typical baud rates are 4800, 9600, 19200, 38400, and so on. For example, when operating at 9600 baud rate with a frame size of 10 bits, 960 characters are transmitted or received each second. The timing between bits is then about 104ms. In RS232-based serial communication the two devices are connected to each other (see Figure 4.22) using either a 25-way connector or a 9-way connector. Normally only the TX, RX, and GND pins are required for communication. The required pins for both types of connectors are given in Table 4.5. The voltage levels specified by the RS232 protocol are 12V. A logic HIGH signal is at 12V and a logic LOW signal is at +12V. PIC microcontrollers, on the other hand, www.newnespress.com 200 Chapter 4 Figure 4.22: 25-way and 9-way RS232 connectors Table 4.5: Pins required for serial communication Pin 9-way connector 25-way . For more information visit site www.prom-electric.ru
Répondre à ce message

Vous utilisez un logiciel de type AdBlock, qui bloque le service de captchas publicitaires utilisé sur ce site. Pour pouvoir envoyer votre message, désactivez Adblock.