ADC sampling

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brigesh
    New Member
    • Feb 2007
    • 2

    ADC sampling

    Hi,

    I have a project where i need to use embedded C for the analog to digital conversion of a single signal. I want to sample the analog signal about 8 times a second and display the average output, my preferred microcontroller for use is the Atmega8. This will be my first project using C and microcontroller s.. My initial ideas are:

    * To begin by defining the ADC as Port C
    * Setting RES0 and RES1 as 1 for a reference voltage, ADC 0 as the input and then enabling ADEN.
    * I can then produce an ADC_Sample class to instigate a delay of 265us for the first conversion and produce the output at ADCH, while incrementing the count (count++).
    *The value of ADCH can go into another temporary register
    * I can carry this out 7 more times with roughly 122ms delays between samples being taken with the count incrementing and the output at ADCH being added to the temporary register.
    *When the count reaches 8 the temporary register can be divided by 8 and output at another appropriate register (I was thinking of using an if statement here).

    These are only initial ideas, if anyone can offer a better solution to this problem or if my approach does not seem correct, please can you inform me and perhaps offer some tips on how this problem may be approached.

    Any help or guidance given will certainly be appreciated!.Th anks!.
    -B
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    I tend to use dsPic devices but your approach sounds OK. Have you looked on the Atmel site?
    http://www.atmel.com/dyn/products/devices.asp?fam ily_id=607

    in particular
    http://www.atmel.com/dyn/products/product_card.as p?part_id=2004

    also the embedded systems discussion group
    http://www.embeddedrel ated.com/groups.php

    Comment

    • brigesh
      New Member
      • Feb 2007
      • 2

      #3
      Thank you for your feedback,

      Yes, I have looked at the Atmel site (in particular the datasheet for the microcontroller ) and after much effort today, I am now pleased to say that I am making significant progress and have now written working code for two thirds of this stage of the project. All that remains is to set up an array for the sample values and make an average of the array elements. Once again thanks for the guidance I really appreciate it!.
      -B

      Comment

      Working...