04-14-2016 04:50 AM
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!
04-14-2016 06:33 AM
Try using two different loops, one for reading the position and a second for controlling.
04-14-2016 06:40 AM
I tried using a Flat Sequence Structure and also two While Loops, but there are no changes. Other ideas?
04-14-2016 08:32 AM
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
04-15-2016 04:18 AM
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.
04-15-2016 07:18 AM
@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