Go Down

Topic: Analog Comparator falling edge setup (Read 4 times) previous topic - next topic

daywalkerdha


I am concerned that the atmega328p datasheet provides (as far as I can tell) no data on the speed of the analog comparator, so there is no telling whether it is fast enough for this application.

I was concerned about that as well, but I'll try and report back.

As far as the circuit itself is concerned, I understand how it works and will use a similar setup. I know there are other ways with less hardware but this project is not intended for sale or anything, mainly just to use Atmega328 features I haven't used before(like the comparator) and understand how they work. And to have a working ESR-meter in the end ;)

@dhenry
I'd be interested in the code and schematic as well, but I'll implement it the other way.

dhenry

When you are done, come back and we can compare notes then.

daywalkerdha


When you are done, come back and we can compare notes then.


You know the schematic, and the code is pretty easy
Code: [Select]

ISR(TIMER2_COMPA_vect){                        // every 500µs
  bitWrite(PORTD, 3, 0);                          // Disable discharge
  bitWrite(PORTD, measurementRange, 0); // Pulse
  delayMicroseconds(7);                           // The pulse width should be around 8µs
  bitWrite(PORTD, measurementRange, 1); // Stops the pulse
  bitWrite(PORTD, 3, 1);                         // Enable discharge
}

ISR(ANALOG_COMP_vect){ // Comparator interrupt
  compareCounter++;
}


In the lowest range, every pulse is 10m?. In the middle range 100m? and 1? in the high range.

daywalkerdha

#33
Dec 14, 2012, 01:41 am Last Edit: Dec 14, 2012, 04:09 pm by daywalkerdha Reason: 1
What about your code and setup?

dhenry

Quote
In the lowest range, every pulse is 10m?. In the middle range 100m? and 1? in the high range.


Great. Please let us know how that's working out for you.


Go Up