lokobob99 Posted May 4, 2023 Share Posted May 4, 2023 Hello everyone, I have a simple question: Lets say for example you have a simple LED, which runs with a pwm-signal and a frequency of 100kHz. Is it possible to use the waveforms sdk to get the frequency (100kHz) of the LED and save it in a variable (e.g. in Python). Thanks in advance! Kind regards, Link to comment Share on other sites More sharing options...
0 attila Posted May 4, 2023 Share Posted May 4, 2023 Hi @lokobob99 To measure the frequency you can capture the data and process it or with Digital Discovery, ADP3X50 or newer use trigger counter-timer, FDwfAnalog/DigitalInCounter Link to comment Share on other sites More sharing options...
0 lokobob99 Posted May 5, 2023 Author Share Posted May 5, 2023 Hey @attila, thanks for the answer. I'm using an Analog Discovery 2 would, that be possible with this device? :) Kind regards, Link to comment Share on other sites More sharing options...
0 attila Posted May 5, 2023 Share Posted May 5, 2023 Hi @lokobob99 The counter-time is not available for AD2, so some data processing is needed to measure the frequency. Link to comment Share on other sites More sharing options...
0 lokobob99 Posted May 7, 2023 Author Share Posted May 7, 2023 Hey @attila, thanks for the reply! So you mentioned data processing: I would assume the first step is to measure the signal and save the values in a buffer of a certain size (e.g. 4096 values). Do you have a hint of what to do next? I would also assume you also need the sampling rate/frequency. Kind regards, Link to comment Share on other sites More sharing options...
0 Guest Posted May 7, 2023 Share Posted May 7, 2023 Hi @lokobob99 The standard mathematical tool to estimate the frequency from a bunch of equally spaced samples is the discrete fourier transform, or its slightly more complicated sibling, the discrete chirp-Z transform. Depending on how strong your mathematical background is, you may want to consult any standard text on digital signal processing to learn about those. If you just want something that works, you may want to look at this Github repository I made. The demo generates samples from a sinusoid signal and then recovers its frequency using the discrete fourier transform, the discrete fourier transform with zero-padding (to increase spectral resolution), and finally the discrete chirp-Z transform:https://github.com/sidneycadot/czt If you want to apply this technique to real data, the first thing to do is to fetch equidistant samples using the AD2. If you want to use Python for that, I can recommend that you take a look at pydwf (https://pypi.org/project/pydwf/), which makes it quite a bit easier to program Digilent devices from Python. Using that, getting a buffer of analog samples from the AD2 is about 15 lines of code. Link to comment Share on other sites More sharing options...
0 attila Posted May 8, 2023 Share Posted May 8, 2023 Hi @lokobob99 You could use the newly added FDwfDigitalInStatusCompress/ed functions. This works similar to record (see WK SDK/DigitalIn_Record_Compress.py) except it returns the value and stable count pairs. From this the signal period can be calculated. Link to comment Share on other sites More sharing options...
Question
lokobob99
Hello everyone,
I have a simple question: Lets say for example you have a simple LED, which runs with a pwm-signal and a frequency of 100kHz.
Is it possible to use the waveforms sdk to get the frequency (100kHz) of the LED and save it in a variable (e.g. in Python). Thanks in advance!
Kind regards,
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now