08-05-2013 05:56 PM
Hey all.
So I have my sbRIO board. I have hooked up the signal generator to one of my analog inputs. From here I use the analog period measurement to find the period(samples). From here I convert this sample period to period(sec) using the formula period(sec)= loop rate * sample period as stated in NI's analog period measurement VI online.. However looking at my results my frequency is always at 0.. I'm not sure what the problem is. My amplitude of the wave is right as it ranges from between 0-5V. Also I am trying to graph the signal coming out from the signal generator, but it stated that I needed a 1-D array. Can anybody help me out here? Thanks!
freqamp.vi is the FPGA target while Untilted2.vi runs the actual program
08-05-2013 08:26 PM
One problem is the way you have the shift register wired in freqamp.vi. The loop rate value alternates between something close to the tick count and something close to the iteration delay.
I have attached Frequency Finder.vi and Frequency Finder.2.vi. The first one is a simplified version of your code using only basic LV primitives. Set milliseconds to wait to about 500 so you can see what is happening. The second version subtracts the current tick count from the previous tick count. This represents the actual time for the loop to iterate.
Lynn
08-05-2013 08:45 PM
Hi Lynn, so you're saying my problem was I had the output of my subtractor wired to the shift register instead of the tick count?
08-05-2013 08:56 PM
Yes. I think that is certainly part of the problem. On the first iteration the shift register is loaded with the tick count minus 0 = tick count. On the next iteration it gets new tick count minus old tick count = ~ 100 ms. The third iteration loads latest tick count (~30000000 on my computer right now) minus 100 = 29999900. And so on.
There may be other problems but I do not have the FPGA stuff so I really cannot tell about that.
Lynn
08-05-2013 09:08 PM
I believe the loop rate problem is now fixed. It's a constant value of 100. However my frequency is still zero.
I know that period= 1/frequency. My period always tends to be such a huge number, and thus my frequency is always at 0. How can this be? Am I doing something wrong? I've got a waveform chart produced to see my graph and it certainly changes frequency whenever I turn the dial of the potentiometer on my sbRIO 9636. I've attached my newly saved VIs
08-05-2013 09:37 PM
You say that the period is a large number. Waht is the value or range of values you expect? Is it large enough that the reciprocal is smaller than the delta for the fixed point data? It appears that there are several different fixed point representations in your VI. I see coercion dots all around the frq indicator. The delta for the wire going to the frq indicator seems to have a delta of 1, so any frequency less than 0.5 will probably display as zero.
As I mentioned I do not have the FPGA module so much of this stuff is missing or grayed out. It is possible that I am misinterpretting the help files.
Lynn
08-05-2013 09:54 PM
Well what I'm doing is using my sbRIO FPGA's signal generator. I;m using the frequency and amplitude potentiometers to change the values. I want to be alble to read what my frequency and amplitude are.
My amplitude value is correct all the time. However, my frequency has always stayed at zero on the front panel. On the sbRIO there are 3 options for frequency: 0-1KHz, 0-10KHz, and 0-100KHz. However whenever I change my potentiometer the frequency on the front panel always stays at 0, when I know it shouldn't be because it should be anywhere from 1-X KHz whenever I dial the potentiometer.
Since my frequency should always have a high enough value, I was expecting the period to be somewhere small. Let's say I turned my potentiometer to have a frequency of 2KHz, then my period should be 0.0005
08-05-2013 10:10 PM
Looking at freqamp.vi, I am wondering about some things:
With a loop delay of 100 ms you only get 10 values of AI0 each second. Does it return the most recent value or does it return all values sampled in order? The former results in violation of the Nyquist criterion and the latter will eventually result in a buffer overflow.
Does the VI which determines the period accumulate data internally until it gets enough points to calculate the period? Maybe something like the PointByPoint VIs? How many iterations are required before the output valid goes True? It does not appear to have an error output, so how can you tell if it is working?
Do the values you get at period (samples) make sense for the frequencies you are putting in?
I suspect your problem is in the way you are sampling or measuring the data, but that is the part of the VI which I do not have.
Lynn
08-05-2013 10:25 PM
It should be returning the most recent values. While the waveform chart I've used should graph the values samplied in order. Can you explain to me how it violates the Nyquist frequency?(sorry just a college student who hasn't taken signal processing for about a year xD).
I've created an error output and have no errors.
08-08-2013 06:48 PM
Hi Butterwaffle,
The frequency is extremely low because you are measuring the loop speed in milliseconds. If you want the frequency in seconds, you need to divide the period by 1000 before calculating 1/period.
Also, there is a good example for using the Analog Period Measurement function in the LabVIEW Example finder called "Measuring Signal Period - cRIO.lvproj" - I would recommend compiling that code for your 9636 and seeing if it works as expected in the example VI. Let us know how it goes!