LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

Ultrasonic not sending data

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

 

 

0 Kudos
Message 1 of 4
(5,933 Views)

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?

Cole R.
National Instruments
Software Engineer
0 Kudos
Message 2 of 4
(5,916 Views)

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.



Ing. Jonathan E. Cruz Ortiz

ENERGÍA PROACTIVA S.A.S

Cel : (+57) 3173669343 - (+57) 3124451894

0 Kudos
Message 3 of 4
(5,913 Views)

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.

0 Kudos
Message 4 of 4
(5,903 Views)