11-02-2012 08:13 AM
We are writing a simple program to use the sonar to stop a robot. If sonar
< x then true case is to brake both motors, if false, then run both motors.
While loop and progam end by touching the touch sensor.
Program starts by running motors and that is correct. Once a hand is placed
in front of ultrasonic sensor, robot stops but does not restart when hand removed, at least for a few seconds.
I put in a couple of writes to the display (after the sonar read and before
the case statement) to diagnose and the problem and the problem stopped. A
student noticed that a wait vi will eliminate the problem as well. 30 ms
seems to be enough of a wait for the program to work consistently.
NI Software :
LabVIEW version 2010
11-05-2012 06:13 PM
Hi,
It is always a good idea to add some element of timing to your while loops, else you may starve other threads that the processor must also run. In this case, does one of the functions seem to be waiting to return when the motors stop? Or does the while loop continue to execute but there is still no motion?
11-05-2012 09:10 PM
To work with this sensor requires a delay of approximately 50 ms - 100 ms after reading the ultrasonic sensor (Wait_num (msec). Vi).
Remember that this sensor works by mechanical waves that are emitted - bounce and read, basically not allowing time these waves to return and can be read.
11-06-2012 12:51 PM
I believe the while loop continues to run but there is no motion. Perhaps it will start up again a few seconds later.
I understand the need for waits when there are multiple threads, but this is a simple program with one thread. I learned labVIEW basics at the 2010 conference in Austin and this is the same program we used there successfully and has worked for me many times with LabVIEW2009.
I thought the principle of the wiring between VI's was that the next VI would not execute until all required information flowed to it. For NXT that would be the pink program control wire plus and data wires that are a prerequisite. The next VI does not seem to be waiting for the data to get there
I have since found the same problem with motor sensors needing a wait to be recognized.
Thank you for your help.