LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need consistent triggering

My apologies if this question has been answered elsewhere, but I was unable to find exactly what I need (perhaps I am asking the wrong question).

I am trying to use two Digital Line Inputs to trigger different states in my LV program.  I'm controlling 3 mass flow controllers using the analog outputs on my PCIe-6259.  I use these Digital Line inputs to trigger 3 different states - off, flowrate 1, flowrate 2  (preflow and cutflow on block diagram).

The problem I am having is that the triggering is inconsistent.  Sometime I get no preflow, but cutflow will work fine...other times preflow works and I have no cutflow.  Every day I turn on the system and some days I get what seems like consistent triggering, only to be let down later.

I had written an earlier version of this program that worked very well with a DAQcard-6024E using Traditional NI-DAQ, but I am new to DAQmx and the DAQ assistant - and the PCIe-6259 doesn't support Traditional NI-DAQ.  In my previous program I had used the Read From Digital Line.vi with flawless results (and so simple).  Now I'm trying to use the DAQ assistant (#2 on the block diagram) and the results are inconsistent.  I have it set up for 1 sample, on demand.

Any help to point me in the right direction is much appreciated.





 PlasmaGuy


0 Kudos
Message 1 of 3
(2,665 Views)
Hello PlasmaGuy.
 
Thank you for contacting National Instruments. 
 
I have a few recommendations on how to improve your code in order to make it more reliable and predictable.  First, the reason that you are seeing one of the write tasks work while the others do not work is because there is a race condition determining which DAQmx write VI executes first.  This is because there is no dataflow specified from one case statement to the next.  Thus, depending on which case statement is executed first (which is not determinant), a different case will execute and thus a different DAQmx write will execute.  This, coupled with the fact that only one DAQmx write task can be running at the same time on the same board, is what is causing either your preflow or cutflow to work while the other one doesn't.  So, before you execute a second DAQmx write task, you must first stop the preceding DAQmx write task. 
 
Secondly, I would recommend only using the DAQ Assistant Express VI or only using the lower level DAQmx VI's.  For this application, I would recommend using the lower level DAQmx VI's since they give you a lot more control over what happens in your application.  When you use DAQmx low level VI's and the DAQ Assistant Expres VI, there can be complications related to this differing level of control that you have over the VI's. 
 
Third, I would recommend looking at a few resources that will get you more familiar with DAQmx and the functionality that it offers.  The common series of events that should take place for a successful DAQmx task is 'DAQmx Create Virtual Channel', 'DAQmx Timing', 'DAQmx Start Task', 'DAQmx Write/Read', 'DAQmx Stop Task', 'DAQmx Clear Task'.  Following this order will help with proper dataflow, execution, and correct termination of the task.  More information on each of these VI's can be found at:
 
Learn 10 Functions in NI-DAQ and Handle 80 Percent of Your Data Acquisition Applications 
 
Two helpful links that will help you in your transition from Traditional DAQ to DAQmx are:
 
Answers to Frequently Asked Questions about NI-DAQmx and Traditional NI-DAQ
 
Transition from Traditional NI-DAQ to NI-DAQmx
 
Also, there are numerous shipping examples that come with your version of LabVIEW.  These can be accessed by selecting 'Find Examples' on the LabVIEW splash screen that launches at startup.  Then, please choose to Browse according to 'Directory Structure' instead of the default 'Task' selection.  Then, a folder named 'DAQmx' will be viewable on the main Example FInder window.  Inside of this structure is a large number of example programs that will help you more familiar with DAQmx and the structure it follows. 
 
I hope this helps you with your application.  Let me know if you have any additional questions or if any of my statements require further clarification.  Good luck with your application and have a great day!
 
Brian F
Applications Engineer
National Instruments 
0 Kudos
Message 2 of 3
(2,641 Views)
Thank you, Brian F. for your helpful post.  I will certainly be digging into those links as I will undoubtedly need a better understanding of DAQmx for future projects already on the horizon.

I was able to resolve my problem with this program.  Interestingly enough, I have not had any problems with the DAQmx write.vi tasks in those case statements.  The main conflict was having two DAQ assistants in that while loop.  I resolved this by stopping my use of digital line i/o (although in retrospect, this may not have been a necessary change), using analog inputs instead, and just using one DAQ assistant to read all the signals.  I have been running this program with solid, repeatable results for the past 2 days.

Here's what I ended up with:

link to photo

Thanks again for your help and happy holidays!

PlasmaGuy
0 Kudos
Message 3 of 3
(2,626 Views)