LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx triggered logging of finite samples

Solved!
Go to solution

Hello again,

 

Still struggling with DAQmx acquisition.  I was playing around with using digital inputs to start and stop the acquisition, as well as flag certain points within it. Non-stop errors around how I am reading/buffering the data. Still need to get my head around exactly what's happening there. It would be great if the function help was more explicit. Anyway…

 

I’ve whittled it down to what seems very simple. There are two digital inputs: Weld Cycle Start, and Part Contact. I am using the first as a start trigger, and the second as a reference trigger to aquire 4.5s of data after contact, and 0.5s before.

 

I want to create a new file and log this data directly to it. Don’t care about reading or displaying – we can do that later – just need to capture it on the hard drive.

 

My specific questions to the group are:

  • Should this work as is?
  • Could it be better?
  • What’s the most efficient way to repeat this every 15 seconds?
    • I was thinking of making it a sub vi within my operator interface vi and calling it on initialize, waiting until it was complete, then calling it again.
    • Alternatively, I could put part of the acquisition inside of a loop, but that’s where I get really confused… What should the loop contain?

Learning hurts, but giving up is not optional…

 

Thanks in advance for your help!!! Kudos will go to the solution, I promise!

Download All
0 Kudos
Message 1 of 11
(3,717 Views)

Hmph Smiley Indifferent...  Not much help.

 

There is very little info available for logging...  I'm still waiting for some BNC pigtails so I can connect my triggers and actually test this, but I did run it and it times out on the "wait for task to complete."

 

I removed that, and the query task complete.  Now it just runs and stops.  Why doesn't the "start" wait for the trigger?  This would make more sense if the trigger had a wire I could connect to the start task vi.

 

99.999% of DAQmx examples include a read function.  What if you don't want to read?  Do you even need to start the task? 

 

I'm still lost, but I'll figure it out.

 

0 Kudos
Message 2 of 11
(3,668 Views)

Hello greyhorn,

 

You will need a read function in order to complete this task.  There are a few examples that you will want to reference to accomplish this task.  First, take a look at "simple queue.vi" to show you how to write every 15 seconds.  Another helpful example to look at is "Voltage - Continuous Input.vi."  This shows proper formatting for reading and writing data.  Between the two examples, you should be able to perform the tasks you are wanting.  Hopefully, this gets you going in the right direction.

 

Regards,

John R.
National Instruments
0 Kudos
Message 3 of 11
(3,648 Views)

Hi John!

 

I appreciate your response.  I'm going to latch on to you like a drowning man here... 🙂

 

You said I MUST have a read function.  Okay, that helps.  I was confused about what the "read" actually did. I thought it was for displaying data on the front panel.  I was confused by the DAQmx help, "Log data only. For very high-speed acquisitions, logging and reading data can slow performance," and several example block diagrams that did not include the read function... 

 

Can you speak to that?

 

Looking at the "continuous voltage" example, I assume I would just leave the "data" out terminal unwired since I don't care about displaying, only logging? 

 

Also, in the "finite voltage" example, the read function is not inside a loop.  I'm doing a triggered finite measurment, not a continuous measurement -- so I should follow the "finite voltage" example, correct?

 

And in that case, can you suggest or point to a nice way to run this task again without having to call a sub vi?  I think I would need a while loop somewhere, but I'm not sure where (again, referring the the NI example for finite voltage).

 

I did find the "simple queue" example, but it was way above my head.  However your comment "write every 15 seconds" is not precisely what I want to do.  The machine has a 15 second cycle time, but I need to trigger the aquisition with the start of the weld cycle, not time.  The time varies slightly, there are machine faults, etc.  I want to aquire when triggered, log it to a file, then wait for the next trigger -- even if that takes hours or days. 

 

I will keep working, but if you could respond to my questions, that would be a tremendous help!

 

 

0 Kudos
Message 4 of 11
(3,641 Views)

Oh, and one more question regarding the examples:, if you don't mind?

 

The case structure with "trigger type" has the option of using a start trigger or a reference trigger.  IAlthough I can't find it at the moment, I was under the distinct impression that you could not use a reference trigger without a start trigger before it. 

 

Can you please confirm or deny that as well?

 

 

0 Kudos
Message 5 of 11
(3,637 Views)

DAQmx read reads the task that you created. If you don't read the task, all you will be doing is creating a task with trigger conditions and then never reading the task to get the data that is there.

 

The data terminal from DAQmx read needs to be wired to a file I/O vi. Without the data wire connected to anything "DAQmx read" will read the task but the data won't be stored anywhere.

0 Kudos
Message 6 of 11
(3,629 Views)

Thank you, Sir.  I follow that. 

 

I noticed the "configure logging" creates a file -- I would then use "tdms open" to open it, "tdms write" to fill it, and "tdms close" to close it, correct?

 

What does the "configure logging" actually do for me, then? 

0 Kudos
Message 7 of 11
(3,622 Views)

Ah, I missed the configure logging vi in your code. I haven't used this VI before, but I believe you need the DAQmx read before the configure loggingthen it should log the data to the TDMS file that it creates.

 

Edit: It looks like you do not need a DAQmx read VI unless you need access to the data. I think your problem might be that you have the configure logging VI before you have the Start task VI. Try putting the Start task VI before the logging VI and see what happens.  You can also check out the help for the Configure Logging VI for more info.

0 Kudos
Message 8 of 11
(3,617 Views)

Ah, here's an example right from NI website RE: the new .tdms file format.

 

No read function.  I'm going to try and copy this but use finite measuring and a trigger.  We'll see what happens.

 

RE: the start/reference triggers -- I beleive the example vi's are wrong, at least for my hardware.  I remember now trying to use a reference trigger only and it threw an error telling me I had to have a start trigger before...

 

 

0 Kudos
Message 9 of 11
(3,606 Views)
Solution
Accepted by topic author greyhorn23

This works.  Thanks to all who tried to assist -- but no Kudos this time 🙂

0 Kudos
Message 10 of 11
(3,588 Views)