LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using multiple outputs on NI USB 6229

Solved!
Go to solution

Hello,

 

i have a question about using multiple outputs (inputs) on NI USB 6229. I am programing application where i use some digital outputs, some digital inputs, some analog outputs and inputs. Initialisation of all ports i have in one subvi which is in one for loop and i am controling parameters from another for loop using notifications. Problem is that setting this outpust is really slow (or reading inputs), i mean in my main loop i switch button but it takes at least 1s to change my outputs (same with reading inputs)? So i am wonderig what i am doing wrong. Can you plesae tell me what is the best way how to control multiple different ports?

 

Ok  so my whole program structure is like this:

 

In main Vi i have one loop which control subvis in other loops. One of this subvi is subvi whichchange some parameters in initialisation subvi. Whole structure in on the picture. Please help me because i really dont know where is problem. I am using two more AD/DA converters and some machines which i am controling using RS232 but this original NI is the slowest one.

 

PS. If i turn on only parameter subvi in loop everythinf is much faster.  

 

Download All
0 Kudos
Message 1 of 7
(3,286 Views)

Hi,

 

My first recommendation is that you should create a new VI and narrow the problem. In the new VI you should just put 2 DAQmx task, one for the reading and the other for the writing. Please find these links for help:

- Building Analog Input : http://zone.ni.com/devzone/cda/tut/p/id/5370

- Building Analog Output : http://zone.ni.com/devzone/cda/tut/p/id/5371

- Simultaneous analog input-output: http://zone.ni.com/devzone/cda/tut/p/id/2903

 

My opinion is that your DAQmx loop is slow, because you are using software timing. The loop time will be specified by the slowest task in the loop. While your write task is fast (it has to push the data into the buffer on the card), the read task takes longer time, because it has to wait for the samples (time=(1/sampling rate)*(samples to read)). The loop time will depend on the reading task.

 

Recommendations for improving you code:

- In the main loop use 'local variables' for communicating between loops instead of notifiers. Now, you have to stop the upper loop for passing data to the other loops. In is not the best practice. http://zone.ni.com/devzone/cda/tut/p/id/7585

- Put the DAQmx Task Initialization out of the loops. You should initialize DAQmx Task when you main program starts and destroy them when your program finishes. You should Start them before the loop. In the loop you should just put the Read and Write VIs. Remove the DAQmx Start VIs from the code as we can see in the initialization.jpg.

- I did not see the correct DAQmx initialization in you VIs. Please find the links above and put DAQmx Create channle and DAQmx Timing into you DAQmx initialization procedure. I also could not see the Rates for your DAQm tasks, it is important to know/calculate the reading time.

 

You code is a little bit messy. Your program would be pretty in a State Machine architecture which is Event Driven: http://zone.ni.com/devzone/cda/tut/p/id/2926 . You shouldn't use many notfiers just control the states.

 

I hope these will help you.

 

Regards,

Peter

 

Peter Vago
0 Kudos
Message 2 of 7
(3,250 Views)

Thank you very much, this will help me really lot. I will take all your recomendation and chage all program. Anywat reason why i am using so much notifiers is that i want controll other loops from one main loop and second reason is that i want to record all data from all loop, so i think is necessary to send data to the main loop.

 

Next reason why i dont have "correct DAQmx initialization" is that i create tasks in MAX (Measurement and Assistant) and in LabView i only conect to this chanels. But ok i will create all task in my program and try to do this correct. After that i will say you if it is working or not.

0 Kudos
Message 3 of 7
(3,243 Views)

Ok i have one problem more. Right now i am trying create digital outpust/inputs. Problem is that i cant find how to do it correctly. This tutorials are only for analog I/O and that is little bit different.

0 Kudos
Message 4 of 7
(3,237 Views)

Ok i loked in DAQ assistant and i think i dont need any timing because i need only one sample every loop (1 sample on demand).

0 Kudos
Message 5 of 7
(3,233 Views)

Ok i found problem and dont know how to solve this. Now I think that there is nothing wrong with multiple tasks on NI USB 6229, but something is deffinitely wrong with multiple for loops in one VI. I made really simple program (and because i dont know how to exactly create task to NI USB 6229 i used DAQ assistant). So in this program i have two for loops. In frst for loop i read data from two serial ports and in second loop i try to write data into NI USB 6229 (daq assistant - 1 sample on demand for digital data). When i start this program this loop which read data on serial port run really fast but loop which send data to NI 6229 make one loop per second (or slower). So ok i tried stop only lopp for reading from serial port and the other loop accelerate at least 100x. This is not normal i think, have you any idea where is problem? And anyway why is sending data to NI USB still so slow even without loop for reading on serial port, the other loop stil makes only 100 loops per second. Picture of my program is attached. 

0 Kudos
Message 6 of 7
(3,228 Views)
Solution
Accepted by topic author BMAJTZ
0 Kudos
Message 7 of 7
(3,211 Views)