Meauring 150mV using comparator on ATmega128...

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

Hi - I need to toggle the analogue comparator at between 100mV - 200mV and to fire the compare interrupt (using WinAVR/GCC 4.14).

Is there a simple was of getting a reference voltage for this with low component count, ar are there any tricks I need to know about?

Thanks for any ideas....

Nick

Nicko

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

The lowest component count I can thing of is 2 resistors.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:
The lowest component count I can thing of is 2 resistors.
If I need to use the ADC (freerunning) as well, will this present a problem...

Nick

Nicko

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

Well, duh.

WE have an old saying here: RTFDS
The tome tells all

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

jgmdesign wrote:
Well, duh.
WE have an old saying here: RTFDS
The tome tells all

Well, Jim, Duh. In other groups I am a member of we also have an old saying: There are few stupid questions, but plenty of stupid answers.

I am new to AVRs and am learning, but I was wondering if there was a neater/cleaner way of doing this - I have looked extensively at the DS (I have a printed & bound copy with me) and I have a demo board (from Olimex), but I'm short of real-estate and need a minimal component count solution.

Regarding the trite "The tome tells all" - it certainly doesn't - I've found errors, some significant (one of which I discussed here), in the DS (and in AVRStudio - a showstopper) and reported them to Atmel who were very polite and helpful.

Nick

Nicko

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

Glad to hear we have a proofreader......

If you run the ADC in Free running mode and have it's interrupt enabled the 128 is going to be constantly servicing that interrupt.

jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

If you really need to save the [AVR] pin, you could amplify the signal and compare against the bandgap. Otherwise you probably want to create the desired level on the AINn pin.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

jgmdesign wrote:
Glad to hear we have a proofreader......
The point being that the DSs are a) not always complete, and b) not always 100% accurate, and c) don't contain many tips&tricks (which is actually what I was hoping for).

In freerunning mode, the ADC will take approx 13 cycles to complete, so my main loop still runs (its only updating an LCD) but it really could be slowed down, so I'll trigger it from a timer.

Anyway, it looks like there is no shortcut, so a few passives it is...

Nick

Nicko

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

jgmdesign wrote:

Quote:
If you run the ADC in Free running mode and have it's interrupt enabled the 128 is going to be constantly servicing that interrupt.
I would say this is generally not true (but it depends on what goes on in the interrupt service routine).

Quote:
In freerunning mode, the ADC will take approx 13 cycles to complete
This is ADC cycles, so, with a resonable ADC clock (like 125Khz), the free running mode adc interrupt overhead should not be a problem. Just don't put any heavy computation in it (but that is general advice re. any interrupt handler).
/Lars

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

nickds1 wrote:
The point being that the DSs are ... c) don't contain many tips&tricks (which is actually what I was hoping for).
You want application notes, not datasheets then. Compared to the datasheets of other companies the Atmel ones are rather good. And compared to the junk some Asian manufacturers or cloners try to pass as datasheets the Atmel ones are incredibly good.

Stealing Proteus doesn't make you an engineer.

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

nickds1 wrote:
In other groups I am a member of we also have an old saying: There are few stupid questions, but plenty of stupid answers.

I prefer "there are no stupid questions, just stupid people" :P