Question

I have a program written in Labview for my LEGO Mindstorms NXT 2.0. When the target is set to the computer, the program works just fine. However, when I set the target to the NXT, the program doesn't work the same as when targeted to the computer.

The program makes the robot go forward until it is 30 centimetres away from an object, which is detected by the NXT's ultrasonic sensor. Then the robot will stop. If the object is moved and there is no object within 30 centimeters of the NXT's ultrasonic sensor, the robot will go forward again until it is 30 centimeters away from an object again. Then, it will stop.

This works when the target is set to computer in Labview, but not when set to NXT. When set to NXT, once the first object is detected, it will stop. But, if the object is removed and there is no longer any object within 30 centimetres of the ultrasonic sensor, the robot will remain stationary and not move forward.

Here is a screenshot of the block diagram: block diagram

Here is a link to the source code for the program.

Any help would be greatly appreciated.

Was it helpful?

Solution 3

I fixed this by adding a 200ms wait block to slow the NXT down. This worked, it seemed that the brick was getting ahead of itself.

OTHER TIPS

My experience with NXT is very limited, but I would suggest that you use the string VIs to display some debug data on the NXT's screen (such as i, the distance, etc.). This will allow you to determine where the program is and might help you find the problem.

As a side point, in LV it is generally not recommended to have a loop which doesn't have something controlling its rate of execution. This might be different for code running on the NXT, but I would still suggest adding a simple wait to the loop.

I don't see a mistake in your code, but what I would do when deploying to NXT target is I would make the loop infinite ( replace Stop with a False constant) and delete the waveform chart. You don't need them at NXT.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top