how to program to sample a sine wave.

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i am new to AVR programing.can anyone tell me how to do the programing,to sample a full wave rectified sine wave of 0-5v and 50 hz into ADC of atmega32.i need some kind of code example,i understood the theory but i can't do the coding in AVR studio 6.thanks in advance.

 

Last Edited: Tue. Nov 4, 2014 - 01:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are articles in the tutorial forum about using the ADC. Have you read them? What wasn't clear? If you understand how to operate the ADC then what other problems are you having?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What information do you need about the sine wave?

Amplitude?

frequency?

shape?

RMS?

frequency change over time?

Harmonic content?

 

Depending on how you answer the above the solution can be anything from Rectify and filter it to running an FFT...

Keith Vasilakes

Firmware engineer

Minnesota

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In addition to being in the wrong forum, it is also a cross post.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

keith v wrote:
What information do you need about the sine wave? ... shape?

Errr... If it is a sine wave, then you know its shape!!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So youre saying it's a perfect sine wave?? no noise? No harmonics? no jitter, wow, flutter?

I'd like to see that

Keith Vasilakes

Firmware engineer

Minnesota

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ashif sent me a PM, maybe to others, also.

 

I responded that it would be very useful to know how this "sample" information is to be used. For example, if it is zero crossings (for a phase-controlled "dimmer) or frequency measurement, then sampling, in the usual sense is not needed. If it is necessary to determine how good of a sine it is, then many (more than 10 per period) ADC measurements are needed. So, to know what kind of "sampling" is needed, more information about the end use is required. 

 

The post talks about ADC but without the requested information, its not clear that the ADC is even important to use.

 

Jim

 

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey guys, this thread is in the wrong forum!

It should be merged with his thread in the mega/tiny forum.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

His other thread is now locked, and this one is (now) in the mega/tiny forum.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...