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 / houch pouch value of adc0808

houch pouch value of adc0808

|

Microcontroller › 8051 › houch pouch value of adc0808

  • This topic has 1 reply, 2 voices, and was last updated 11 years, 8 months ago by Ashutosh Bhatt.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • August 20, 2014 at 7:28 pm #3164
    swyam prakash singh
    Participant

    sir please resolve my error where my logic is getting wrong

    i m interfacing adc 0808  in intereupt mode with at89c51 with lcd 16*2 in 4 bit method

    but the error i m getting is houch pouch value between 000 to 255;

    these 2 positon are correct and other are houch pouch

    i have simulated on proteus now to check only and the result are on proteus;

    mine code is written in  c

    code is

    #include<reg51.h>
    #define ADC P1
    #define LCD P2
    unsigned int adc_val[7];
    sbit a=P3^0;
    sbit b=P3^1;
    sbit c=P3^2;
    sbit ale=P3^3;
    sbit  sc=P3^4;
    sbit eoc=P3^5;
    sbit oe=P3^6;
    sbit clk=P3^7;
    sbit rs=P2^0;
    sbit rw=P2^1;
    sbit en=P2^2;
    sbit sw=P2^3;
    sbit flag=P2^7;
    void timerdelay()  interrupt 3
    {
     clk=~clk;
    }
    void delay(int x)
    {
     unsigned int i,j;
     for(i=0;i<127;i++)
     for(j=0;j<x;j++);
    }

    void cmd(unsigned int x)
    {
     unsigned int temp1 ,temp2;

     temp1=x;
     temp1=temp1&0xf0;
     LCD=temp1;
     rs=0;rw=0;en=1;en=0;
    delay(1);
    temp2=x;
    temp2=temp2<<4;
    temp2=temp2&0xf0;
     LCD=temp2;
     rs=0;rw=0;en=1;en=0;
    }

     
    void dat(unsigned int x)
    {
     unsigned int temp1 ,temp2;
     
     temp1=x;
     temp1=temp1&0xf0;
     LCD=temp1;
     rs=1;rw=0;en=1;en=0;
     delay(1);
    temp2=x;
    temp2=temp2<<4;
    temp2=temp2&0xf0;
     LCD=temp2;
     rs=1;rw=0;en=1;en=0;
    }
    void init()
    {
     cmd(0x28);
     cmd(0x01);
     cmd(0x06);
     cmd(0x0e);
    }

    void lcdstring(unsigned char *string)
    {while(*string!=’’)
     dat(*string++);
    }

     
    void bin2dec(unsigned int x)
    {
     
     dat(((x/100)%10)|0x30);
      dat(((x/10)%10)|0x30);
      dat(((x/1)%10)|0x30);
    }
    void adc(unsigned int x)
    {

     
     
    if(x==0)
    {
     

     {
     cmd(0x80);
      lcdstring(“SN1”);
     a=0;b=0;c=0;
        ale=1;
        sc=1;
        sc=0;
        ale=0;
        while(eoc);
        oe=1;
      adc_val[0]=ADC;oe=0;
     cmd(0xc0);
     bin2dec(adc_val[0]); 
    }
    }
     if(x==1)
     {
     
      
      {
      cmd(0x80);
     lcdstring(“SN2”);
      
      a=1;b=0;c=0;
        ale=1;
        sc=1;
        sc=0;
        ale=0;
        while(eoc);
        oe=1;
      adc_val[1]=ADC;
      oe=0;
      cmd(0xc0);
    bin2dec(adc_val[1]); 
     }
    }
     if(x==2)
     {

      {
      cmd(0x80);
      lcdstring(“SN3”);
     a=0;b=1;c=0;
        ale=1;
        sc=1;
        sc=0;
        ale=0;
        while(eoc);
        oe=1;
      adc_val[2]=ADC;oe=0;cmd(0xc0);
     bin2dec(adc_val[2]); 
      }
     }

     if(x==3)
     {

      {
      cmd(0x80);
      lcdstring(“SN4”);
      a=1;b=1;c=0;
        ale=1;
        sc=1;
        sc=0;
        ale=0;
        while(eoc);
        oe=1;
     adc_val[3]=ADC;oe=0;cmd(0xc0);
     bin2dec(adc_val[3]); 
    }
     
    }
    if(x==4)
    {
     
     
     {
     
      cmd(0x80);
      lcdstring(“SN5”);
      a=0;b=0;c=1;
        ale=1;
        sc=1;
        sc=0;
        ale=0;
        while(eoc);
        oe=1;
      adc_val[4]=ADC;oe=0;cmd(0xc0);
     bin2dec(adc_val[4]); 
    }
     
    if(x==5)
    {
     
     {
     
      lcdstring(“SN6”);
     a=1;b=0;c=1;
        sc=1;
        sc=0;
        ale=0;
        while(eoc);
        oe=1;
      adc_val[5]=ADC;oe=0;cmd(0xc0);
     bin2dec(adc_val[5]); 
    }
    }
      
    if(x==6)
    {
     

     {

      cmd(0x80);
      lcdstring(“SN7”);
        a=0;b=1;c=1;
        sc=1;
        sc=0;
        ale=0;
        while(eoc);
        oe=1;
      adc_val[6]=ADC;oe=0;cmd(0xc0);
     bin2dec(adc_val[6]); 
    }
    }

    if(x==7)
    {

     {

      cmd(0x80);
     lcdstring(“SN8”);
     
        a=1;b=1;c=1;
        sc=1;
        sc=0;
        ale=0;
        while(eoc);
        oe=1;
      adc_val[7]=ADC; oe=0;cmd(0xc0);
     bin2dec(adc_val[7]); 

     }
    } 
      
     
    }
     
    }

    void main()
    {
     
     unsigned int count; int r;
     init();
     count=0;ADC=0xff;
     ale=0;sc=0;oe=0;eoc=1;sw=1;
     TMOD=0x20;//timer 1 is used in 2 mode;
     TH1=0xfd;
     TR1=1;
     IE=0x83;
     {
      while(1)
      {
       
       
       if(sw == 0)
       {
        count++;
        r=count%8;
       }
       adc(r);
      }
     }
     
    }   
      
      

    August 22, 2014 at 10:02 am #12057
    Ashutosh Bhatt
    Participant

    i didnt understand your problem?

    there seems to be some problems in your dat and cmd functions. check in proteus by connecting LEDs on LCD pins that whether same data is given to LCD or not? all control signals are generated as per requirements or not?

     

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

RSS Recent Posts

  • PCB manufacturing issues April 18, 2026
  • Bot checks April 18, 2026
  • Convenient audio FFT module? April 18, 2026
  • SDCC Array Access In Timer 0 Interrupt Handler April 18, 2026
  • Assistance locating a 'trail' camera gadget, please ? April 18, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 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