I have been looking on the web for AVR-GCC example sources on using the ADC converter in the ATmega32 or a related processor, to my disappointment, I have only found the Atmel AVR465: Energy meter example, are there any other examples both simple and complex on setting up and using this peripheral?
Andrew
Didn't find your answer? Ask the community — no account required.
C
Craig Ruff
This is from a simple application I use to decode the WWVB time codes. It is using the GCC AVR tool chain. It samples the amplified and filtered analog signal at 256 Hz to decode the time signal.
This is part of the initialization code:
// // Setup A/D, use AVCC for ref, ADC0 as input, left adjust value // Prescale CPU clock by 64 => 2,400 samp/sec max // ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(ADLAR); ADCSRA = _BV(ADEN) | _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0);
Forgot to mention that this is running on a ATmega128. The WWVB time code is PWM encoded in the power level of the 60 KHz carrier signal. The codes represent a position marker 'P', a binary 0 and binary 1. The EdgeDetect routine is looking for the transitions of the filtered signal. The way the analog circuitry is wired, the default state of the A/D values is to be at a higher number, so I sync up by looking for the higher numbers, then watch for a falling edge whcih represents the start of the second and the code. The amount of time the signal is at a lower number represents which code is being sent:
0.2s = 0 0.5s = 1 0.8s = P
A more detailed description of WWVB can be found at:
formatting link
B
BobG
Andrew: many examples and helpful friendly members at avrfreaks.net
A
Andrew Tweddle
The people might well be friendly but the interface drives me crazy!.It would have to be one of the worst web interfaces with all that redrawing every time you look at a new thread or message. Just a BG Bandwidth hog and absolutely no advantage to their advertising or thier user base, beats me? But thanks anyway, so endith the gripe.
Andrew
B
BobG
What the regulars do is hit the 'maximize' button on the menu, and the ads go away.
A
Andrew Tweddle
Thankyou!
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.