From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

PXI

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting data from two DMA using Python NIFPGA API

Hi,


This question is about how to use the Python API package to save simultaneously two set of data at different speed. I need for my application to save two different sets of data (different size, different type) and i'm using 2 target to host DMA. I'm using an NI FPGA 7971R card with an NI 5783 clip to measure signals. 

 

I did a simpler FPGA VI to illustrate my problem: Instead of the I/O data, I use a simple counter and the values are send to two buffers:

diagrammeFPGA.png

For the host part, i used two while loops + a timed loop to synchronize the stop condition between the 2 loops:

diagrammeHOST.png

I compiled the FPGA part and tested the bitfile. It works well with LabVIEW.

Now I want to use the LabVIEW Bitfile inside a Python interface to use my measured data to control other connected devices. I know how to get one set of data from one DMA, by example:

from nifpga import Session
import time
Time_Acq = 3000 #ms
bitfile='test.lvbitx' #bitfile placed in directory
Data_stock=[]
with Session(bitfile,"PXI1Slot2") as session:
  session.reset()
  time.sleep(5)
  INPUT_period = session.registers['Period (ticks)']
  INPUT_period.write(100)
  DMA=session.fifos['DMA_1000']
  DMA.configure(50000)
  session.run()
  DMA.start()
  t0=t=time.time()
    while (t-t0)<Time_Acq :
    Data=DMA.read(10000,timeout_ms=5000)
    Data_stock.append(Data)
    t=time.time()
  session.abort()

Now, my question is:

How can I program two simultaneous while loop in Python to get the results of the two DMA? I don't need to share the variables in Real Time from one loop to another, except the STOP condition. Should I use a multithreading approach? If so, do I have to use Python in object? I'm not knowledgeable enough about the subject and i don't know where to start. I would really appreciate some insight about how to proceed.


Thanks a lot!

0 Kudos
Message 1 of 1
(706 Views)