LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Please Tell Me what is the problem with code

Solved!
Go to solution

Dear all,

 

As you can see from the attached vi(pictures) after the "home.vi"  nothing happens, after the home.vi both DAQ's and motor controller's vi are not working. Could you pls help me to find a solution about the problem.

 

Waiting response.

Thanks,

Best regards.

0 Kudos
Message 1 of 6
(2,599 Views)
Solution
Accepted by topic author Salander

It's quite easy, you have data dependency between your two while loops.

The top while loop can't run before the lower while loop stops.

 

Remove the wires between the two loops, and they will run in parallel.

The wires you have to remove is going from the top border of the lower while loop to the bottom border of the top while loop.

 

Message 2 of 6
(2,597 Views)

You also has was called a greedy loop. When the Boolean is false, the lower while loop is runing as fast as it can, taking all the PC's power. You need to put in a small wait in the false case.

 

But really, I can't see why you have the lower while loop at all. It will only run the true case one time, and then the false case the rest of the time, never coming back to the true case.

Why not just but it in the top while loop ? in the false case there. (Not the while loop, but the case structure )

0 Kudos
Message 3 of 6
(2,590 Views)

Dear dkfire,

 

Firstly thanks alot for your solution, now two loops are working paralel with no problem. But i dont understand what you want to mean with the greedy loop. I need to made 2 loops in order to apply "wait.vi" only to the motor vis. Otherwise the DAQ's vis and motor's drivers vis locate at the same loop which means  DAQ also waits while the motor is waiting. I want DAQ to take samples continuously without waiting. If i put wait.vi to the false structure as you said, then this will make DAQ wait too which is unacceptable. So now it takes my PC's all power? 😞

 

Kind Regards,

Waiting forward for your kind reply.

0 Kudos
Message 4 of 6
(2,525 Views)

It is ok to have two loops. You just need to put some wait in the lower loops false case. 

This will only affect the motor vi's and it only needs to be a 2 ms wait.

 

A greedy loop is when a while loop spins as fast as it can without any wait. The PC will try to run the loop all the time. This means that nothing else in windows will be able to run. At some point windows has had enough of other task to be done, and your LabVIEW program will be paused until windows has completed its tasks.

Placing a small wait in the while loop, will give windows some time to handle other tasks at that point, making sure your program runs as you would like it to do.

 

Hope this helps.

Message 5 of 6
(2,518 Views)

Ok now i got it. Thanks alot for your clear response. It is so nice to have professionals like you in the discussion forum.

 

Kind regards from Turkey.

0 Kudos
Message 6 of 6
(2,498 Views)