LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Activating a VI within another using boolean inputs

I have two separate VI's which I am using to implement a solar tracking system.

 The entire project is implemented using the USB-6008 DAQ. The concept is very simple, but I am having some trouble combining the two VI's together to obtain an automated response. Let me describe the overview of this system and where I am stuck.

 

First of all, I am using LED's to detect changes in light intensity. For this, I have two LED's connected to the analog inputs of the DAQ. When a light is supplied to the LED, a voltage is generated. For this step, there is no problem. In Labview, I have a VI which acquires the voltage levels from the DAQ, transmits this data into a comparator and the comparator is connected to two boolean outputs.

 

In condition one, when, voltage generated on LED1 > LED2,  the first boolean gives a high. When LED2>LED1 , the second boolean output gives a high. When the voltage levels on both LEDs are equal, there is no response. The system is implemented in a loop and runs continuously to detect the output voltages on both LEDs.

 

 

The second VI is a stepper motor control VI. An array is used to write digital data to the output ports of the DAQ. The direction of motor rotation is set by simply changing the array configuration.

 

What I need to do now is to actually implement the stepper motor VI within the sensors VI. I will require two settings for the stepper motor VI, once for forward movement, and the other for reverse. When the first boolean gives a high output, I want the motor to move forward, and when the second boolean gives a high output, I want the motor to move backwards. However, when I try implementing the motor control VI within the sensor VI, I get both VI's running at the same time.

 

I will really appreciate if someone can show me how I can actually implement the VI for motor control within the sensor VI, and when I click run, only the sensor VI is running, whereas the stepper VI's are only activated by the boolean outputs.

 

The programs are posted below, and I would really appreciate any guidance that can be provided or examples shown for this task as I have searched all resources I have but to no avail. Being a beginner to LabVIEW, it would really be great to get more guidance from the professionals. Thanks in advance.

Download All
0 Kudos
Message 1 of 5
(3,563 Views)
Hi, does anyone have an idea? Solution needed quie urgently! 🙂
0 Kudos
Message 2 of 5
(3,533 Views)

First,  I don't think your sensor VI is working the way you described you want it to work.  You are taking the data from two analog inputs.  Then you are comparing them to a fixed value of 0.5.  You said you wanted to compare them to each other.

 

Second, you didn't describe a boolean output from this comparison, but 3 states.  V1>V2,  V2>V1, V1=V2.  In reality, V1 will probably never be exactly equal to V2 since they measured values, and inherently double floating point datatypes.  If your stepper motor works the way I think you want it to (move one way if V1 is greater, the other if V2 is greater), the motor will probably just get to the equilibrium point and hunt back and forth as V1 and V2 values dance around each other.  You would probably want to have some sort of fuzzy error that if V2 is close enough to V1, then they are essentially equal.  Then you would have 3 states to send to the motor (forward, backward, no motion).

 

Right now, in your subVI, you don't have any of your controls wired to the connector pane.  Also, it has a while loop that is stopped by a stop button.  That is why your sensor VI seems to stop while the motor VI runs.  Once it starts the subVI, there is no way to stop it unless there is a DAQmx error, or the user presses the stop button on the front panel.  The main VI can't  continue running until the subVI finishes execution.  This is one of the principles of LabVIEW as a dataflow language.  You really only want the while loop in your main VI. 

 

To learn about passing data to a subVI, and how LabVIEW uses dataflow and VI's interact with each other, I would recommend you learn more about LabVIEW from here. How to Learn LV

Message 3 of 5
(3,528 Views)

From my understanding, I thought that the comparison is between the two sensors on the two analogue inputs, and then if the difference more than or equals to 0.5, a high is generated. The reason I did that is because I expect that the LED voltages will hardly be exactly the same, which is why I want it to only generate a response when the difference is 0.5V or higher.

 

Anyway, can u please instead guide me as to how I can actually insert the motor VI as a sub vi with 3 different states, one forward, one backward and one no response, and how to have these 3 VIS activated from within the program when the mentioned states are detected? Thank you very much for your feedback dear sir.

0 Kudos
Message 4 of 5
(3,521 Views)

Hi Take a look at the state machine design template by going to file --> New..  and then finding the "Standard State Machine" Template under design patterns.

 

However isnt this really a control problem?  You are basically driving a Stepper motor with a voltage level (From your comparator).  You can determine direction by negating the voltage level when condition A>B (Or whatever way round it needs to be).  Hunting can be thinned out by using appropriate thresholding etc etc.  I believe this is the better way to go about this problem rather than...

 

State 1 - Look at LDR Voltages and determine sign if A > B then goto State 2

State 1 - ------------------------^^---------------------------- if B > A then goto State 3

 

etc etc.

 

This makes your design template easier and probably less code (All be it a bit more taxing 😉

 

Craig

LabVIEW 2012
Message 5 of 5
(3,510 Views)