Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
I am working on an impedance analyzer of RC and RL circuits. My input frequency is a sweep frequency generator and the frequency will stop after it has detected that it is the resonant frequency. The Arduino will serve as the sweep frequency generator.
I would suggest you need to do the entire sweep, and log the results across the range, as you've no way of knowing if you've reached the resonant frequency until you've gone past it. Depending on serial or parallel resonance you need to detect the lowest or highest reading.
It depends entirely on how you write the software, and also (obviously) on the resolution you want to use.
As I said, the only way to detect the resonance is to sweep past it - only once you're past the peak (and it's going back down) do you know you've found the resonant frequency. You don't need to log all the readings, just the last 'so many' in a circular buffer, so once you've detected you're past the peak the stored values will include the resonant point.
OK, I agree with that, but that is not the only way.
At resonance the circuit becomes purely resistive, ie the inductive and capacitive reactances are equal and opposite and so cancel out.
So at resonance the current through the tuned circuit is exactly in-phase with the applied voltage.
If you arrange that your circuit looks for 0 degree phase shift between current and voltage, then you have found the resonant frequency.
Admittedly, this may be more complicated than looking for a peak (or dip) in the voltage.