LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

upgrading multithreaded program to DaqMx

I am trying to upgrade a program that I wrote with traditional nidaq to daqmx and need some general advice. The purpose of the program is to analyze cardiac signals (presently only on one channel) during ventricular fibrillation and to respond to those signals in as close to real time as possible with an analog pulse train. The pulse train is delayed by a calculated amount and has a cycle length that depends on the measured rate of the cardiac signal. My approach was modeled after the daq multithread example program daqMT and basically displays the data in a stripchart in the main thread and acquires and processes the data in a second thread. In order to maintain a psuedo real-time environment, I am using the easy i/o function AICheckAcquisition() in a while loop in the data acquisition thread to determine how many points are in the internal circular buffer that was set up by the function AIStartAcquisition(). I then use the function AIReadAcquisition() to read a single sample of data from the circular buffer whenever the lag is 1 sample. In this way, I can maintain a real time enviroment and respond to the measured cardiac signal within about a millisecond or two. I am using a 1 to 2 kHz sampling rate, so it is not difficult for the analysis to keep up with the incoming data. The program works fairly well, but once in every twenty or thirty runs at seemingly random times, I get a blue screen and the computer reboots. I have spent alot of time trying to diagnose this problem with no luck. It has been suggested that this is a problem with the multithreading. I thought that since the new daqmx driver was "multithreaded" and supposedly faster that I would rewrite the program using this driver. (Also I just want to learn how to use the new driver). The problem is that I am not sure how to implement the equivalent AI_CheckAcquisition, etc. functions using the new driver. Any general thoughts/ comments on how I could do this. Also, since I don't really consider myself a programmer, any advice on how I am implementing this program in the first place would be welcome. Sincerely, Philip
0 Kudos
Message 1 of 2
(2,970 Views)
I think that the function you are looking for is the DAQmxGetReadAttribute (handle, DAQmx_Read_AvailSampPerChan, &avalSamples, 1000); The DAQmxGetReadAttributes can be used to return information about the read such as the available samples, number of channels, total read, etc. After finding how many examples are available you can call the DAQmxReadAnalogF64 function. Take a look at some of the shipping examples like: C:\Program Files\National Instruments\CVI70\samples\DAQmx\Analog In\Measure Voltage\Cont Acq-Ext Clk-Dig Start

I hope this helps.

Joshua
0 Kudos
Message 2 of 2
(2,970 Views)