03-28-2019 07:12 PM
Hello
I am successful in reading the analog signal using the MCP3008 ( analog to digital converter) along with Raspberry Pi to LabVIEW using the BCM2835 library. The signal acquired is a Double (64 bit). Then I converted it into 1D array and then I build a waveform using the array. After getting the waveform, I tried using the tone measurement to measure the quantities. But using tone measurement in the same while loop is making the loop to run slow, where I am missing the samples. So I am using the Producer Consumer loop concept. Data is acquired in producer loop and analyzed in consumer loop. I am using the enqueue and dequeue to pass the data between two loops. When I am using the tone measurement in consumer loop it outputs are showing as zero ( I found the possible reason as tone measurement block require certain number of cycles to measure the data, but dequeue is passing one element at a time, but I am not able to resolve the issue). Can any one please let know how to measure the frequency, amplitude and phase of the data acquired.
I also used Buneman frequency estimator with the generated waveform, but the frequency I am measuring is slightly higher (+0.2 to +8) than the analog source signal.
Thank you in advance
Ram
03-29-2019 01:38 AM
Hi Ram,
all your data handling is based on single samples. Why do you need waveforms then?
Try this:
- read your samples in a dedicated loop.
- collect the samples in an array! (This is different than stuffing just one sample into a waveform: you still handle only one sample, with an added timestamp/dt value.)
- do your tone measurement on that array of samples!
On your VI:
- Its blockdiagram is way too big. By using AutoCleanup you could atleast get down to fit a FullHD screen in height and only need to scroll sideways…
- Using PtByPt-Buneman on a waveform is pretty senseless as indicated by the CoercionDot. You could connect it directly to your single sample coming from your SPI-handling code…
- Why do you need two "stop" buttons for just one VI?
03-29-2019 11:52 AM
Hello Gerd
Thank you for replying, I understood what you said, build 2D array using the data acquired and the dt. But I am unable to read the sampling rate, the inbuilt "MCP3008 byte block" is generating triangular (Please see waveform chart 13) wave to trigger the raspberry pi to read the data from mcp3008, but I am unable to figure out what is the data acquisition rate. One more question, Can you please showing me how can we add a constant dt value to the array.
I really appreciate your comments on my VI, I am using AutoCleanup to arrange my blocks. I will remove the second stop.
Thank you
Ram
04-01-2019 12:15 PM
Hello GerdW
I tried your suggestion of reading the samples in a dedicated loop and then using the tone measurement on collected array of samples. But still my tone measurement block is showing "NaN outputs on amplitude and phase, zero output on frequency". I am attaching the VI can you please have a look.
Thank you in advance
Ram
04-01-2019 12:39 PM - edited 04-01-2019 12:42 PM
Hi Ram,
I tried your suggestion of reading the samples in a dedicated loop and then using the tone measurement on collected array of samples. But still my tone measurement block is showing "NaN outputs on amplitude and phase, zero output on frequency".
Well, you tried, but you failed…
You still don't "collect" samples in an array: you only build an array from a single sample. Then you try to do some FFT analysis on an array of that one sample - which will error out!
You need to collect data in an array - which is a very basic task in LabVIEW involving a shift register and a BuildArray function. Did you take any of those free Training resources offered in the header of the LabVIEW board?
04-01-2019 01:24 PM
Hello GerdW
No sir, I did not take the free training resource, I found this link (http://www.ni.com/getting-started/labview-basics/) in your responses to some other question, can you please let me know if it is the correct link? I started to read about building the array using shift registers.
Thank you
Ram
using LabVIEW 2014 32 bit version on Win7
04-01-2019 01:26 PM
04-03-2019 02:41 PM
Hello GerdW
I used the shift register to build array and then I gave it to Tone measurement block. But I am getting wrong frequency measurements. Can you please have a look into the VI and let me know my mistake.
Thank you
Ram
Using LabVIEW 2014
04-04-2019 01:05 AM
Hi Ram,
so what is your intention with the VI you created?
- Now you add the very same sample 100 times to an array
- That array is kept in an uninitialized shift register: with every iteration of the while loop around you simple add ypur sample 100 times to an ever growing array…
Why don't you keep the shift register with the while loop?
Simple and clean (but far from perfect):
04-05-2019 06:56 PM - edited 04-05-2019 07:01 PM
Hello GerdW
I am able to generate the same wavefrom in the array form, but the frequency is varying. Even when I measure frequency from 1D array it is showing 67Hz, but when I measure frequency after converting the array to dynamic data I am getting 0.067HZ. I am not able to figure whats the issue. A part from all of this I am giving 60 HZ analog input.
Thank you
Ram
Using LabVIEW 2014