Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

USART module for display 16x1

Status
Not open for further replies.

Vermes

Advanced Member level 4
Joined
Aug 2, 2011
Messages
1,163
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,316
Activity points
22,318
This design is an USART module which can operate with display 16x1. This device was implemented on PIC16F84A. The main assumption of this project was to crate a module which allows the communication with such a display via USART. In order to send data to the display, you only have to give instruction of start of the transmission „[„. Instruction „]” informs the mictocontroller that there is no more data for display. Additional instruction „#” allows for deleting the screen. Because the display 16x1 is divided into two pieces (8 characters each), the microcontroller pays attention to correct transition of an inscription to the other half of the display. When the entire display is full and it receives 17 character, the screen is deleted and the 17 character appeats as 1 character on the display.

Communication of the microcontroller with the PC:
Microcontroller PIC16F84A communicated with the computer using port COM. You need to use MAX232 to adapt the voltage of TTL (5V) of the microcontroller to the standard RS232 (12V) which is on the port COM.



Communication of the microcontroller with another microcontroller:
Microcontroller PIC16F84A communicates with another microcontroller using USART.



Electric schematic:



Data transmission protocol:
Tab.1 Control instructions
Code ASCII Instruction
[ start of data receiving
] stop of data receiving
# deleting the display

Algorithm of the program:



Code of the program:

Code:
/**
* Wyswietlanie na LCD danych pobranych
* przez USART.
*/
*
#include <16F84.h>
#fuses XT,NOPROTECT,NOWDT
*
#use delay(clock=4000000)
*
//RX RA2 PIN 1
//TX RA3 PIN 2
#use rs232(baud=300,parity=N,xmit=PIN_A3,rcv=PIN_A2,bits=9)
*
#include "wlcd.c"
*
main() {
   char c;
   char i=0;
*
   /*
   //Informacja o sterowaniu wyslana na rs232
   printf("\fLCD OK\n");
   printf("[ - begin\n");
   printf("] - end\n");
   printf("# - clear\n");
   */
*
   //inicjacja lcd
   lcd_init();
*
   //napis testowy na lcd
   lcd_putc("\fLCD 2.2");
*
   delay_ms(800);
   lcd_putc("\f");
*
   //glowna petla programu
   for(;;){
*
       //pobranie znaku z usart
       c = getc();
*
       //komenda - czyszczenie wyswietlacza
       if (c=='#'){
            i = 0;
            lcd_putc("\f");
       }
*
      //komenda - rozpoczecie wyswietlania
      if (c == '['){
        for(;;){
           //pobranie znaku do wyswietlenia
           c = getc();
*
           //jesli nie jest to znak konca transmisji dla wyswietlania, to znak na ekran
           if (c!=']'){
*
             //jesli koniec linii (polowa ekranu) to przejscie na 2 polowe ekranu
             if (i==8){  lcd_putc("\n"); }
             //jesli koniec ekranu to zaczynamy od nowa
             if (i==16){  lcd_putc("\f"); i=0; }
*
             //dodanie znaku do wyswietlacza
             lcd_putc(c);
             i++;
           }
           //byl znak konca transmisji na wyswietlacz
           if (c==']') {
             break;
           }
        }
     }
  }
}
*

Link to original thread - Moduł USART dla wyświetlacza 16x1 zrealizowany na PIC16F84A
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top