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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer-Consumer Mode, TDMS Log and Continuous Acquisition

Solved!
Go to solution

I created a event-based VI to control the parameters of the DAQ. I created a producer-consumer queue to log to TDMS file in the consumer loop. 

 

Question 1: Why do I have to pass DAQmx TASK across each defined event? If I dont do that, I get DAQmx task error. 

Question 2: Do I have to pass QUEUE from each event? If I dont do that I get error in the TDMS file close (consumer loop)

Question 3: When I am reviewing data file, I get errors manily linked to consumer loop in the TDMS file close. Since there is no element in the QUEUE why should I get this error.

 

Please advice.

 

Thanks 

RY
0 Kudos
Message 1 of 10
(3,457 Views)

Well, some code would help us visualize what is going wrong but I'll risk "Troubleshooting the general case" (Not always effective- bear in mind I can only point to common causes that may have no points in common with your case)

 

Question 1: Why do I have to pass DAQmx TASK across each defined event? If I dont do that, I get DAQmx task error.:  You most likely put the Task on a shift register an left the event loop output tunnel set to the default "Use Default if unwired" which, of course, is Not A Task.  See Q2 too

 

 

Now the big question  Why are you passing DAQmx Data to a consumer loop rather than letting DAQmx Log to TDMS for you?  Look at DAQmx Configure Logging (VI) on the DAQmx Advanced functions palatte


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 10
(3,447 Views)

I have the code here at http://forums.ni.com/t5/LabVIEW/How-to-dynamically-program-the-DAQ/m-p/2728795#M807588

 

If you see this code, I am passing the DAQmx TASK from each defined event. If I dont wire any event, I get DAQmx error. Exactly same thing happens with the QUEUE too.

RY
0 Kudos
Message 3 of 10
(3,443 Views)

I don't see a producer/consumer in that code.  But now on to your questions.

 

1.  You have to pass the task out of each event case or else you will lose your task reference.  Data flow 101.

2.  If you are using a shift register, you do.  The queue you can probably get away with not using a shift register with since you have to set it up before the producer or consumer loops.

3.  Need to see actual code for this one.

 

But I will reiterate what Jeff said (which was my original thought when reading your post), why not just use the Configure Logging VI in DAQmx.  The logging will all be done for you.  You just have to tell it where to put the data.  No need for the producer/consumer with that.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 10
(3,424 Views)
Solution
Accepted by VEEDAY

That is certainly not how I would start to put a Soft Front Panel together for a AI Task.  Let leave file logging asside for the moment (As, mentioned that's actually very easy to add later.)

 

As Food for thought- and because creating a SFP really does involve thinking a bit differently from where you started- I whipped up a "Start" of a SFP.  It also demonstrates how to create a simple API around a "Resource Module."   (Just a natural extension of an "Action Engine - If you haven read the community nugget it is always a good read. http://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/m-p/503801)

 

What I zipped is not complete- but you should get an idea of what to extend and where.  You might even get there quicker from here than where you are now.Smiley Wink

 

Taking an approach like this can really help when you go to unwind problems like you mention in your code where you fail to pass around information that the GUI really can't make use of anyhow and DOES NOT NEED exposed at that level.  the "Computer Science" Guys will use terms like "Data Hiding", "Functional Abstraction" and "Encapsulation." 

 

The snip below is meant to tease the project so others can get the idea of the code-  (Sorry no LAVA CCT Today! Smiley SadSmiley Frustrated)

!0.png


"Should be" isn't "Is" -Jay
Message 5 of 10
(3,414 Views)

Thank you Jeff. Your code is good starting point to recode. I am using queues to perform several tasks, like logging, processing and display. Since we want to achieve them all in parallel, I got some help from forum to use QUEUES.

 

I will update you if I face any problem.

 

Thanks

RY
0 Kudos
Message 6 of 10
(3,389 Views)

Jeff,

 

I am facing two minor issues. 1. How do I send AI.PhysicalChannels to the Channel List (DAQmx Read)? 2. I am unable to send the voltage range to sub-vi for configuration. Any pointers????

 

Many thanks in advance.

RY
0 Kudos
Message 7 of 10
(3,372 Views)

@RYADAV wrote:

Jeff,

 

I am facing two minor issues. 1. How do I send AI.PhysicalChannels to the Channel List (DAQmx Read)? 2. I am unable to send the voltage range to sub-vi for configuration. Any pointers????

 

Many thanks in advance.



1.  you had a sub vi that converted an array of selected chanels to a DAQmx Channel string.  just pass that string into AI Configure.  You might want to seperate out the single Configure case to Configure Chanels, Configure Range and Configure Timing.  It depends on how you want the code to eventually work.

 

2. I used a ring of type dbl Your enum and lookup would work as well.


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 10
(3,364 Views)

Thanks Jeff,

 

Actually I was thinking if there was some direct solution. I have disabled the two variables and introduced two new variables to accomodate physical channels and range.

 

Thanks

RY
0 Kudos
Message 9 of 10
(3,357 Views)

@RYADAV wrote:

Thanks Jeff,

 

Actually I was thinking if there was some direct solution. I have disabled the two variables and introduced two new variables to accomodate physical channels and range.

 

Thanks



Hey, it was a framework-  use it however you need it... Glad to have helped


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 10
(3,353 Views)