LCD not displaying anything in 8051 based project.

Thread Starter

kks31

Joined Feb 18, 2018
17
I successfully manged to run my project on Proteus, but now when trying to run it actually in real world, the LCD remains blank and nothing appears. I am posting the code and images of my connection, please check it and help me out. Also when connecting the GND of motor driver ic to the GND of the 8051 programming board, the programming board doesn't even start. For better understanding (since in the image its difficult to understand the connections) here is the pins which i have connected to the 8051 programming board (i followed the proteus simulation circuit diagram which i am posting)
LCD pins :
VSS - 5V
VDD, V0, RW - GND
RS - P3.7
E - P3.5
D0-D7 - P1.0-P1.7
A - 5V
K - GND

RFID MODULE :
GN - GND
TX - 3.0

L293D MOTOR DRIVER IC :
A1 - P2.4
A2 - P2.5
EA - 5V
VCC - 12V
GND - GND
C:
#include<reg51.h>
#include<string.h>
#include<stdio.h>
#define lcdport P1


sbit rs=P3^7;
sbit en=P3^5;
sbit rw=P3^6;
sbit m1=P2^4;
sbit m2=P2^5;

char i,rx_data[50];

char rfid[13],ch=0;

char pass[4];

void forwardmotor(void) ;
void stopmotor(void);

void delay(int itime)
{
    int i,j;
    for(i=0;i<itime;i++)
    for(j=0;j<1275;j++);
}

void daten()
{
    rs=1;
      rw=0;
    en=1;
    delay(5);
    en=0;
}

void lcddata(unsigned char ch)
{
    lcdport=ch & 0xf0;
    daten();
    lcdport=(ch<<4) & 0xf0;
    daten();
}

void cmden(void)
{
    rs=0;
    en=1;
    delay(5);
    en=0;
}

void lcdcmd(unsigned char ch)
{
    lcdport=ch & 0xf0;
    cmden();
    lcdport=(ch<<4) & 0xf0;
    cmden();
}

void lcdstring(char *str)
{
    while(*str)
    {
        lcddata(*str);
        str++;
    }
}

void lcd_init(void)
{
    lcdcmd(0x02);
    lcdcmd(0x28);
    lcdcmd(0x0e);
    lcdcmd(0x01);
}

void uart_init()
{
TMOD=0x20;
SCON=0x50;
TH1=0xfd;
TR1=1;
}
char rxdata()
{
  while(!RI);
    ch=SBUF;  
    RI=0;
    return ch;
}

void forwardmotor()
{
  m1=1;
    m2=0;  
    delay(500);
  stopmotor();
    delay(500);
  m1=0;
    m2=1;  
    delay(500); 
    stopmotor();
}


void stopmotor()
{
  m1=0;
    m2=0;
}

void main()
{
    uart_init();
    lcd_init();
    lcdstring("  RFID Based    ");
    lcdcmd(0xc0);
    lcdstring("Security system ");
    delay(400);
    while(1)
    {
        lcdcmd(1);
        lcdstring("Place Your Card:");
        lcdcmd(0xc0);
        i=0;
        for(i=0;i<12;i++)
        rfid[i]=rxdata();
        rfid[i]='\0';
        lcdcmd(1);
        lcdstring("Your ID No. is:");
        lcdcmd(0xc0);
        for(i=0;i<12;i++)
        lcddata(rfid[i]);
        delay(100);
        if(strncmp(rfid,"160066A5EC39",12)==0)
        {
            lcdcmd(1);
            lcdstring("Access Granted ");
            lcdcmd(0xc0);
            lcdstring("Person1");
            forwardmotor();
          }
      
        else if(strncmp(rfid,"160066BD7AB7",12)==0)
            {
            lcdcmd(1);
            lcdstring("Access Granted ");
            lcdcmd(0xc0);
            lcdstring("Person2");
            m1=1;
            m2=0;
            delay(300);
            m1=0;
            m2=0;
            delay(200);
            m1=0;
            m2=1;
            delay(300);
            m1=0;
            m2=0;
            }
          
                else if(strncmp(rfid,"160066203060",12)==0)
            {
            lcdcmd(1);
            lcdstring("Access Granted ");
            lcdcmd(0xc0);
            lcdstring("Person3");
            m1=1;
            m2=0;
            delay(300);
            m1=0;
            m2=0;
            delay(200);
            m1=0;
            m2=1;
            delay(300);
            m1=0;
            m2=0;  
            }

        else
        {
           lcdcmd(1);
           lcdstring("Access Denied");
           delay(300);
        }
  }
}
Mod edit: added C qualifier to code tags.
Screenshot (11).png IMG_20180301_184955.jpg IMG_20180301_185131.jpg IMG_20180301_185058.jpg
 
Last edited by a moderator:

Ian Rogers

Joined Dec 12, 2012
689
Unfortunately Proteus doesn't model the power on the LCD... You do indeed have them backwards.. Vss is ground and Vdd is positive.

Your LCD is probably defunked now... On another note.... You seem to be connecting all 8 bits but you are running 4 bit data, whilst this is fine I can't help but wonder why!!!
 

Thread Starter

kks31

Joined Feb 18, 2018
17
Unfortunately Proteus doesn't model the power on the LCD... You do indeed have them backwards.. Vss is ground and Vdd is positive.

Your LCD is probably defunked now... On another note.... You seem to be connecting all 8 bits but you are running 4 bit data, whilst this is fine I can't help but wonder why!!!
Thank you, it works. I initially connected just as you mentioned but on seeing the circuit diagram i changed my connections. Can you tell me the Motor Driver connection problem. As i mentioned, on giving the Gnd connection to the microcontroller the programming board doesn't start. I connected vcc and EA of motor driver ic to 12v and 5v respectively. Is there anything wrong with my connection?
 

Thread Starter

kks31

Joined Feb 18, 2018
17
Actually it doesn't work, i tried it yesterday, its just the contrast that shows up and i thought that it was working. Still nothing is displayed on the lcd.
 

Ian Rogers

Joined Dec 12, 2012
689
If the power to the LCD was backwards even for a second, it will be blown.. Have you another display to try?

Regarding the motor... I cannot see if the 5 v is enough to enable when the Vcc is 12 volts..
 

AlbertHall

Joined Jun 4, 2014
9,043
Actually it doesn't work, i tried it yesterday, its just the contrast that shows up and i thought that it was working. Still nothing is displayed on the lcd.
Did it actually have the power connected backwards? If it did it is unlikely to have survived.
 

JohnInTX

Joined Jun 26, 2012
3,949
Besides any hardware fixes, you need some delays in LCDinit between the commands. Proteus does not model the LCD very well in that regard.

C:
void lcd_init(void)
{
   delay_ms(50); // power up delay
    lcdcmd(0x02);
    delay_ms(5) 
    lcdcmd(0x28);
    delay_ms(1);
    lcdcmd(0x0e);
    delay_ms(1);
    lcdcmd(0x01);
}
You might need different delays depending on your LCD and whether you are checking BF first.
 

Attachments

Thread Starter

kks31

Joined Feb 18, 2018
17
Besides any hardware fixes, you need some delays in LCDinit between the commands. Proteus does not model the LCD very well in that regard.

C:
void lcd_init(void)
{
   delay_ms(50); // power up delay
    lcdcmd(0x02);
    delay_ms(5)
    lcdcmd(0x28);
    delay_ms(1);
    lcdcmd(0x0e);
    delay_ms(1);
    lcdcmd(0x01);
}
You might need different delays depending on your LCD and whether you are checking BF first.
That did it. It's working now. Thanks a lot! Although i still can't figure the problem with the Motor driver ic.
 

JohnInTX

Joined Jun 26, 2012
3,949
@Parth786 A couple of things in this thread that you might find useful.

The 8051 development board is inexpensive and local in India:
http://silicontechnolabs.in/development-boards-silicon-techchnolabs/8051-development-board-silicon-technolabs

Also note how moving from Proteus to actual hardware caused problems with ‘working’ code. The sim was happy with no delays in the LCD init but the LCD was not. This is why you need to get some real hardware. Sims are great for many things but they do have their limitations.

@kks31 Sorry for the hijack but I wanted to share some things in context. Thanks.
 
Last edited:

be80be

Joined Jul 5, 2008
1,990
If the power to the LCD was backwards even for a second, it will be blown.. Have you another display to try?

Regarding the motor... I cannot see if the 5 v is enough to enable when the Vcc is 12 volts..
If the LCD works your lucky I got about 3 I hooked the wrong side of the rail I got a new breadboard and the power rails
are backward from my old one I hooked it up with my glasses on. And then did something else came back and hooked the power
up out of habit I hooked it up like my old board and to lazy to put my glasses on. I popped 3 in a roll.
 

Thread Starter

kks31

Joined Feb 18, 2018
17
N
@Parth786 A couple of things in this thread that you might find useful.

The 8051 development board is inexpensive and local in India:
http://silicontechnolabs.in/development-boards-silicon-techchnolabs/8051-development-board-silicon-technolabs

Also note how moving from Proteus to actual hardware caused problems with ‘working’ code. The sim was happy with no delays in the LCD init but the LCD was not. This is why you need to get some real hardware. Sims are great for many things but they do have their limitations.

@kks31 Sorry for the hijack but I wanted to share some things in context. Thanks.
No problem. Although after purchasing, i realised that i should have been better off with an Arduino Uno.
 

Thread Starter

kks31

Joined Feb 18, 2018
17
If the LCD works your lucky I got about 3 I hooked the wrong side of the rail I got a new breadboard and the power rails
are backward from my old one I hooked it up with my glasses on. And then did something else came back and hooked the power
up out of habit I hooked it up like my old board and to lazy to put my glasses on. I popped 3 in a roll.
I guess i am lucky that nothing happened. It's a group project and the other members would have eaten my head off if something like that happened.
 

ErnieM

Joined Apr 24, 2011
8,011
I would like to add on JohnInTx's comment that a simulation is not useless. It is a very good place to test out the basic code itself. Yes, simulation will not find many pesky hardware issues, but it is still very useful.

My general statement is "if it doesn't sim you can't win."
 
Top