LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I pass a string structure into a VI?

 


@Samweis wrote:

Yes looking at the demo.vi does help. And you're right it does not contain a call to the motor. In fact it doesn't actually do anything lol. I played with all of the VI's in that library, and the only one I found that actually drives the motor is the utility_panel.vi, via commands manually typed into it (ie J+ or J-).

 [snip] 

So maybe I am asking the wrong question. Perhaps some of you would be so kind as to help me better understand the LabVIEW library they have provided, and how everything functions together? I thought that passing the requisite command(s), as a string, into utility_panel would be the way to go, but maybe there is a better way to do it.


 

Now you're asking a better question, albeit one that's hard to answer without having your hardware on hand to play with.  I suspect the demo VI would do something if it it opened a reference to the motor (using openDeviceReference) at the beginning of the program, and if it didn't have a random reference to a LabVIEW numeric control.

 

The utility panel shows all the elements you need to get the motor working.  It's an unusual structure and not one that I'd recommend you copy, but it does work.  It's based on a LabVIEW state machine: a case structure inside a while loop with a shift register to track which state to execute.  Their implementation maintains an array of states that are processed in order, removing the state from the array as it is processed.  It starts with only the "initialize" state, which triggers the "getDeviceList" state, which then loads a long list of other states.  Most of those states make use of the command_center subVI, which lets you pass in an array of enumerated values indicating what action the motor should take so that you don't need to write the strings yourself.

 

It looks like a basic LabVIEW program would need to get the device list, allow the user to select a device, open a reference to that device, pass the reference (an integer on a blue wire) to the command_center along with the commands to execute (this step might go in a loop until the user decides to exit the program), then close the reference at the end of the program.  I hope by now you know that you can double-click a subVI to open and inspect it so you can see how they work.  Also, some of the VIs in the library provide very limited comments in their VI documentation (go to VI Properties -> Documentation).

Message 21 of 64
(1,198 Views)

Thank you for your detailed response! Very helpful. Viewing the (limited) documentation does provide some insight. I tried to email the creator but apparently that email addy is no longer.

 

The structure seems really complicated, and you're right I would not like to copy it. I'm thinking maybe modify it, based on your suggestions. Yes I know about the double-clicking on a sub-VI. However in looking at the UtilityPanel I see only one sub-VI I can select - setTimeOuts. Am I missing something?

 

My VI would only really need to pass three or four commands to the motor - initialize, "speed up" (or a larger J+ value) and "slow down" (or a smaller J+ value), for example. 

0 Kudos
Message 22 of 64
(1,159 Views)

Now we're into LabVIEW basics again.  There's a case structure (the box with the black and white speckled border) and you're looking at only one case, the setTimeOuts case.  You can click on that to pop down a list of all the possible cases, or scroll through them using the arrows on either side.  You can see that the code starts in the "initialize" case (based on the "initialize" constant wired to the shift register on the left), so that's a good place to start.  You will probably find it informative to run the utility panel with execution highlighting enabled.  Click the light bulb icon in the block diagram toolbar, then hit the run arrow, and LabVIEW will trace out the code as it runs.

0 Kudos
Message 23 of 64
(1,152 Views)

(sorry, this post started as an accidental duplicate of my previous reply)

0 Kudos
Message 24 of 64
(1,151 Views)

Quick (somewhat basic) question related to my VI.

Please see screenshot image:

 

I have a thermocouple attached to channel 1 (TC1) only. TC0 and TC2 have nothing attached (hence "infinite" resistance --> zero voltage --> should generate lowest temperature reading). In the DAQmx settings I have the Signal Input Range for each channel set at Max = 100 and Min = -200. Therefore TC0 is displaying correctly (fixed at -200 with no input) whereas the other two channels are acting funny and displaying a very large negative value, and this value increases (negatively) as time passes.

Can anyone enlighten me as to why this is happening? I would prefer if the channel just reads -200 if nothing is attached.

 

Thanks!

Download All
0 Kudos
Message 25 of 64
(1,133 Views)

Unterminated inputs on many DAQ devices result in the behavior you are seeing.  Capacitance at the input can charge to voltages which depend on the voltages at other  pins, how fast and in what sequence inputs are switched, and (sometimes it seems like...) the phase of the moon.  Any unused inputs should be connected to the AI ground or some similar reference.  Check the manual for your DAQ device.

 

Lynn

0 Kudos
Message 26 of 64
(1,129 Views)

Thanks. But why would the condition result in the same behavior at TC1 and TC2 but not TC0??

0 Kudos
Message 27 of 64
(1,122 Views)

 


@Samweis wrote:

Thanks. But why would the condition result in the same behavior at TC1 and TC2 but not TC0??


The phase of the moon. Always read the manual on the device you are using and see what the recommendations are regarding unused inputs. In most cases it will say (as Lynn indicated) to terminate unused inputs. This is standard engineering practice.

 

0 Kudos
Message 28 of 64
(1,120 Views)

The device probably has a multiplexer in front of a single A/D converter.  TC0 may be scanned before TC1 and 2.  Therefore it is exposed to a different charging environment than TC2.  Without details of the circuit of the DAQ device and all your wiring connections to it, I could only guess about the exact details.

 

Lynn

0 Kudos
Message 29 of 64
(1,108 Views)

I'm using a NI-9211 Thermocouple input (into a NI USB-9162 USB Carrier).

Here is the operation manual which includes the circuit diagram:

http://www.ni.com/pdf/manuals/373466d.pdf

 

There's nothing in the manual about connecting unused channels to a ground. I'm assuming the device is designed properly internally.

 

"The NI 9211 channels share a common ground isolated from other modules in the system. Each channel passes through a filter and then a 24-bit analog-to-digital converter (ADC) samples the channel. Each channel also has an open thermocouple detection (OTD) circuit, which consists of a current source between the TC+ and TC– terminals. If an open thermocouple is connected to the channel, the current source forces a full-scale voltage across the terminals."

 

Best

0 Kudos
Message 30 of 64
(1,100 Views)