LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FPGA max value from DMA FIFO within data collected

Hello community.

 

Currently I am developing a system that is a data collector using a NI9234 and FPGA. One of the things that I want to do is once I have collected a measure and I pass through FFT module, I want to obtain the MAX value of them.

I'm not sure that my VI is doing correctly the MAX.

Let me give you some keys about the code.

In the first window (below) you see the code where the NI9234 module realice the read of one channel. Once the read have been made I pass the signal through two filter high-pass and band pass. And I write the signal into a DMA FIFO in order to pass this data to another time sequence loop, which is below.

DAta collectorDAta collector

In the image below you see the time-sequence loop where a reading of the FIFO is made  and a FFT is performed once the FFT has been made a square norm is calculated. All of is aimed in order to get the maximum value of the FFT. 

FFT_SQNORMFFT_SQNORMIn the image below that is in another while loop a FIFO read is made in order to find the maximum value.MAXMAX

All of this code is programmed into the FPGA part of the sbRIO-9627

Should I put this code into a flat sequence structure?

Is there any advice or example where the max value in the FFT into the FPGA is calculated?

I am stuck with this and I am not sure if I am doing correctly.

Attached is the example.

0 Kudos
Message 1 of 9
(2,665 Views)

Hi,

I have not checked the logic or details much, but will share some thoughts on the first impression:

1. The FFT node in SCTL takes a few cycles to start generating valid output samples, hence you should wire the FFT output terminal 'Output Valid' to the input terminal of the downstream node  Norm square 'Input Valid'. Similarly the Max_5k and Max_3k FIFOs should be written only when this Norm Square node produces valid samples, ie, when the output terminal 'Output Valid' is true.

2. The output terminal 'ready for input' of any downstream node should be connected to the input terminal 'ready for output' of the immediate upstream node via feedback node. (Eg: Output of NormSquare to the input of FFT).

3. You seem to be attempting to perform the Max calculation for the number of times the elements in the FIFO (Eg: Max_3k). But you are not reading the FIFO that many times. The FIFO is read only once and the for loop iterates with the same input data each time.

 

Arun
0 Kudos
Message 2 of 9
(2,599 Views)

Hi,

 

4. Why don't you use the MinMax function?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 9
(2,593 Views)

I will check this ideas.

 

The idea 1 and 2 I think there are implemented already, but I will confirm.

 

The idea 3 I will review to make some changes based on your tip.

 

Thank you

0 Kudos
Message 4 of 9
(2,580 Views)

@ArunJ Are you suggesting to perform the reading into the For loop to receive new data in each iteration?

 

My idea is to get the max value of the square norm in each FFT iteration.

 

 

0 Kudos
Message 5 of 9
(2,552 Views)

@GerdW  ha escrito:

Hi,

 

4. Why don't you use the MinMax function?


Could I use into the for Loop in each iteration instead of a comparation? I would like to compare the entire fifo not each value.

0 Kudos
Message 6 of 9
(2,546 Views)

For finding the Max value in each iteration, you need a new sample every iteration.Hence you should read all the samples that is written into FIFO (using a loop), along with calculating the Max value.

But in the present code, it doesn't happen because the this FIFO is read only once, irrespective of the number of elements in it. And the FOR loop executes the Max value calculation on this single element, through all the iterations.

Arun
0 Kudos
Message 7 of 9
(2,535 Views)

@ArunJ  ha escrito:

For finding the Max value in each iteration, you need a new sample every iteration.Hence you should read all the samples that is written into FIFO (using a loop), along with calculating the Max value.

But in the present code, it doesn't happen because the this FIFO is read only once, irrespective of the number of elements in it. And the FOR loop executes the Max value calculation on this single element, through all the iterations

 


 Understand.

I keep fighting with this problem, Labview isn't trivial. Maybe cause I'm still thinking more in software programation than hardware.

 

Finally I discarded the FFT and NormSquare, cause I discovered that I don't need it. but I'm still needing find the max value inside of the FIFO and when I find it, send it to a host or write into another fifo with the max value.

image (1).png

 

As you can see in the upper loop I have a selector that is activated when a FIFO time Out? variable is true in that case I write 0 in each input of the Max node to reset the maximum on the other hand if is False I compare the previous value with the actual value.

 

My idea is only send the max value once the FIFO is sent to the host computer.

 

0 Kudos
Message 8 of 9
(2,496 Views)

Finally I finish the program. With a satisfactory solution, it's a very tricky but it works properly.

 

I leave it here to help the community.

 

First of all I have four selector in which in one entry is one of the values that I want to compare, and the other is the previous max value and in the others there are a Zero value that comes from the previous value.

The ? selector is if the FIFO is full or not, if is not I select the value that I want to compare once the value is True, enter into the time sequence, where I have two indicator for the two maximun. In a second sequence I have put a wait module with 5 ms, enough time to make the reading from the host and in a third frame I have a zero value to reset the maximum in each iteration.

 

Is someone need I can show you the VI.Max values.JPG

 

0 Kudos
Message 9 of 9
(2,481 Views)