EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Interfacing 16×2 LCD Character Problem

Interfacing 16×2 LCD Character Problem

|

Microcontroller › 8051 › Interfacing 16×2 LCD Character Problem

  • This topic has 3 replies, 3 voices, and was last updated 13 years, 8 months ago by nikhiljain.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • October 26, 2011 at 1:52 pm #1340
    Adeel
    Participant

    Hello guys,

     

    I am using AT89C51 IC with 16×2 LCD after so much research i got how to display text on LCD but now i stuck with a character problem.

     

    i was making this project: http://www.engineersgarage.com/microcontroller/8051projects/interfacing-adc0831-circuit a

     

    nd was done 90% only the problem is that the Characters on my LCD are not correct:

     

    lets say i m sending “ADC OUTPUT”

     

    in my LCD its showing me “A?C OQPPQP2”

     

    even if i send only single character which is ‘d’ its show me ” ?` ”

     

    i dont know how to fix this issue can anyone help me in that ? any c example fixing this issue ??

    October 26, 2011 at 5:37 pm #6751
    Ashish Angural
    Participant

    hey try this

     

    #include<reg51.h>

    #include<intrins.h>

    #define data P1
     

    sbitS1=P1^0;

    sbitS2=P1^2;

    sbit RS=P2^0;
    sbit RW=P2^1;
    sbit E=P2^2;

    sbit A1=P0^0;
    sbit B1=P0^1;
    sbit C1=P0^2;
    sbit D1=P0^3;

    void ms_delay(unsigned int a)
    {
     unsigned int i,j;
     for(i=0;i<a;i++)
     {
      for(j=0;j<70;j++)
      {
       _nop_();
      }
     }
    }

    void sec_delay(unsigned int a)
    {
     unsigned int i,j;
     for(i=0;i<a;i++)
     {
      for(j=0;j<1000;j++)
      {
       ms_delay(1);
      }
     }
    }

    void lcd_cmd()
    {
     data=ACC;
     RS=0;
     RW=0;
     E=1;
     ms_delay(10);
     E=0;
    }

    void lcd_data()
    {
     data=ACC;
     RS=1;
     RW=0;
     E=1;
     ms_delay(10);
     E=0;
    }

    void lcd_initialize()
    {
     ACC=0x38;
     lcd_cmd();
     ACC=0x38;
     lcd_cmd();
     ACC=0x38;
     lcd_cmd();
     ACC=0x06;
     lcd_cmd();
     ACC=0x0C;
     lcd_cmd();
    }

    void lcd_puts(unsigned char *a)
    {
     while(*a!=’’)
     {
      ACC=*a;
      lcd_data();
      a++;
     }
    }

    void clkwise()
    {
     unsigned char i;
     for(i=0;i<=5;i++)
     {
      A1=0;
      B1=C1=D1=1;
      ms_delay(250);

      B1=0;
      A1=C1=D1=1;
      ms_delay(250);

      C1=0;
      A1=B1=D1=1;
      ms_delay(250);

      D1=0;
      A1=B1=C1=1;
      ms_delay(250);
      }
    }

    void anticlkwise()
    {
     unsigned char i;
     for(i=0;i<=5;i++)
     {
      D1=0;
      A1=B1=C1=1;
      ms_delay(250);

      C1=0;
      A1=B1=D1=1;
      ms_delay(250);

      B1=0;
      A1=C1=D1=1;
      ms_delay(250);

      A1=0;
      B1=C1=D1=1;
      ms_delay(250);
     }
    }

    void main()
    {
     lcd_initialize();
     while(1);
      {
       if(S1==0)
       {
           ACC=0x80;
        lcd_cmd();
        lcd_puts(“MOTOR CLOCKWISE”);
        clkwise();
       }
       else if(S2==0)
       {
           ACC=0x01;
        lcd_cmd();
        ACC=0x80;
        lcd_cmd();
        lcd_puts(“MOTOR ANTICLOCKWISE”);
        anticlkwise();
       }
      }
     }

     

    this code is for stepper motor and lcd intefacing take it as an example

     

    October 29, 2011 at 1:37 am #6754
    Adeel
    Participant

    Hello,

     

    Thank you so much for your reply, but i have solved my problem

     

    problem was that i was using the Instruction Set for HD44780 and i have 162A Character LCD Module.

     

    and becuz of having different Instruction set i was facing this problem, but its solved thank you so much.

     

     

    also if you can help me in ADC 0831 i am trying to measure 220v what i need to do is :

     

    Get the volts and checks if its 170 , 200 , 220 so i can do other steps on behave of this.

     

    how can i get this ??? any idea

     

    thank you

    November 4, 2011 at 10:05 am #6805
    nikhiljain
    Participant

    you need to first step it down using a transformer than use a rectifier ciruit to convert into dc than feed to the adc. Choose components with proper rating.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Pickit 5 July 16, 2025
  • Pic18f25q10 osccon1 settings swordfish basic July 16, 2025
  • turbo jet fan - feedback appreciated. July 16, 2025
  • More fun with ws2812 this time XC8 and CLC July 16, 2025
  • I Wanna build a robot July 16, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise