Pages: [1]   Go Down
Author Topic: High frequency measurement using Arduino Due  (Read 2241 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Everyone,

I am a newbie to Arduino boards and I am trying to do frequency measurement using an Arduino Due and store the frequency on a microSD card every 1ms. Here is the shield I'm using for the microSD card.

http://www.adafruit.com/products/254

The input signal is from a signal generator and I want to be able to measure the frequencies up to 400kHz. I was wondering if anyone knows about the best way to do this.

I have been working on this for weeks now and I am completely lost in the subject. I have tried many different ways, but non of them worked. So I decided to start fresh again and any help is greatly appreciated.

Thanks,
Shahab
Logged

St. Leonards-on-Sea, E. Sussex, UK.
Offline Offline
Sr. Member
****
Karma: 2
Posts: 301
Ancient developer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How are you processing the input signal? You need to convert it to a square wave so that you can use a timer to measure to measure the frequency.
Logged

Leon Heller
G1HSM

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is already a square wave signal. I'm not sure how I can use a timer.
Logged

St. Leonards-on-Sea, E. Sussex, UK.
Offline Offline
Sr. Member
****
Karma: 2
Posts: 301
Ancient developer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Measure the time between two pulses. You can then calculate the frequency.
Logged

Leon Heller
G1HSM

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem is using the Analogread(), I can only read the values from ADC up to 10,000 samples/sec which is the maximum of 10kHz for the input signal. I also found an example of using ADC in free mode, which I was able to measure the frequencies up to ~190kHz. Please let me know if you know of any other way to read the values from ADC.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem is using the Analogread(), I can only read the values from ADC up to 10,000 samples/sec which is the maximum of 10kHz for the input signal. I also found an example of using ADC in free mode, which I was able to measure the frequencies up to ~190kHz. Please let me know if you know of any other way to read the values from ADC.

Measuring a signal's frequency via it's amplitude values via an ADC is simply the wrong method. I suspect you will not get anything to work worth using. To measure frequency one counts signal zero crossings for a fixed 'sample time', then store the result and reset the count for the next sample window.

Lefty
 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
To measure frequency one counts signal zero crossings for a fixed 'sample time', then store the result and reset the count for the next sample window.

Could you please explain more what do you mean by counting the signal zero crossing? I am newbie anf I appreciate it if you could explain it more or even give me a sample code for doing so.

Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
To measure frequency one counts signal zero crossings for a fixed 'sample time', then store the result and reset the count for the next sample window.

Could you please explain more what do you mean by counting the signal zero crossing? I am newbie anf I appreciate it if you could explain it more or even give me a sample code for doing so.



http://interface.khm.de/index.php/lab/experiments/arduino-frequency-counter-library/

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does the library work on ARM processors? It looks to me that it was written for AVR processors.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does the library work on ARM processors? It looks to me that it was written for AVR processors.

Yes it was, just look at the dates, the Due came out late last year. I'm sure it could be modified if needed. I posted to show you the method used so that you can come to the conclusion that trying to use ADC to determine frequency of a signal is just not the way to go.

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm struggeling with a similar problem.
I took the approach of measuring the time between two interrupts.
Now it turns out that micros() delivers (randomly) wrong values when called in an interrupt-function.
Referring to this thread http://arduino.cc/forum/index.php/topic,148161.0.html
My new idea is to stop times directly with internal timers. But this turns out a bit more difficult than expected  smiley-confuse.
Logged

Pages: [1]   Go Up
Jump to: