06-19-2023 01:05 AM
Hi,
I'm writing a LabVIEW FPGA code for my PXIe-5774 that:
takes in 4096 samples of data
-> calculates an fft of it
->stores it to bram
-> takes another sample and adds that fft value to the previous value on bram
-> does that 10000 times (windows are taken at 10 kHz -> adding takes around 1s)
-> when that is done the values are sent to the host vi and displayed to me
and the whole process is repeated.
My problem is that my code only manages to do the 10000 ffts added together once. When I run my fpga code through my host vi, I see the first fft come through fine but the next ffts are THE EXACT SAME SPECTRUMS. The values that the fpga streams are exactly same every second. Even weirder. When I rerun the code, the previous data is still sent to me and it doesn't update no matter how different the input signal is. The vi still runs and sends me a sample every second or so but it is always the same sample.
Only when I wait enough time when the fpga is not executing code or sometimes if I run a different code, is the spectrum calculated again and a new sample is sent to me.
What am I doing wrong? Is the fault in storing the data to bram wrong or is my streaming somehow messed up? Why is it that I can update the bram memory 10000 times but when I suddenly stream the data, I can't update it anymore?
As you can see from my code I am flushing the memory with zeros right after I have read the data so in theory the bram shouldn't remember the previous spectrum after the streaming. Right?
The folder with the fpga vis is attached. The main vi is PFGA_main_v_0.6.2.vi
Thanks:
Aarni
My code from left to right (The streaming code on the right is taken from Example Finder -> Hardware input and output -> Integrated IO -> Getting started and I know it to work):
Solved! Go to Solution.
06-19-2023 01:26 AM
Update:
It seems that the fpga code is not a fault here. I tried to run the same code on a different PXIe-5774 target and the read stream vi still gave me the old spectrum. The samples come at 1Hz when I have the trigger pulses coming to the fpga and stop when the trigger stops. The samples that I am receiving are always the same when I use the Read Stream 2d I16 configuration on my host vi but change when I use the Array of waveforms configuration. Why does the Read Stream 2d I16 not work correctly?
Thanks:
Aarni
06-19-2023 01:37 AM
No need to bothwer with this question. I was just being really stupid and not resetting the shift registers on the for loop.
Thank you for this community for bein nice...
Aarni
06-19-2023 10:38 AM
Speaking only for myself, I've never (well, since about an hour ago) made such a silly mistake as forgetting to wire a Shift Register. Sometimes all it takes to find our silly mistakes is to "explain the code to a colleague, even if they know nothing about LabVIEW or Programming", the idea being it forces you to "slow down" and as you say "and here we do such-and-so", you involuntarily look at the code and say "Oops, that *@*%%!!& Shift Register is not initialized properly!"
You get "extra points" for having the courage to post a "broken VI" and finding the problem yourself.
Bob Schor
06-19-2023 10:56 AM
Yes, the "rubber duck" method works wonders most of the time. I have often looked at my code for hours without finding what is wrong and when I start to write a post about it, I immediately notice what is wrong.
I'm just very new to LabVIEW FPGA and when something doesn't work, I automatically assume that the FPGA code is wrong. Because it usually is and it's harder to find what is wrong with it. I just assumed I didn't understand BRAM properly... Sometimes it is the noob mistakes that get you. (Not to say that I am not a noob...)
Thanks
Aarni