jleonqui
Posts: 1
Joined: Wed Nov 20, 2019 2:31 pm

Measuring frequency in a voltage signal

Wed Nov 20, 2019 4:43 pm

Hello,

I want to measure the frequency of a signal like the one that I am showing in the picture. I tried to measure the voltage with an analog-to-digital converter (MCP 3008 https://www.adafruit.com/product/856 ) and then I calculated the frequency with a python function in my code. This method works really well for low frequencies, but for high frequencies, this method is not very good. I thought that counting the peaks and the time between them would be another option, but I don't know how to do this. I would appreciate it if you have ideas on how to measure the frequency of this signal.

Thanks for your help.
Attachments
signal_v1.jpg
signal_v1.jpg (231.25 KiB) Viewed 1093 times

User avatar
neilgl
Posts: 2663
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: Measuring frequency in a voltage signal

Thu Nov 21, 2019 12:59 am

Maybe have a look at the Nyquist sampling theorem - sample at (at least) twice the expected frequency to get a good result?

User avatar
hitsware
Posts: 268
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa
Contact: Website

Re: Measuring frequency in a voltage signal

Thu Nov 21, 2019 1:24 am

Is that your oscilloscope in the picture ?
If so , read frequency at the bottom right of the display .
http://www.hitswares.com/

User avatar
joan
Posts: 15372
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Measuring frequency in a voltage signal

Thu Nov 21, 2019 9:17 am

Can't you condition the signal to produce a digital output suitable for the 3V3 GPIO? Then just read the pulses direct rather than via the slower ADC interface.

User avatar
mark3112
Posts: 46
Joined: Mon Apr 09, 2018 10:39 am

Re: Measuring frequency in a voltage signal

Thu Nov 21, 2019 10:56 am

As per Joan’s suggestion, try a zero crossing detector.
http://www.ti.com/lit/an/snoa999/snoa999.pdf
You can make a real CPU in a FPGA, but you can’t make a real FPGA in a CPU.

boyoh
Posts: 1581
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Measuring frequency in a voltage signal

Thu Nov 21, 2019 11:30 am

This is only a wild Idea to count the peaks is
Use a Zener diode as a peak clipper, At this point
The Zener diode will conduct .When it conducts
Use a Opto Isolato to switch a signal to the
Pi input

Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

User avatar
hitsware
Posts: 268
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa
Contact: Website

Re: Measuring frequency in a voltage signal

Thu Nov 21, 2019 2:52 pm

Say you covert to pulses and connect to gpio pin .
What then to count ?
http://www.hitswares.com/

User avatar
joan
Posts: 15372
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Measuring frequency in a voltage signal

Thu Nov 21, 2019 3:36 pm

hitsware wrote:
Thu Nov 21, 2019 2:52 pm
Say you covert to pulses and connect to gpio pin .
What then to count ?
The pulses in a second will give a frequency. Any of the GPIO libraries will let you detect and thus count GPIO level changes.

boyoh
Posts: 1581
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Measuring frequency in a voltage signal

Fri Nov 22, 2019 4:22 pm

hitsware wrote:
Thu Nov 21, 2019 2:52 pm
Say you covert to pulses and connect to gpio pin .
What then to count ?
I think a little understanding of Digital Electronics
Might be of help to you on how to use the Pi as
a counter.
Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

trejan
Posts: 3064
Joined: Tue Jul 02, 2019 2:28 pm

Re: Measuring frequency in a voltage signal

Fri Nov 22, 2019 5:03 pm

How high is high frequency?

boyoh
Posts: 1581
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: Measuring frequency in a voltage signal

Fri Nov 22, 2019 11:08 pm

trejan wrote:
Fri Nov 22, 2019 5:03 pm
How high is high frequency?
Time applied to a repetitive action ( Frequency)
BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

trejan
Posts: 3064
Joined: Tue Jul 02, 2019 2:28 pm

Re: Measuring frequency in a voltage signal

Sat Nov 23, 2019 12:15 am

boyoh wrote:
Fri Nov 22, 2019 11:08 pm
trejan wrote:
Fri Nov 22, 2019 5:03 pm
How high is high frequency?
Time applied to a repetitive action ( Frequency)
BoyOh
I know what frequency means. I was asking jleonqui as they said their setup worked for low frequencies but didn't for high frequencies. If they're trying to sample a 1MHz signal then the MCP3008 which has a maximum sample rate of 200ksps isn't going to work.

Return to “Beginners”