LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Issue with Myrio

Highlighted

We were trying to work with the servo motor controlled by the data from sonar range finder. We used the code given in the myRio demo projects and devices from myRio Mechatronics Kit.  But we are unable to do the operation.We are not able to control both servo motor and Sonar range finder using the single vi file. We are trying to transfer the output of the sonar to control the direction/speed/duration of the servo.

PFA the .vi file attatched.
0 Kudos
Message 1 of 2
(47 Views)

Based on a quick scanning of your VI, I'd suggest the problem lies in your understanding of Data Flow - that is, the process by which the execution order of different nodes is determined in LabVIEW.

 

You have a pair of nested While loops, and so first the outer loop (reading the Sonar Range Finder value) will iterate, and then the inner loop will start. The inner loop will continue running until the inner loop completely finishes (i.e. you click stop on the inner loop). It seems likely you actually only want this loop to iterate once per range finding value?

 

Once the inner loop is stopped, the outer loop will go to the next iteration, then then inner loop will again start.

 

You probably want to remove the inner loop whilst leaving the code, moving the Open VI to the outside of the remaining (outer) loop. Then you'll have one While loop containing both sets of code, which will run each iteration.

 

Take care to avoid having one need to run much faster than the other - if that is the case you'll need something more complicated, perhaps using either a State Machine (if you're happy to do one thing many times, then the other, then back to the first) or more likely, a Producer/Consumer type architecture which could feed the slower loop values from the faster loop.

0 Kudos
Message 2 of 2
(19 Views)