LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

Showing results for 
Search instead for 
Did you mean: 

Need help solving a problem (follow black line)

I've been doing this project for a course with a classmate and we can't figure it out. I know it's probably supposed to be quite simple, but we've already changed the PID values many times and the car keeps having problems. With a certain configuration (the image attached, which we could not get a printscreen of because we didn't have an internet connection on the computer it was made), the car actually follows the black line decently, but when it gets to a sharp corner, it goes completely bonkers.
Would any of you help us, please? We need some kind of clue on where we need to get with these values...

Kind Regards,


0 Kudos
Message 1 of 8


If you send the vi instead of a picture it is easier to look at.

greetings from the Netherlands
0 Kudos
Message 2 of 8

Thank you for your reply. I didn't have a way to get the VI, as I was working on it on a computer with no internet connection. Well, here it goes attached.

Also, the black line is the one also attached.

Download All
0 Kudos
Message 3 of 8

EDIT: Sorry, the VI is not that one.

Here is the correct file attached.

0 Kudos
Message 4 of 8

can you explain what you are trying?

I really don't see much difference between the true and false case and as far as I can see neither of them ever stops anyway.

greetings from the Netherlands
0 Kudos
Message 5 of 8

Our goal would be to make the robot complete that path. So far, it follows the line (even though it wobbles/oscillates a little, but not that bad). The problem shows up when the robot gets to one of the two "pointy" curves. It completes one (not great, but serves the purpose), but the other one it doesn't, because it turns to the other way and so it loses track of the line. We were trying to make two case structures and we would switch between the two making noise (plugging the mic). We don't really have any experience in LabView and sutff like that, so this may be a very basic problem to solve, but not to us. 

Thank you for your patience.


0 Kudos
Message 6 of 8

I am not surprised that your line following algorithm is struggling with the 2nd pointy section.  That is a very sharp turn!  Here are two approaches I would take as part of your troubleshooting.  

  1. Increase the target brightness value from 39 to something larger.
  2. Slow down your speed when navigating the pointy sections. 

When it comes to using a sensor to switch between 2 different sets of control parameters, using a loud sound is a good idea, but you will need to write the LabVIEW a little differently.  Right now you are only checking the sound level once before entering the While Loop that does the line following.  As soon as the robot gets into the one of the inner PID loops, it will stay there and not check your sound sensor again.  This means that you cannot change your control constants once the robot has started line following. One way to fix this is to move your sound check code inside the PID loop that is doing the line following. Once inside the loop, you can make decisions based on what sound level it detects. 


Hope this helps.


0 Kudos
Message 7 of 8

Yeah, we tried to set the "39" parameter lower, not higher! 

We'll try those tips this week, thank you! Very helpful 🙂

0 Kudos
Message 8 of 8