Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Averaging on FPGA target

Hardware: PXIe - 7972R, IO Module NI 5782

 

Hello guys,

I've a problem and no idea how to overcome it. I've tried many things but nothing really worked so yeah. So the NI 5782 has 2 AI and what I want to achieve is to average some hundreds of thousands of points over many periods for each of the channel. So to say, aquire 100 000 points wait for some trigger and then add the next 100 000 points and so on for many periods. At the end send the data to the host vi and there i should be able to divide by the number of periods. It should be easier to implement the division on the host vi, since it doesnt matter where the division happens and it is better for resource usage on the fpga.

 

So are maybe someone can help me with some tipps. Should I use an array/memory, how to send so much data to host, etc?

 

Thanks a lot!

0 Kudos
Message 1 of 13
(3,229 Views)

Is it really necessary to wait until "the end" to transfer all the data to the host? If so, you could leverage the Dynamic RAM of the card. The 7972 features 2 GB of DRAM, that should be enough for 5000 periods (2 channels x 100000 samples x 2 bytes (14bit on the 5782?)). And if you have not worked with DRAM yet, we published a code sample last year showing the basics of DRAM for our NI Week 2017 presentation. You can find it at https://gitlab.com/hampel-soft/accelerate-with-ni, look for the "Measurement Data on FPGA" example.

 

That being said, why not transfer each batch or block of 100000 samples to the host right after acquiring it? 




DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (The Future of Team-Based LabVIEW Development)


0 Kudos
Message 2 of 13
(3,219 Views)

First of all thanks a lot for the response. I'll check the code you posted about the DRAM basics.

So I actually want to process the data further after averaging it. I already aquire and stream the raw data on the host, but I want to average it on the FPGA and send that to the host as well. 

0 Kudos
Message 3 of 13
(3,211 Views)

You can find a bram based multi record average processing block in FIDL (FlexRIO Instrument Design Library). 

https://forums.ni.com/t5/NI-Labs-Toolkits/NI-FlexRIO-Development-Tools/ta-p/3517734

The example that you'll want to take a look at it is <LabVIEW>\examples\instr\FlexRIO\FlexRIO Building Blocks\573X\Simple\Getting Started With Configuration.lvproj. That project will have a target labeled 'Simple Processing Engine' that demonstrates how to use the processing block that uses bram to implement a multi record average. 

 

If you want to do DRAM based multi record averages, which you probably do since your records are thousands of samples long, there is an unpublished VIPM example that demonstrates this. I've attached the .vipm file that will allow you to install it via VIPM. 

 

Message 4 of 13
(3,188 Views)

So I've tried out some things on the fpga and got something that is working but I'm pretty sure that this is not the right way to go. So I've implemented a LUT to add the data on it for some periods (average nr) and then send it to the host and divide it there. I've uploaded the code so you can take a look at it. Could you help me out to implement the DRAM here, to add up like 200000 points for some period and then send it to the host? It's not that trivial for me, since the DRAM has to work in another clock domain and so on..

 

Also maybe you could help me here with the timing error as well, since the module has 2 CLIPS, one which aquires only one sample every 4ns, the code needs some adjustment to make the code work within that 4ns - for testing the code im using the multi sample clip  to increase the sctl time to 8ns to make it work.

 

Thanks a lot!!

0 Kudos
Message 5 of 13
(3,131 Views)

Matthias, I sent you a PM.




DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (The Future of Team-Based LabVIEW Development)


0 Kudos
Message 6 of 13
(3,120 Views)

It would be amazing, if anyone could help me with this!!

Thanks!

0 Kudos
Message 7 of 13
(3,096 Views)
it seems to me you just need a some shift register and simple adding function. what's part makes you feel hard?
0 Kudos
Message 8 of 13
(2,961 Views)

Hello, so what I want to achieve is something very similar to this:

 

http://www.ni.com/newsletter/51467/en/

 

I'm still working on it, tried many things with the DRAM but it is a big challenge for me (initializing the dram, multirecord on it, add stuff on it and so on). So if anyone still here could help me, I would appreciate it a lot!!

0 Kudos
Message 9 of 13
(2,928 Views)

Say that you need a moving avg function, it is relative simple.

 

First of all, you need add certain amount of element,  then you only need add the last element, minus the oldest element, and keep the output for next cycle...it should be able to get a output every cycle.

 

So you'll have a deep ram-based shift register, luckily you can find these on xilinx ip panel.

 

 

0 Kudos
Message 10 of 13
(2,907 Views)