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
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
Comment