Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem trying to build daq program from scratch

Solved!
Go to solution

Hello all

 

I know this may be a trivial question by now, but I can't seem to find earlier posts describing my problem.. I feel like running in circles 😞

 

 

I am trying to build a system with an analog input and a digital output (I use the 9172 cDAQ with NI 9215 ADC and NI 9403 DIO) and I am trying not to use the DAQ assist.

But when I run the VI the chart updates very slowly even with a loop delay of 1 ms and a sample rate of 1000 and 100 samples to read.

I tried inserting a graph but that dosen't show anything at all

And depending on my sample rate (the higher fs, the quicker the error appear) I get an error saying that the samples I am trying to read is not available anymore.

I understand that something is taking too much time in my loop, but I cant see what it should be.

 

Is it possible to setup this daqmx to sample on demand?

The analog in / digital out is part of a motor controller I am trying to build, where the analog input is a motor position feedback from a potentiometer and the

digital pulses are a PWM signal to a hardware motor controller.

 

The program is running on a Lenovo T410 with 2,66GHz I7 cpu, 4GB memory, Windows 7 and LabVIEW 2009 SP1

 

Sorry if this is a duplicate post!

 

Kind regards

Tommy

0 Kudos
Message 1 of 8
(4,106 Views)

Okay

I just found out that it is the digital write function that takes up too much time.. I am not quite sure if I setup the daq correct for the digital output??

I used the tools ->  profile -> performance and memory.. And here I can see it is the digital write that uses a lot of time...

 

Any ideas ?

 

Regards

Tommy

0 Kudos
Message 2 of 8
(4,102 Views)

Hi Tombech84,

 

Can you be more specific when you say the chart updates very slowly? I have tried the VI you attached on my laptop with the similar performance as yours and it seems to run without any issues. The loops rate is around ms and I have tested with two simulated devices.

 

I have also done some modifications to your code that might improve the performance of the VI a bit.

 

Please let me know if this helps.

 

Thanks!

-----------------------------------------------------
Dennis Morini
District Sales Manager
National Instruments Denmark
http://www.ni.com/ask
0 Kudos
Message 3 of 8
(4,065 Views)

Hello Dennis

 

I am having problems with the sample rate when i connect the hardware to my computer. I found that the digital module is very slow to generate signals and as a consequence hereby the program tries to read old overwritten samples. That is what I found so far. By the graph updating slowly, it must be due to the slow digital generation, which you apparently don't see - this is odd to me... 

 

Looking forward to try out your code when i get back on Thursday.

 

Thanks a lot for your support.

 

Have a nice day 

 

Regards

Tommy

0 Kudos
Message 4 of 8
(4,051 Views)
Solution
Accepted by Tombech84

Hi Tommy,

 

I actually think one of the biggest problems is that you are restarting your Digital task inside the loop every time.  Attached is the revised code for you to try out, the loop now looks like the following:

 

 Block_Diagram.png

 

Notice the DAQmx Start is now called before entering the loop for the Digital Task.  Instead of using a Wait function, you can instead use the Samples to Read parameter so that the ratio of Samples to Read / Sample Rate is equal to the loop time that you desire (DAQmx Read will block until the appropriate number of samples have been received).  I also put the two tasks in parallel so you can now write the digital data while the DAQmx Read is waiting for the desired number of samples.

 

Simulated devices are often useful but when trying to benchmark performance it is always better to have the actual hardware.  USB in particular has quite a high latency to it; a 1 ms loop time is unfortunately probably not going to be achievable, but the exact performance is going to be system dependant.  Try running this code and see what results you can get--if you are still overwriting samples then you will have to increase the number of samples read per loop (and thus decrease the loop rate).

 

 

I hope this helps, be sure to let us know if you have any questions.

 


Best Regards,

John Passiak
Message 5 of 8
(4,037 Views)

Hello all

 

Thanks for the support, it now works like a charm 🐵

 

How is it possible to simulate the DAQ hardware? Sometimes I would like to build programs without having hardware available and then it would be nice to simulate...

 

Once again thanks!

 

Have a nice day!

 

Regards

Tommy

0 Kudos
Message 6 of 8
(3,997 Views)

Hi Tommy,

 

You can simulate NI-DAQmx devices by Right Click "Devices and Interfaces" in MAX --> "Create New" --> "Simulated....."

 

Simulate DAQmx Device.PNG

-----------------------------------------------------
Dennis Morini
District Sales Manager
National Instruments Denmark
http://www.ni.com/ask
Message 7 of 8
(3,994 Views)

Hello Dennis

 

Thanks for the help!

 

Have a nice day

 

Regards

Tommy

0 Kudos
Message 8 of 8
(3,992 Views)