Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
clawson
PostPosted: Jun 20, 2012 - 03:10 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62294
Location: (using avr-gcc in) Finchingfield, Essex, England

I find this almost amusing. So I took your code and built it and got the same errors you see. So I double clicked the first error to go to the source line involved and it says:
Code:
DDRC &=~((1<<PC0)|(1<<PC1)|(1<<PC2)|(1<<PC3)|(1<<PC4));// ADC i/p R,B,Y & Gnd, neutral

To be honest I cannot see anything wrong with that line so I do the natural thing and start to look back to a previous line where the actual error may be. I don't have to go very far before I get to:
Code:
DDRB |=(1<<PB0)//error occur

//set portC0-4 as i/p with pull up resistor
DDRC &=~((1<<PC0)|(1<<PC1)|(1<<PC2)|(1<<PC3)|(1<<PC4));// ADC i/p R,B,Y & Gnd, neutral

The comment even says "// error occur". Do you not see why? That line has no terminating semi-colon (just because it ends in a comment does not make the semi-colon statement terminator optional!)

After fixing that one the error that remains is:
Code:
                  else(adc_result[i]<690)//checking for 230V
                  {

I wonder IF you are missing some keyword in that line? Wink

Having fixed those two lines the code compiles without error - of course there's no guarantee that it actually does what you hope when it runs!

You need to learn to do what I just did - when you get an error (or a warning - don't just ignore those) you need to take the line number given in the message and go to that line in the source (most IDE let you double-click on the message to get there). Then study the line that's been highlighted. Either it has an obvious error (like your second error here missing "if") or if the line looks OK the chances are the problem has actually occurred on a previous line (which can sometimes even mean in a #include'd .h file) and you have to look back through the code for anything that looks suspicious - like your missing semi-colon.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Jun 21, 2012 - 08:47 AM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18552
Location: Lund, Sweden

So, you have...

1) A definition of F_CPU that is in the wrong place, or possibly redundant

and

2) Likely a missing semicolon somewhere above line 97 in protector.c
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
justinjohney
PostPosted: Jun 21, 2012 - 08:59 AM
Hangaround


Joined: Jun 04, 2012
Posts: 295
Location: Mumbai,India

how can i simulate this code with analog signal.
I want to know about the behaviour of the code?


Code:
#include <avr/io.h>
#include <stdio.h> 
#include <avr/interrupt.h>
#include <util/delay.h>

//# define F_CPU 1000000UL //system clock @1MHz

//Global variable
int adc_result[5]={0,0,0,0,0};//for storing the adc out put
uint8_t ch=0;
uint8_t y=0;
uint8_t i=0;
int k=0;

/* PORT INIT */
void port_init (void)
{
DDRB |=(1<<PB1);//set portB.1 as output drive for relay
PORTB&=~(1<<PB1);//initially set 0 as o/p drive
DDRB |=(1<<PB0);//error occur

//set portC0-4 as i/p with pull up resistor
DDRC &=~((1<<PC0)|(1<<PC1)|(1<<PC2)|(1<<PC3)|(1<<PC4));// ADC i/p R,B,Y & Gnd, neutral
PORTC |=((1<<PC0)|(1<<PC1)|(1<<PC2)|(1<<PC3)|(1<<PC4));

//set up port D 0-4  as output
DDRD &=~((1<<PD0)|(1<<PD1)|(1<<PD2)|(1<<PD3)|(1<<PD4));//o/p led for R,B,Y and GLP
}

void init_adc(void)
{
ADCSRA |= ((1 << ADPS1) | (1 << ADPS0));// Set ADC prescaler to 8 - 125KHz sample rate @ 1MHz
ADCSRA |= (1 << ADEN);  // Enable ADC
ADCSRA |= (1 << ADIE); // Enable ADC Interrupt
ADCSRA |= (1<<ADSC);//start conversion
while (!(ADCSRA & (1<<ADIF)));//wait for coversion to be completed

}

void init_glp(void)
{
   i=ch;
   ADMUX=ch;
   init_adc();
   adc_result[i]=ADCW;
}



int main(void)
{
   i=ch;
   port_init();
   ADMUX=ch;
   init_adc();
   ADCSRA |= (1<<ADSC);//discarding the first adc result
   
// Loop Forever
    while(1)
       {
         ch=0;
         init_adc();
         if(ch<3)
         {
            for(ch=0;ch<3;ch++)
               {
               {   
                  ADMUX=ch;
                  init_adc();
                  adc_result[i]=ADCW;
                  if (adc_result[i]>795)//checking for 265V
                  {
                     PORTD=y;//OV indication led on
                     _delay_ms(1);
                     init_adc();
                     adc_result[i]=ADCW;
                        while(adc_result[i]>810)//checking for 270V
                        {
                           do
                           {
                              PORTB|=(1<<PB1); //  o/p drive ON
                              init_adc();
                              _delay_ms(1);
                              adc_result[i]=ADCW;
                           }while(adc_result[i]>795);
                           PORTD=0x00;//off the OV indicator led
                           PORTB&=~(1<<PB1);// o/p drive off
                        }
                  }
                  else if(adc_result[i]<690)//checking for 230V
                     {
                        do
                        {
                           PORTD|=(1<<PD3);// on the led corresponding to UV indication
                           init_adc();
                           adc_result[i]=ADCW;
                        }while(adc_result[i]<690);//checking for 230V
                     }
                  y++;
               }
            }
            y=0;
         }   
         else if((2<ch)&&(ch<5))
         {
            ch=3;
            init_glp();
            ch++;
            init_glp();
            k=(adc_result[4]-adc_result[3]);
            if(k>30)//checking for 230V
            {
               PORTD|=(1<<PD4);//ON the led corresponding to GLP indication
               _delay_ms(1);
               ch=3;
               init_glp();
               ch++;
               init_glp();
               k=(adc_result[4]-adc_result[3]);
               if(k>45)//checking for 15V difference
               {
                  do
                  {
                     PORTB|=(1<<PB1); //  o/p drive ON
                     ch=3;
                     init_glp();
                     ch++;
                     init_glp();
                     k=(adc_result[4]-adc_result[3]);
                  }while(k>30);//checking for 15V difference
                  PORTB&=~(1<<PB1);// o/p drive off
                  PORTD&=~(1<<PD4);//OFF the led corresponding to GLP indication
               }
            
            }
         }
         else
         {
            PORTB|=(1<<PB0);
         }
      }
}
 
 View user's profile Send private message  
Reply with quote Back to top
justinjohney
PostPosted: Jun 21, 2012 - 09:16 AM
Hangaround


Joined: Jun 04, 2012
Posts: 295
Location: Mumbai,India

how can i make a stimuly file for above code?
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jun 21, 2012 - 10:17 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62294
Location: (using avr-gcc in) Finchingfield, Essex, England

Quote:

how can i make a stimuly file for above code?

What did the user manual tell you?

(oh and just to be clear AS4.19 has the most advanced stimuli functionality ever produced by Atmel. AS5 and AS6 have not yet got the same functionality so you must use Studio 4.19 if you want to be able to write stimuli scripts).

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
justinjohney
PostPosted: Jun 21, 2012 - 12:33 PM
Hangaround


Joined: Jun 04, 2012
Posts: 295
Location: Mumbai,India

how can i write write stimuli scripts?
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jun 21, 2012 - 12:36 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62294
Location: (using avr-gcc in) Finchingfield, Essex, England

Quote:

how can i write write stimuli scripts?

By following the guidance in the manual. It's what all other programmers trying to use the feature do too. Or did you want someone to read the manual out to you or something? This is the example shown in the manual - it even shows them faking values in to the ADC registers:
Code:
The example also shows use of logging and break directives.
 
// Initial delay
#100
// Set up logging ADC and ADCSRA to file adc.log
$log ADCL
$log ADCH
$log ADCSRA
$startlog adc.log
// start of repeat loop
$repeat 100
// Assuming TCNT1 is running, use as data for ADC
ADCL = *TCNT1L
ADCH = *TCNT1H
// Set ADIF flag in ADCSRA, this will trigger ADCC interrupt
ADCSRA |= 0x10
#30
$endrep
// Stop logging (close log file)
$stoplog
// break program execution
$break

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Jun 21, 2012 - 12:43 PM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18552
Location: Lund, Sweden

Cliff! It seems it is time for following the new policy and just walk away.

Justin! Over several threads you have repeated more or less the same question. You have been given directions as to what to study, but we have seen no or little response or reaction to those advice. Instead a similar question is just posed again.

While it may not be so, it makes you come through as either lazy or spoiled or possibly both. In the past, such a situation might have led to "flaming" or harsch language. There is a new policy in place here at AVRfreaks which means that in such a situation there should be no flaming or harsh words, but rather that one should just walk away and not comment on the question(s) at all.

To be blunt: We are not here to spoon-feed you a solution. We are here because we are looking for interesting discussions, because we are genuinely interested in seeing other people learn how to solve AVR-related problems, or we might be here and answer just to rub our egos. Nothing in your threads fulfils any of those goals for anyone of us.

I will now walk away.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
bobgardner
PostPosted: Jun 21, 2012 - 12:49 PM
10k+ Postman


Joined: Sep 04, 2002
Posts: 21258
Location: Orlando Florida

First thing that I saw was lots of calls to init_adc(). Seems like the a/d should just be initialized once at the top of the program. Then it looks like the actual reading of the a/d is sort of distributed all over with lots of redundancy. The concept of 'subroutine' is applicable here. Why not have one function called readadchan(n) that selects admux channel n, inits conversion, polls the adsc bit till it goes low, then returns the value of the a/d? Then you could even have another function called readadchannels() that calls readadchan(n) in a loop. Then your main loop would be something like a while(1) loop with a call to readadchans() and processadvalues(). That would be easier to format and indent because it would be shorter and simpler. Unlike this message.

_________________
Imagecraft compiler user
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
justinjohney
PostPosted: Jun 21, 2012 - 02:02 PM
Hangaround


Joined: Jun 04, 2012
Posts: 295
Location: Mumbai,India

thanx Mr bobgardner for your answer and patience.

here is the my updated code
is it look to be a standared code? can we predicts its nature

Code:
# define F_CPU 1000000UL //system clock @1MHz


#include <avr/io.h>
#include <stdio.h> 
#include <avr/interrupt.h>
#include <util/delay.h>


//Global variable
uint16_t adc_result[5]={0,0,0,0,0};//for storing the adc out put
uint8_t ch=0;
uint8_t y=0;
uint8_t i=0;
int k=0;

/* PORT INIT */
void port_init (void)
{
DDRB |=(1<<PB1);//set portB.1 as output drive for relay
PORTB&=~(1<<PB1);//initially set 0 as o/p drive
DDRB |=(1<<PB0);//error occur

//set portC0-4 as i/p with pull up resistor
DDRC &=~((1<<PC0)|(1<<PC1)|(1<<PC2)|(1<<PC3)|(1<<PC4));// ADC i/p R,B,Y & Gnd, neutral
PORTC |=((1<<PC0)|(1<<PC1)|(1<<PC2)|(1<<PC3)|(1<<PC4));

//set up port D 0-4  as output
DDRD &=~((1<<PD0)|(1<<PD1)|(1<<PD2)|(1<<PD3)|(1<<PD4));//o/p led for OV,UV and GLP
}

void init_adc(void)
{
   ADCSRA |= ((1 << ADPS1) | (1 << ADPS0));// Set ADC prescaler to 8 - 125KHz sample rate @ 1MHz
   ADCSRA |= (1 << ADEN);  // Enable ADC
}

void read_adc(void)
{
   _delay_ms(1);
   ADCSRA |= (1 << ADIE); // Enable ADC Interrupt
   ADCSRA |= (1<<ADSC);//start conversion
   while (!(ADCSRA & (1<<ADIF)));//wait for coversion to be completed
   adc_result[i]=ADCW;
}

void init_glp(void)
{
   i=ch;
   ADMUX=ch;
   read_adc();
   adc_result[i]=ADCW;
}
void glp(void)
{
   init_glp();
   ch++;
   init_glp();
   k=(adc_result[4]-adc_result[3]);
}



int main(void)
{
   i=ch;
   port_init();
   ADMUX=ch;
   init_adc();
   read_adc();
   
// Loop Forever
    while(1)
       {
         ch=0;
         if(ch<3)
         {
            for(ch=0;ch<3;ch++)
               {
                  ADMUX=ch;
                  read_adc();
                  if (adc_result[i]>792)//checking for 255V
                  {
                     PORTD|=(1<<PD0);//OV indication led on
                     _delay_ms(1);
                     read_adc();
                        while(adc_result[i]>823)//checking for 265V
                        {
                           do
                           {
                              PORTB|=(1<<PB1); //  o/p drive ON
                              read_adc();
                           
                           }while(adc_result[i]>792);//Should be in the state off until voltage reaches under 255V
                           PORTD=0x00;//off the OV indicator led
                           PORTB&=~(1<<PB1);// o/p drive off
                        }
                  }
                  else if(adc_result[i]<621)//checking for 200V
                  {
                     
                           PORTD|=(1<<PD3);// on the led corresponding to UV indication
                           read_adc();
                           while(adc_result[i]<495)// checking for 160V
                           {
                              do
                              {
                                 PORTB|=(1<<PB1); //  o/p drive ON
                                 read_adc();
                              }while(adc_result[i]<543);   _delay_ms(1);
                              PORTB&=~(1<<PB1);// o/p drive off
                           }
                        PORTD&=~(1<<PD3);//Off the UV indicator
                  }
                  i++;
               }
               ch++;
         }
         
//GLP SECTION
            
         else if((2<ch)&&(ch<5))
         {
            {
               ch=3;
               glp();
               if(k>22)//checking for 7V
               {
                  PORTD|=(1<<PD4);//ON the led corresponding to GLP indication
                  _delay_ms(1);
                  ch=3;
                  glp();
                  if(k>22)//checking for 9V difference
                  {
                     do
                     {
                        PORTB|=(1<<PB1); //  o/p drive ON
                        ch=3;
                        glp();
                     }while(k>3);//Should be in the state off until voltage reaches under 7V
                     PORTB&=~(1<<PB1);// o/p drive off
                     PORTD&=~(1<<PD4);//OFF the led corresponding to GLP indication
                  }
               }
            }
            ch=0;
         }
         else
         {
            PORTB|=(1<<PB0);
         }
      }
}


________________________________________
Be keep patience to those who needs it.

Justin
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jun 21, 2012 - 02:07 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62294
Location: (using avr-gcc in) Finchingfield, Essex, England

Change this:
Code:
   ADCSRA |= (1 << ADIE); // Enable ADC Interrupt
   ADCSRA |= (1<<ADSC);//start conversion
   while (!(ADCSRA & (1<<ADIF)));//wait for coversion to be completed
   adc_result[i]=ADCW;

For one thing you don't have to use ADIE to be able to use ADIF but if you do use ADIF then because it goes to 1 at the end you have to reset it. Using ADSC to determine when the conversion completes is a better idea as it automatically returns to 0.
to this
Code:
   ADCSRA |= (1<<ADSC);//start conversion
   while ((ADCSRA & (1<<ADSC)));//wait for coversion to be completed
   adc_result[i]=ADCW;

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
bobgardner
PostPosted: Jun 21, 2012 - 03:46 PM
10k+ Postman


Joined: Sep 04, 2002
Posts: 21258
Location: Orlando Florida

I recommend that programs should be tested and debugged without the use of interrupts from the a/d and uarts. Using interrupts means you have to turn them on and off and write the interrupt handlers correctly and name the interrupt vectors correctly, and its just generally error prone for newer programmers. Interrupts are used to get better performance as the program gets bigger and slower. This program isnt there yet.

_________________
Imagecraft compiler user
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
justinjohney
PostPosted: Jun 22, 2012 - 11:20 AM
Hangaround


Joined: Jun 04, 2012
Posts: 295
Location: Mumbai,India

thanx Mr.bobgardner
i update my code as
Code:

# define F_CPU 1000000UL //system clock @1MHz
#define THRES_255V   792
#define   THRES_265V   823
#define   THRES_200V   621
#define   THRES_160V   495
#define   THRES_175V   543
#define   THRES_9V   28
#define   THRES_7V   22


#include <avr/io.h>
#include <stdio.h> 
#include <avr/interrupt.h>
#include <util/delay.h>


//Global variable
uint16_t adc_result[5]={0,0,0,0,0};//for storing the adc out put
uint8_t ch=0;
uint8_t y=0;
uint8_t i=0;
int k=0;

/* PORT INIT */
void port_init (void)
{
DDRB |=(1<<PB1);//set portB.1 as output drive for relay
PORTB&=~(1<<PB1);//initially set 0 as o/p drive
DDRB |=(1<<PB0);//error occur pin

//set portC0-4 as i/p with pull up resistor
DDRC &=~((1<<PC0)|(1<<PC1)|(1<<PC2)|(1<<PC3)|(1<<PC4));// ADC i/p R,B,Y & Gnd, neutral
PORTC |=((1<<PC0)|(1<<PC1)|(1<<PC2)|(1<<PC3)|(1<<PC4));

//set up port D 0-4  as output
DDRD &=~((1<<PD0)|(1<<PD1)|(1<<PD2)|(1<<PD3)|(1<<PD4));//o/p led for OV,UV and GLP
}

void init_adc(void)
{
   ADCSRA |= ((1 << ADPS1) | (1 << ADPS0));// Set ADC prescaler to 8 - 125KHz sample rate @ 1MHz
   ADCSRA |= (1 << ADEN);  // Enable ADC
}

void read_adc(void)
{
   i=ch;
   _delay_ms(1);
    ADCSRA |= (1<<ADSC);//start conversion
   while ((ADCSRA & (1<<ADSC)));//wait for coversion to be completed
      adc_result[i]=ADCW;
}

void init_glp(void)
{
   ADMUX=ch;
   read_adc();
}
void glp(void)
{
   init_glp();
   ch++;
   init_glp();
   k=(adc_result[4]-adc_result[3]);
}



int main(void)
{
   i=0;
   i=ch;
   port_init();
   ADMUX=ch;
   init_adc();
   read_adc();
   
// Loop Forever
    while(1)
       {

         PORTD&=~(1<<PD0);//OV indication led off

         if(ch<3)
         {
            for(ch=0;ch<3;ch++)
               {
                  ADMUX=ch;
                  read_adc();
                  if (adc_result[i]>THRES_255V)//checking for 255V
                  {
                     PORTD|=(1<<PD0);//OV indication led on
                     _delay_ms(1);
                     read_adc();
                        while(adc_result[i]>THRES_265V)//checking for 265V
                        {
                           do
                           {
                              PORTB|=(1<<PB1); //  o/p drive ON
                              read_adc();
                           
                           }while(adc_result[i]>THRES_255V);//Should be in the state off until voltage reaches under 255V
                           PORTD=0x00;//off the OV indicator led
                           PORTB&=~(1<<PB1);// o/p drive off
                        }
                  }
                  else if(adc_result[i]<THRES_200V)//checking for 200V
                  {
                     
                           PORTD|=(1<<PD3);// on the led corresponding to UV indication
                           read_adc();
                           while(adc_result[i]<THRES_160V)// checking for 160V
                           {
                              do
                              {
                                 PORTB|=(1<<PB1); //  o/p drive ON
                                 read_adc();
                              }while(adc_result[i]<THRES_175V);
                              PORTB&=~(1<<PB1);// o/p drive off
                           }
                        PORTD&=~(1<<PD3);//Off the UV indicator
                  }
               }
            ch++;
         }
         
//GLP SECTION
            
         else if((2<ch)&&(ch<5))
         {
            {   
               ch=3;
               glp();
               if(k>THRES_7V)
               {
                  PORTD|=(1<<PD4);//ON the led corresponding to GLP indication
                  _delay_ms(1);
                  ch=3;
                  glp();
                  if(k>THRES_9V)
                  {
                     do
                     {
                        PORTB|=(1<<PB1); //  o/p drive ON
                        ch=3;
                        glp();
                     }while(k>THRES_7V);
                     PORTB&=~(1<<PB1);// o/p drive off
                     PORTD&=~(1<<PD4);//OFF the led corresponding to GLP indication
                  }
               }
               else
               {
                  PORTD&=~(1<<PD4);//off the led corresponding to GLP indication
               }

            }
            ch=0;
         }
         else
         {
            PORTB|=(1<<PB0);// Error in microcontroller programming
            ch=0;
         }
      }
}

 
 View user's profile Send private message  
Reply with quote Back to top
justinjohney
PostPosted: Jun 22, 2012 - 11:22 AM
Hangaround


Joined: Jun 04, 2012
Posts: 295
Location: Mumbai,India

# define F_CPU 1000000UL
is 1 MHz is the default system clock?
is i need to add any extra oscillator in my ciruit for setting system clock?
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jun 22, 2012 - 11:46 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62294
Location: (using avr-gcc in) Finchingfield, Essex, England

Quote:

# define F_CPU 1000000UL
is 1 MHz is the default system clock?

It is. So if you haven't changed fuses that is likely the speed the AVR is running at. The reason you set that #define in the code is simply so that _delay_ms() and _delay_us() can have a good go at working out how many cycles to run for to delay for the given number of milli or micro seconds.

I cannot see anything else in your code that makes use of F_CPU.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
justinjohney
PostPosted: Jun 23, 2012 - 07:12 AM
Hangaround


Joined: Jun 04, 2012
Posts: 295
Location: Mumbai,India



Last edited by justinjohney on Jun 23, 2012 - 08:18 AM; edited 1 time in total
 
 View user's profile Send private message  
Reply with quote Back to top
larryvc
PostPosted: Jun 23, 2012 - 07:33 AM
Raving lunatic


Joined: Dec 06, 2007
Posts: 2512
Location: Redmond, WA USA

how can i...? how can i...? I am not trying to be rude or callous, but, how can we make you understand that there is a point that you will have to sit down and figure out some things on your own like everybody else here has done or is doing. Most of us here have a lot of patience and will go to extremes at times to help someone understand whatever it is they don't understand. There is a limit to that patience, and when we see that there is no initiative on the part of the person we are helping, then that patience ends.

Start to take the initiative and look things up on your own by using google, bing, baidu or whatever search engine you have access to.

_________________
Larry

Those afraid to embrace the future will quickly fade into the past. - larryvc
 
 View user's profile Send private message  
Reply with quote Back to top
bobgardner
PostPosted: Jun 23, 2012 - 03:30 PM
10k+ Postman


Joined: Sep 04, 2002
Posts: 21258
Location: Orlando Florida

I'd just like to see Justin write a small program that reads one a/d channel and prints the result in a loop. You can test it with a pot from 5V to gnd. Should see smooth change from 0x000 to 0x3ff. The next program could read 3 channels and print them out. At least give us a spec of what a glp is and what the R G and Y represent. Its like a puzzle. If you need design help, explain the requirements. If you want program debugging help, listen to the suggestions that the programmers post. If you need programming help, show us your whack at the read-an-a/d-channel-and-print-it-out program.

_________________
Imagecraft compiler user
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
justinjohney
PostPosted: Jun 25, 2012 - 11:40 AM
Hangaround


Joined: Jun 04, 2012
Posts: 295
Location: Mumbai,India

is a direct 5v ac can be supplied to adc pin of atmega series?is it need to be rectified?
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jun 25, 2012 - 11:50 AM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62294
Location: (using avr-gcc in) Finchingfield, Essex, England

Is that 5V AC with a 2.5V DC offset (so the entire wave is in the positive domain or is it centred at 0V so it +2.5V and -2.5V at the peaks? If the latter you are going to find your AVR does not like negative voltages (be ready with a butterfly net to catch the smoke cloud!). If the signal needs to be offset I think our sparky friends would advise the use of an op-amp.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits