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 / About ADC programming error….

About ADC programming error….

|

Microcontroller › PIC › About ADC programming error….

  • This topic has 2 replies, 3 voices, and was last updated 10 years, 4 months ago by Ashutosh Bhatt.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • December 22, 2014 at 7:52 am #3364
    jarry
    Participant

    I’m using PIC18f4550 and for ADC programming I’m getting error as below please any onr help me 

     

     

     

    D:\ProjectsCompleted_projectsPIC18F4550 tasksADC with LDCADClcd.c:79:Error [1105] symbol ‘GO’ has not been defined..

     

     

     

     

     

     

    MY CODE IS 

     

     

     

    // Program to depict working with inbuilt ADC of PIC18F4550 Microcontroller
    // This code uses Channel0 (zero) of PIC’s ADC Module
     
    // Configuration bits
    /* _CPUDIV_OSC1_PLL2_1L,  // Divide clock by 2
       _FOSC_HS_1H,           // Select High Speed (HS) oscillator
       _WDT_OFF_2H,           // Watchdog Timer off
       MCLRE_ON_3H            // Master Clear on
    */
    #include<p18f4550.h>
     
    #define rs PORTAbits.RA0
    #define rw PORTAbits.RA1
    #define en PORTAbits.RA2
    #define lcdport LATB
     
    void lcd_ini();
    void lcdcmd(unsigned char);
    void lcddata(unsigned char);
    void adc_con(unsigned int);
    void adc_init();
     
    unsigned char data[20]=”ADC OUTPUT=”;
    unsigned int digital_out[10],avg_output=0,temp;
    unsigned int i=0;
     
    void Delay_ms(unsigned int dly)
    {
    unsigned char i;
    for(;dly>0;dly–)
    {
    for(i=250;i>0;i–);
    for(i=237;i>0;i–);
    }
    }
     
    void adc_init()
    {
        ADCON1=0x0E;                            // Make RA0/AN0 pin as analog pin (Other pins remain to be digital I/O)
        ADCON0=0x00;                            // Select Channel0 & ADC off
        ADCON2=0x8A;                            // Left justified, 2TAD acquiciation time, Fosc/32 clock option
        ADCON0bits.ADON = 1;                        // Enable ADC
    ADCON0bits.GO = 1;
    }
     
     
    void lcd_ini()
    {
        lcdcmd(0x38);        // Configure the LCD in 8-bit mode, 2 line and 5×7 font
        lcdcmd(0x0C);        // Display On and Cursor Off
        lcdcmd(0x01);        // Clear display screen
        lcdcmd(0x06);        // Increment cursor
        lcdcmd(0x80);        // Set cursor position to 1st line, 1st column
    }
     
    void main(void)
    {
        TRISA=0x01;        // Configure RA0 as input pin
        LATA=0;
        TRISB=0;        // Configure Port B as output port
        LATB=0;
        TRISD=0;
        LATD=0;
        lcd_ini();        // LCD initialization
        while(data!=’’)
        {
            lcddata(data);      // Call lcddata function to send character one by from ‘data’ array
            i++;
        }
     
        adc_init();        //ADC Initialization
     
        while(1)
        {
     
            temp=0;
            for(i=0;i<10;i++)
            {
                ADCON0|=(1 << GO);                              // Start A/D conversion
                while(!(ADCON0 & (1 << GO)));                   // Wait until conversion gets over
                digital_out=((ADRESL)|(ADRESH<<8));        // Store 10-bit output into a 16-bit variable
                Delay_ms(20);
                temp=temp+digital_out;
            }
            avg_output=temp/10;                           // Take average of ten digital values for stablity
            adc_con(avg_output);                          // Function to convert the decimal vaule to its corresponding ASCII
     
        }
    }
     
     
     
     
    void adc_con(unsigned int adc_out)
    {
        unsigned int adc_out1;
        int i=0;
        char position=0xC3;
     
        for(i=0;i<=3;i++)
        {
            adc_out1=adc_out%10;                     // To exract the unit position digit
            adc_out=adc_out/10;
            lcdcmd(position);
            lcddata(48+adc_out1);                    // Convert into its corresponding ASCII
            position–;
     
        }
    }
     
     
    void lcdcmd(unsigned char cmdout)
    {
        lcdport=cmdout;        //Send command to lcdport=PORTB
        rs=0;                        
        rw=0;
        en=1;
        Delay_ms(10);
        en=0;
    }
     
     
    void lcddata(unsigned char dataout)
    {
        lcdport=dataout;    //Send data to lcdport=PORTB
        rs=1;
        rw=0;
        en=1;
        Delay_ms(10);
        en=0;
    }
     
    December 23, 2014 at 4:26 am #12446
    AJISH ALFRED
    Participant

    Hi,

     

    ADCON0|=(1 << GO);                              // Start A/D 

     

    The value of ‘GO’ need to be defined with a value, like

     

    #define GO 5

     

    Learn about the ADCON0 to find out the value that should be used to define  the ‘GO’

    December 24, 2014 at 10:09 am #12452
    Ashutosh Bhatt
    Participant

    you are using GO symbol many times. but actually it must be defined first. or else just give its value at every point like 0 or 1 or 5 etc

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

RSS Recent Posts

  • compatible eth ports for laptop May 18, 2025
  • how to work on pcbs that are thick May 18, 2025
  • Actin group needed for effective PCB software tutorials May 18, 2025
  • Kawai KDP 80 Electronic Piano Dead May 18, 2025
  • Doing consultancy work and the Tax situation? May 18, 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