code for sine wave sampling.

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

hello everyone.i am new to the AVR programing.recently i am doing a project where i need to sample a 50 hz sine wave to the ADC of atmega 32.but i can't write the code.i googled enough but nothing is helpful.can anyone help me by telling how to write code for sampling.thanks in advance

 

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

I think this is in wrong forum for ATmega 32.

 

[moved]

It all starts with a mental vision.

Last Edited: Mon. Nov 3, 2014 - 12:13 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you know how many samples you want to take? What sampling speed? Can you edit and compile and burn and run ANY simple program for an AVR? Like turn an led on and off? Can you write a program to init the uart and send UUUUUUU in a loop at a standard baud rate and see it on a PC terminal program? You are almost there! Just write a c function to read channel 0 of the AVR a/d converter and store it in an array. Put this in a for loop. Add a print statement to print out the a/d value in hex. Hook a pot up from 5V to gnd, wiper to a/d input. Should get a smooth output from 0x000 to 0x3ff from the pot. To measure the 50Hz AC, you have to attenuate the peak to peak voltage to +-2.5V peak to peak, and add a 2.5V DC bias using resistors.

 

 

Imagecraft compiler user

Last Edited: Mon. Nov 3, 2014 - 05:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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...
Last Edited: Mon. Nov 3, 2014 - 09:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thread locked. Please do not double post.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

Topic locked