LCD wont display

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Re: LCD wont display

Postby robosang » Mon Nov 05, 2012 6:19 pm

mohdismiaswaly WROTE:Hi,

I a newbie here..how to post thread here?

Cannot find any button to click... :roll:

TQ


It seem you seldom join forum discussion. You should see "New Topic" on the left corner, example under this category, "PIC Microcontroller". :mrgreen:
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: LCD wont display

Postby choohao » Fri Nov 09, 2012 12:34 pm

Sorry for the above coding... i means my LCD show a long square bar. may i have a workable coding? i not sure is the my coding or LCD problem~~
If LCD then, i will take back to cytron have a ask..
choohao
Freshie
 
Posts: 5
Joined: Sat Nov 03, 2012 7:18 pm

Re: LCD wont display

Postby robosang » Fri Nov 09, 2012 4:32 pm

the top line show square black box? Most likely the LCD is not initialized properly.

How you connect it and which program you use? Show us a photo of the hardware and share the code. BTW, have you load the program into your microcontroller?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: LCD wont display

Postby gadgetng » Fri Nov 09, 2012 6:08 pm

choohao WROTE:Sorry for the above coding... i means my LCD show a long square bar. may i have a workable coding? i not sure is the my coding or LCD problem~~
If LCD then, i will take back to cytron have a ask..


Some suggestion:
If you are using SK40C just try with the Cytron example coding. Those code is downloadable in the SK40C product page. You can try with the 16F877A LED blinking sample code. The code will display some text on the LCD. No modification on code needed.
If you are already using the sample code:
1. Make sure the PIC used is the same
2. Make sure there is a 20MHz Crystal on the SK40C.
3. Make sure your soldering is OK! :twisted:
4. Try adjust the preset on the SK40C for the LCD contrast until the text can be seen.

If still cannot, try capture some photos on the hardware here so that others can advise.
gadgetng
Discoverer
 
Posts: 97
Joined: Tue Jul 24, 2012 11:20 am

Re: LCD wont display

Postby Tianjin » Mon Dec 10, 2012 1:21 am

Hi guys, i bought p18f4520 and icd2 and am using 20mhz mplab v8.6. i reprogram temp control program(from this site) for p16f876A to my pic18f4520 and z compilation and simulation works well but there's no display on the LCD.
so would u tell me where z problem is?
CODE: SELECT_ALL_CODE
#include<p18f4520.h>
//===============define IO port=============================
#define      lcd         PORTC
#define      RS         RA2
#define      E         RA5
#define      [color=#FF0000]CHANNEL0   0b00000001[/color]   // AN0
#define      [color=#FF0000]CHANNEL1   0b00000101[/color]   // AN1
#define      buzzer      RD0
#define      ledA      RD1
#define      ledB      RD2

//==============FUNCTION PTOTOTYPE=========================
void e_pulse(void);
void delay(unsigned short i);
void send_char(unsigned char data);
void send_config(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void dis_num(unsigned long data);
void increment(unsigned long data);
void read_adc(void);
unsigned short read_temp(void);

//====================MAIN================================
unsigned short result;
unsigned short temp,tempA,tempB;

void main(void)
{
   ADRESH=0;               //clear A/D result
   ADRESL=0;               //clear A/D result

   //setting ADCON1 Register
   [b][color=#FF0000]ADCON1=0b00011101;[/color][/b]         // A/D result right justified,             
                        // configure RA2 and RA5 as digital I/O
   [color=#FF0000]ADCON2=0b10001010;[/color]

   TRISA=0b11011011;         //configure PORTA I/O direction
   TRISD=0b00000000;         //configure PORTD as output
   TRISC=0b00000000;         //configure PORTC as output

   PORTA=0;
   PORTB=0;
   
   while(1)               
   {
      send_config(0b00000001);      //clear display at lcd
      send_config(0b00000010);      //Lcd Return to home
      send_config(0b00000110);      //entry mode-cursor increase 1
      send_config(0b00001100);      //diplay on, cursor off and cursor blink off
      send_config(0b00111000);      //function set
      
      lcd_goto(0);               //cursor start from beginning
      
      //display character on LCD
      send_char(' ');
      send_char('T');
      send_char('E');
      send_char('M');
      send_char('P');
      send_char('.');
      send_char('A');
      send_char('=');   

      lcd_goto(20);               //cursor go to 2nd line of the LCD

      //display character on LCD
      send_char(' ');
      send_char('T');
      send_char('E');
      send_char('M');
      send_char('P');
      send_char('.');
      send_char('B');
      send_char('=');   

      while(1)                  //infinity loop
      {
      //sensor A
      ADCON0=CHANNEL0;            //CHANNEL1=0b00000101
      lcd_goto(8);
            
      read_adc();

      temp=read_temp();
      dis_num(temp/10);
      send_char('.');
      dis_num(temp%10);
      send_char(0b11011111);
      send_char('C');
      send_char(' ');
      send_char(' ');
      
      tempA=temp;
      
      //sensor B
      ADCON0=CHANNEL1;            //CHANNEL0=0b00000001         

      lcd_goto(28);
            
      read_adc();

      temp=read_temp();
      dis_num(temp/10);
      send_char('.');
      dis_num(temp%10);
      send_char(0b11011111);
      send_char('C');
      send_char(' ');
      send_char(' ');

      tempB=temp;
   
         if((tempA>=250)&&(tempB<400))      //   *****************************************
            {                        //   *   LED A and Fan A activated only for    *
               PORTDbits.RD0=1;//ledA=1;                  //   *   temperature A greater than 40'C      *
               PORTDbits.RD1=0;//ledB=0;                  //   *   and temperature B less than 35'C   *
               
               PORTDbits.RD2=0;//buzzer=0;
            }   

         else if((tempB>50)&&(tempA<=150))    //   *****************************************
            {                        //   *   LED B and Fan B activated only for    *
               PORTDbits.RD0=0;//ledA=0;                  //   *   temperature A less than 40'C and   *
               PORTDbits.RD1=1;//ledB=1;                  //   *   temperature B greater than 35'C      *
               
               PORTDbits.RD2=0;//buzzer=0;
            }   

               delay(2000);
   
      }
   
   }
      
}
Tianjin
Novice
 
Posts: 19
Joined: Mon Dec 10, 2012 1:01 am

Re: LCD wont display

Postby zhenning » Mon Dec 10, 2012 1:32 am

You need lcd power up/ startup sequence. Do you have that? These sequence are different for 4 bit and 8 bit mode. Do notice that.

Image
zhenning
Enthusiast
 
Posts: 351
Joined: Thu Dec 30, 2010 12:32 am

Re: LCD wont display

Postby Tianjin » Mon Dec 10, 2012 7:33 pm

hi,zhenning. I read about it but I don't have the experience of c ( power up sequence of lcd). I want to use
8 bit mode
data bits---- portC
RS -----RA2
RW-----GND
E-------RA5. would u tell me how I can do it with examples.
thank you.
Tianjin
Novice
 
Posts: 19
Joined: Mon Dec 10, 2012 1:01 am

Re: LCD wont display

Postby zhenning » Mon Dec 10, 2012 7:56 pm

zhenning
Enthusiast
 
Posts: 351
Joined: Thu Dec 30, 2010 12:32 am

Re: LCD wont display

Postby robosang » Mon Dec 10, 2012 11:37 pm

Don't do complex stuff first.... Is PIC running? Is LCD contrast adjusted? Is the black box on 1st row of LCD disappear?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: LCD wont display

Postby Tianjin » Mon Dec 10, 2012 11:50 pm

I tried it following the steps. when i compiled it,it says "could not find definition of symbol 'main' in file 'C'" and i added the main c,temp control.c and now the simulation even doesn't work. help me
#include<p18f4520.h>
#define lcd_data PORTC
#define lcd_DB7 RD7
#define lcd_RS RD2
#define lcd_RW RD1
#define lcd_E RD0
void lcd_busy(void);
void lcd_init()
{
lcd_data =0x38;
PORTDbits.RD2=0;
PORTDbits.RD1=0;//lcd_RW=0;
PORTDbits.RD0=1;//lcd_E=1;
PORTDbits.RD0=0;//lcd_E=0;
lcd_busy();
lcd_data=0x0F;
PORTDbits.RD2=0;//lcd_RS=0;
PORTDbits.RD1=0;//lcd_RW=0;
PORTDbits.RD0=1;//lcd_E=1;
PORTDbits.RD0=0;//lcd_E=0;
lcd_busy();
lcd_data=0x01;
PORTDbits.RD2=0;//lcd_RS=0;
PORTDbits.RD1=0;//lcd_RW=0;
PORTDbits.RD0=1;//lcd_E=1;
PORTDbits.RD0=0;//lcd_E=0;
lcd_busy();
PORTDbits.RD2=0;//lcd_RS=0;
PORTDbits.RD1=0;//lcd_RW=0;
PORTDbits.RD0=1;//lcd_E=1;
lcd_busy();
}
void lcd_busy()
{
TRISC=0xFF;
PORTDbits.RD0=1;//lcd_E=1;
PORTDbits.RD2=0;//lcd_RS=0;
PORTDbits.RD1=1;//lcd_RW=1;
while(PORTDbits.RD7)
{
PORTDbits.RD0=0;//lcd_E=0;
PORTDbits.RD0=1;//lcd_E=1;
}
TRISD=0x00;
}
void lcd_command(unsigned char var)
{
lcd_data=var;
PORTDbits.RD2=0;//lcd_RS=0;
PORTDbits.RD1=0;//lcd_RW=0;
PORTDbits.RD0=1;//lcd_E=1;
PORTDbits.RD0=0;//lcd_E=0;
lcd_busy();
}
//lcd_command(0x83);
void lcd_senddata(unsigned char var)
{
lcd_data=var;
PORTDbits.RD2=1;//lcd_RS=1;
PORTDbits.RD1=0;//lcd_RW=0;
PORTDbits.RD0=1;//lcd_E=1;
PORTDbits.RD0=1;//lcd_E=0;
lcd_busy();
}
void lcd_sendstring(const char *var)
{
while(*var)
lcd_senddata(*var++);
}
Tianjin
Novice
 
Posts: 19
Joined: Mon Dec 10, 2012 1:01 am

PreviousNext

Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 13 guests