LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView subVI bad functionality

          Hello everyone!

 

 

           I am using a Parallax PING))) sensor mounted on a servo motor. I have 2 subVIs: one for controlling the motor's position and another one for getting the distance from the sensor. When I use the subVI from the sensor alone, it works corectly, but when I try to use it in the same VI with the subVI for the motor, it works bad. It is always showing a distance aroung 9cm. I think it might be a timing problem since this is how the sensor works. And I really can't figure out where the problem is.

           I attached the three subVIs. Please help me!

 

           All the best!

Download All
0 Kudos
Message 1 of 6
(3,661 Views)

Try using two different loops, one for reading the position and a second for controlling.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 6
(3,634 Views)

           I tried using a Flat Sequence Structure and also two While Loops, but there are no changes. Other ideas?

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

Your Main shows one loop with two sub-VIs that appear to have nothing to do with one another.  If they are truly independent, then (as Crossrulz says) you can put them each in their own While Loop.  When you first try this, you might create two Stop buttons, one for Stop Sensor and the other for Stop Motor -- later you can learn how to stop two loops safely with one Control (hint -- do not use a Local Variable).

 

I noticed your Sensor routine was full of Frames.  You absolutely do not need Frames except for a Frame containing the Error Line (to enforce serial order) and the Wait function (which lacks the Error Line).  What I do (since I hate Frames) is make my own Wait sub-VI (perhaps with a picture of the Wait Function as an Icon) that is simply the "Wait Function with Error Line" so that I can "anchor" the Wait to the Error Line without ugly (and big) Frames.  Otherwise, ordinary Data Flow (mainly enforced by the Error Line) will serialize the code for you and make it much neater and more compact.

 

Bob Schor

0 Kudos
Message 4 of 6
(3,584 Views)

           As I mentioned before, I already did this(I attached the subVI this time) with the same result. And I also need all those frames because I need to be sure the data flow is correct. I mean, it is all based on useconds timing and with the frames I am sure that it works correctly.

0 Kudos
Message 5 of 6
(3,539 Views)

@Bob_Schor wrote:
I noticed your Sensor routine was full of Frames.  You absolutely do not need Frames except for a Frame containing the Error Line (to enforce serial order) and the Wait function (which lacks the Error Line).  What I do (since I hate Frames) is make my own Wait sub-VI (perhaps with a picture of the Wait Function as an Icon) that is simply the "Wait Function with Error Line" so that I can "anchor" the Wait to the Error Line without ugly (and big) Frames.  Otherwise, ordinary Data Flow (mainly enforced by the Error Line) will serialize the code for you and make it much neater and more compact.

 

Bob Schor


That is one of the instances where i use an Express VI instead. The Time Delay saves me the work of creating a "Wait with error".

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 6
(3,511 Views)