LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DaqMX turn off equipment whilst sampling

Hi Guys,

              i have an applciation where i need to send an "off" signal via usb to a bit of kit and then take a number of samples with an NI usb datalogger.

 

The device has labview drivers so the comms is streightforward, I set the USB datalogger to take 200 hardware timed samples at 1kHz then i save this data to file.

 

The problem is that i need to capture the point just after i turn off the device but if i send the "off" signal before logging the data i miss it and if i log before i turn it off i also miss it.

 

I need to start logging data then whilst logging turn off the device (this requires labview to do two things at once)

 

 

0 Kudos
Message 1 of 41
(4,652 Views)

Hi Zac_Acal

 

I'm not quite sure if I've understood your problem correctly;

you want to take 200 samples as soon as your "off" signal arrives at you device??

 

If so you could just surround the code that takes the 200 samples, within a for loop to run one wich passes your boolean false strait on through the loop. this way the DAQ device wont turn off untill the samples are taken, but it will be the next thing to occour after the samples. see attached.

 

Richard 

Richard S
Applications Engineer
Certified LabVIEW Associate Developer
National Instruments UK&Ireland
0 Kudos
Message 2 of 41
(4,631 Views)

The problem i have is that the 200 samples are hardware timed, so once i trigger the samples labview seems to get tied up in that VI until the samples are taken.

0 Kudos
Message 3 of 41
(4,622 Views)

Hi Zac-Acal,

The main point about your code is that you’ve used a sequence structure for this operation. Each frame of your sequence structure will have to run until it is complete and you can’t stop it midway through the operation. This is why when you trigger your data acquisition, LabVIEW (the DAQmx Read function to be precise) will not stop until all the samples are taken.

 

LabVIEW is inherently multi-threaded and will be able to divide your code into different threads if you have them in separate loops (Please see the attached). However if you send your whole code I can look at how this can be implemented in your architecture.

 

Let me know how you get on.

Mahdieh G
Applications Engineer
National Instruments UK&Ireland
0 Kudos
Message 4 of 41
(4,597 Views)

Thanks for that, but i don't understand why labview wont simply get stuck in the top loop untill the datalogging is complete then do the next loop with the off signal ?

 

 

I have attached my full application. (the file is a .rar but i had to add the .jpg as the forum won't let me upload .rar files.)

 

Thanks, Zac

0 Kudos
Message 5 of 41
(4,583 Views)

Also where do you get the "status" control that connects the error out to the boolean ? i cant find it in the controls pallet.

 

Cheers, Zac

0 Kudos
Message 6 of 41
(4,577 Views)

My data aquisition is hardware timed.

 

I do the task once and recieve an array of 200 samples, if i put this into a while loop it will just perform this task many times won't it ?

0 Kudos
Message 7 of 41
(4,574 Views)

Thanks for sending your code Zac-Acal,

To first answer your question the “status” is extracted with an Unbundle By Name function from the error cluster. See https://www.ni.com/docs/en-US/bundle/labview/page/unbundling-elements-from-clusters-by-name.html                                                                  

The use of error clusters is advised to identify errors and also control your dataflow.

 

Can you let me know what USB devices you are using, both the NI and non NI USB module.

 

From what I understand from your post the data generated once you turn off your USB kit is most crucial to you. In order to ensure you capture that moment, you should log some of the data before the USB kit is turned off too. Please see the diagram requirements attached.

There are two methods of implementing this requirement.

 

1) Physical Hardware Connection:

IMPORTANT: This method can only be implemented if the false case that you send to your non NI USB device actually turns one of the digital lines off. If you can do this it is the best way to take your measurement.

Implementation: You need to set up your DAQmx task so that your data acquisition is triggered by your Non NI USB kit turning off. However you should buffer some of the data before the trigger as well to ensure you capture all of your required data.  In LabVIEW this is referred to as pre-triggering: https://www.ni.com/en/support/documentation/supplemental/21/ni-daqmx-data-acquisition-triggering-tec...

You can set this triggering up in MAX (as long as your device supports it). Please see attached MAX Config.

You should set your trigger source to the PFI line that will go low when you turn off the non NI USB module. You will have to connect this line on your non NI USB device to one of the lines on your NI USB module so you can read it.

 

2) No physical connection :

If the false case you send to your non NI USB is just a software command you cannot implement the above. You can wire your error terminals to ensure dataflow, i.e the non NI USB device is turned off first, then DAQmx reads the data. As I mentioned at the begining of this post you can use error clusters to control the flow of your data. However you might have to increase the number/rate of samples you read in order to make sure you capture all of your required data. Please see attached Software Config

 

 

You can improve your main VI  by using the state machine architecture:  https://www.ni.com/en/support/documentation/supplemental/16/simple-state-machine-template-documentat...

Since you need to respond to your front panel controls you can use an Event Structure in your state machine.

 

I hope this helps you. We also run training courses in our branches to help our customers in using LabVIEW, please let me know if you would like more information on this.

 

 

Mahdieh G
Applications Engineer
National Instruments UK&Ireland
Download All
0 Kudos
Message 8 of 41
(4,527 Views)

Thanks for that,

 

I'll give that a try (controling data flow with error wires).

 

There is no connection between my logger and load unit, ie the "off" signal is just a software command.

 

I used the sequence structure to try and ensure the load unit is switched off, then the data logged, the problem is that by the time labview comes out of the load unit communication VI and moves onto the datalogging part its too late to catch the data i wan't.

 

If i start the logging first, labview stays in the logging VI until it has 200 samples then moves on to switch off the load unit.

 

I want to send the "off" command either at the start of the data logging or just after and effectivley perform them at the same time.

 

Oh the NI usb logger is a USB-6210 and the non NI usb device is a kikusui PLZ load unit.

 

Thanks Zac.

 

 

 

0 Kudos
Message 9 of 41
(4,518 Views)

Hi Zac_Acal,

Am I right in thinking that you want to log a bit of data after you have just turned off the apparatus that you were using to log data in the first place?

This seems like a difficult operation to complete. I would suggest using a seperate USB datalogger to record the data when the other one is turned off (triggering between the two).

Kind Regards,

John McLaughlin
Academic Account Manager
National Instruments UK & Ireland
0 Kudos
Message 10 of 41
(4,511 Views)