NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » Where is the analog-comparator documented? For ATmega168

December 27, 2010
by Ralphxyz
Ralphxyz's Avatar

From the ATmega 168 specsheet:

15.6 Input Capture Unit
         The Timer/Counter incorporates an Input Capture unit that can 
         capture external events and give them a time-stamp indicating 
         time of occurrence. The external signal indicating an event, or 
         mul- tiple events,  can be applied via  the ICP1 pin or alternatively, 
         via the analog-comparator unit.

I tried searching the specsheet for analog-comparator but only got the one reference.

I am looking for methods to capture pulses coming from my anemometer project.

Ralph

December 27, 2010
by mrobbins
(NerdKits Staff)

mrobbins's Avatar

Hi Ralph,

Chapter 22 (datasheet pages 242-244) is entirely about the analog comparator.

Then again, you may find that a pin change interrupt on a normal digital pin may suit your needs just as easily since you now have large voltage swings coming from your phototransistor.

In either case, don't forget about "debouncing" as you're likely to get multiple noise-induced transitions close together as the disc slot is rotating just past the sensor edge. This can be done in software, or can be done electronically by buying/building something like a "Schmitt trigger", which is really just a say of saying a circuit with hysteresis. (Note for future readers of this thread: a Schmitt trigger won't help with traditional debouncing of a bouncy switch contact. However it may be useful here because of the analog / noisy nature of the sensor, assuming the hysteresis level is much larger than the noise level.)

Mike

December 28, 2010
by Ralphxyz
Ralphxyz's Avatar

I have found other post on the internet with people capturing the same pulse who lost pulses because of the overhead of their debounce code.

I would like to use the Input Capture Noise Canceler of Timer/Counter1

15.11.2 TCCR1B – Timer/Counter1 Control Register B

Bit 7 – ICNC1: Input Capture Noise Canceler

"When the noise canceler is activated, the input from the Input Capture pin (ICP1) is filtered.

The filter function requires four successive equal valued samples of the ICP1 pin for changing its output."

It seems using the mcu to filter the input would be faster (better) than using code.

Will there be a problem using ICP1 (PB0).

I have tried using PB0 to flash a led and that didn't work so is there a conflict with the bootloader?


I know how to turn on the capture/noise canceling and how to trigger the interrupt but i am still struggling with showing revolutions on the LCD. I do not know if I need to use a elapse timer and tie the elapse time to number of revolutions (how).

All this math has got my mind so distracted I cannot think logically any longer to put two and two together to make one.

Ralph

Post a Reply

Please log in to post a reply.

Did you know that you can generate hundreds of volts AC from your microcontroller with a little bit of circuitry? Learn more...