Loading ...
Sorry, an error occurred while loading the content.

help needed

Expand Messages
  • danial_1000
    hi, i having a problem to display adc reading on the lcd display .i m using atmega32 and connected an analog voltage to ch0 of it.i m using avcc as a refrence
    Message 1 of 8 , Sep 2, 2009
    • 0 Attachment
      hi,
      i having a problem to display adc reading on the lcd display .i m using atmega32 and connected an analog voltage to ch0 of it.i m using avcc as a refrence ,the adc resolution is 10 bit ,i don,t understanding how to display the fractional part of adc reading for example i m inputing (5/1023=.0048v)and i read 0x01,so how i can display it on the display .plz help me with a simple code with comments for better understanding .
      thanking all of u ,
      dany
    • nitin chaudhary
      for reading values
      Message 2 of 8 , Sep 4, 2009
      • 0 Attachment
        for reading values <1, multioly them by 10 or 100 or 1000 to make it large...

        To display them in to lcd, convert these numbers into character..
        Say you want to display 42 (z).
        take first digit  x=z%2;
                     now x=2;
         take any char (char d='0').
        run a for loop (i) from 0 to 9
        in each iteration   compare i with x;
                                  if it not matches increment d by 1; and if matches send d to lcd...
        ex: we have x=2 and d='0'
        loop begins

        i=0
        x is not equal to i hence do nothing
        d=d+1; i.e. d='1'(character 1);

        i=1
        same and d='2';

        i=2 
        here x==i so print d to lcd and break i.e.2 which is easy since d is a character not integer

        now z=z/10;
        x=z%2; i.e. x=1;
        again d='0' and so on...


        Love Cricket? Check out live scores, photos, video highlights and more. Click here.
      • mihaigalos
        display a 0 and then a point and then the rest of the data :) Please add a better description of your problem. Mihai G.
        Message 3 of 8 , Sep 4, 2009
        • 0 Attachment
          display a 0 and then a point and then the rest of the data :)
          Please add a better description of your problem.

          Mihai G.

          --- In booksbybibin@yahoogroups.com, "danial_1000" <danial_1000@...> wrote:
          >
          > hi,
          > i having a problem to display adc reading on the lcd display .i m using atmega32 and connected an analog voltage to ch0 of it.i m using avcc as a refrence ,the adc resolution is 10 bit ,i don,t understanding how to display the fractional part of adc reading for example i m inputing (5/1023=.0048v)and i read 0x01,so how i can display it on the display .plz help me with a simple code with comments for better understanding .
          > thanking all of u ,
          > dany
          >
        • shamsher_saleem
          I will suggest you to upload the detailed program you are using and also the header file of the lcd which you are using. So that it can be observed for the
          Message 4 of 8 , Sep 4, 2009
          • 0 Attachment
            I will suggest you to upload the detailed program you are using and also the header file of the lcd which you are using. So that it can be observed for the bug.
            Many time there a smal basic mistake and you end up in the big mess


            --- In booksbybibin@yahoogroups.com, "mihaigalos" <mihaigalos@...> wrote:
            >
            > display a 0 and then a point and then the rest of the data :)
            > Please add a better description of your problem.
            >
            > Mihai G.
            >
            > --- In booksbybibin@yahoogroups.com, "danial_1000" <danial_1000@> wrote:
            > >
            > > hi,
            > > i having a problem to display adc reading on the lcd display .i m using atmega32 and connected an analog voltage to ch0 of it.i m using avcc as a refrence ,the adc resolution is 10 bit ,i don,t understanding how to display the fractional part of adc reading for example i m inputing (5/1023=.0048v)and i read 0x01,so how i can display it on the display .plz help me with a simple code with comments for better understanding .
            > > thanking all of u ,
            > > dany
            > >
            >
          • alexandru sorin
            If you use 10 bits them use this formula: 5*N/65535. The value from ADc is in 16 bits, but you use only 10 MSB. The uC have register in 8 bits, so for 10 bits
            Message 5 of 8 , Sep 8, 2009
            • 0 Attachment
              If you use 10 bits them use this formula: 5*N/65535. The value from ADc is in 16 bits, but you use only 10 MSB. The uC have register in 8 bits, so for 10 bits he will use 16.


              From: shamsher_saleem <shamsher_saleem@...>
              To: booksbybibin@yahoogroups.com
              Sent: Saturday, September 5, 2009 1:18:25 AM
              Subject: [booksbybibin,www.booksbybibin.tk] Re: help needed

               

              I will suggest you to upload the detailed program you are using and also the header file of the lcd which you are using. So that it can be observed for the bug.
              Many time there a smal basic mistake and you end up in the big mess

              --- In booksbybibin@ yahoogroups. com, "mihaigalos" <mihaigalos@ ...> wrote:
              >
              > display a 0 and then a point and then the rest of the data :)
              > Please add a better description of your problem.
              >
              > Mihai G.
              >
              > --- In booksbybibin@ yahoogroups. com, "danial_1000" <danial_1000@ > wrote:
              > >
              > > hi,
              > > i having a problem to display adc reading on the lcd display .i m using atmega32 and connected an analog voltage to ch0 of it.i m using avcc as a refrence ,the adc resolution is 10 bit ,i don,t understanding how to display the fractional part of adc reading for example i m inputing (5/1023=.0048v) and i read 0x01,so how i can display it on the display .plz help me with a simple code with comments for better understanding .
              > > thanking all of u ,
              > > dany
              > >
              >


              __________________________________________________
              Do You Yahoo!?
              Tired of spam? Yahoo! Mail has the best spam protection around
              http://mail.yahoo.com
            • danial_1000
              hi, i m working on a project where i does switching upon multiple adc readings.the problem is when i vary the the pot and enter that region where i want to
              Message 6 of 8 , Oct 21, 2009
              • 0 Attachment
                hi,
                i m working on a project where i does switching upon multiple adc readings.the problem is when i vary the the pot and enter that region where i want to switch the controller outputs starts dancing (blinking) means there is no solid switching as '1' or '0' and its also increasing the voltages on the output pins linearly as i varying the pot and approaching that region.plz help me.
                regards
                dany
                /*************my code is here*************/
                #include <avr/io.h>
                #include <util/delay. h>
                #define F_CPU 8000000ul
                volatile unsigned int ch;
                volatile int adc_result0= 0;
                volatile int adc_result1= 0;
                void adc_init(void)
                {
                //select reference voltage
                ADMUX=0X40;
                //set prescaller and enable ADC
                ADCSRA|=(1<< ADEN)|(1< <ADPS2)|( 0<<ADPS1) ;//prescaller is/64
                }
                int adc_start_conversion(unsigned int ch)
                {
                //set ADC channel
                unsigned int channel=ch & 0b00000111;
                ADMUX=ADMUX| channel;
                //Start conversion with Interupt
                ADCSRA |= (1<<ADSC)|(1< <ADIE);
                return (ADC);
                }
                int main(void)
                {


                DDRB=0XFF; // OUT PUTS
                sei(); //inite globle interrupt
                adc_init(); //INITILISE ADC MODULE
                while(1)
                {
                adc_result0= adc_start_ conversion( 0); //READ ADC0
                _delay_ms(30) ; //WAIT FOR 30 MILLISECOND

                adc_result1= adc_start_ conversion( 1); //READ ADC0
                _delay_ms(30) ; //WAIT FOR 30 MILLISECOND
                }
                return 0;
                }
                ISR(ADC_vect)
                {
                if((adc_result0 >=347 && adc_result0 <=409) && (adc_result1 <= 833))

                {
                PORTB |=(1<<PB0) ;
                PORTB &=~(1<< PB1);
                PORTB &=~(1<< PB2);
                PORTB |=(1<<PB3) ;
                PORTB &=~(1<< PB4);
                PORTB |=(1<<PB5) ;
                }
                else if((adc_result0 >= 409)&&(adc_result1 >=613 && adc_result1 <=833 ))
                {
                PORTB |=(1<<PB0) ;
                PORTB &=~(1<< PB1);
                PORTB &=~(1<< PB2);
                PORTB &=~(1<< PB3);
                PORTB &=~(1<< PB4);
                PORTB &=~(1<<PB5) ;
                }
                else
                {
                PORTB=0X00;

                }

                }
              Your message has been successfully submitted and would be delivered to recipients shortly.