--Arduino--

Hello,

I have a small problem and I need your help!

I have a current sensor connected to Arduino (analog input), that allows me to read the values of the current in a simple circuit (AC power supply + charge),(the current sensor acts as an ammeter, thus connected in series with the charge).

I would like to detect the frequency of the current survey, and I found the library "FreqCounter" and I don't know if it will be helpful to solve my problem.

For more information on this library, please visit the links below:

https://www.pjrc.com/teensy/td_libs_...t.html#compare

http://www.circuitstoday.com/frequen...-using-arduino

What do you think? Could you clarify a little more the usefulness of this library?

Thanks :slight_smile:

Why don't you just count reads and divide by elapsed time?

GoForSmoke:
Why don't you just count reads and divide by elapsed time?

How can I do this? I'm pretty new in Arduino programmation, so can you give me more explication or examples, please?

You may very well benefit from going through some of the Examples in your IDE because what I do explain will not fill the holes in your understanding, will not let you see which way to go.

Time on Arduino is given by either millis() or micros(). The first is how many milliseconds since startup and the latter is microseconds to the nearest 4.

So you save a start time and you gather your samples, possibly 8 or 9 per millisecond, and when that is done you save the end time.

Then end time - start time = time elapsed

Samples / elapsed time = samples per time, you can scale that to seconds?

The last thing you want is code that you don't understand. You can't debug it or reliably change it. So please, learn instead of grabbing code somewhere and throwing it in. Otherwise, get someone else to write your code. Best choice is to learn.

If that sensor gives you only rms current value, then you cannot sense frequency. If it gives you instantaneous current you can measure the time between zero crosses.

mart256:
If that sensor gives you only rms current value, then you cannot sense frequency. If it gives you instantaneous current you can measure the time between zero crosses.

It would probably be smarter to use a comparator to generate interrupts than use analog reads then.

moderator: a more descriptive title will give forum visitors a better clue what this thread is about ...

GoForSmoke:
It would probably be smarter to use a comparator to generate interrupts than use analog reads then.

With comparator you cannot read values, with adc you can read values and frequency.