LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

extract device from physical channel

Solved!
Go to solution

As always I want to do something absolutely trivial and am running into all sorts of issues

 

I define (through a control) a physical channel that I want to take data on. I want to be able to programmatically reset the device the channel is on. i.e. i don't want someone to have to open up the code and change the device on the reset vi if necessary. Even if there is only one device physically connected, you can’t guarantee the device will be Dev1, because Labview keeps a history of devices that have been plugged in. The obvious solution – extract the device name from the physical channel control which contains the channel(s) you have selcted. Can I find a trivial way to do it, NO!  There is a property node called device but it does not (despite its name) return the device you have selected along with the physical channel.  There are convoluted ways of doing this, but i'm hoping there is some easy way. Suggestions

0 Kudos
Message 1 of 6
(3,361 Views)

Hi!

Use a DAQmx Task Property Node and select "Devices" property.

This gives you a list of devices used in the task.

 

Regards,

Marco

Message 2 of 6
(3,351 Views)

That means I've got to create the task first and reset the device second. Can be done I guess, but I thought it made more sense to reset the device before defining tasks on it.

0 Kudos
Message 3 of 6
(3,346 Views)

I think this might be the "trivial" way you're looking for: some string pattern matching and a simple

regular expression to extract the device name prefix from a physical channel name.

 

-Kevin P

 

dev from phys chan.png

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 4 of 6
(3,340 Views)

That is indeed more like I had in mind. I wasn't sure I could fire what looked like an enumeration type into a string vi. I guess it isn't an enumeration, just a string after all (in which case why isn't the wire pink?). Thanks to both respondents. I've tried both and they work - great.

0 Kudos
Message 5 of 6
(3,335 Views)
Solution
Accepted by topic author rossu

If you want you can mark the issue as solved and give Kudos to everyone 😉

 

Marco

Message 6 of 6
(3,314 Views)