Problem in maze solving (using pid and qtr - 8a)

Hello !
I’m making a maze solving robot using QTR-8A sensor (only using 6 sensors), arduino UNO R3, L298D H-Bridge motor drive, and using PID. Firstly I worked on simple straight Line Following using QTR-8A, it worked but it takes too much time in turning. Then I made my code for Maze Solving, but this code did not work properly. I do everything which I can do. In this only one motor is working and other wheel does not work and I also used auto calibration in this but this also doesn’t work.
Can you suggest any change in hardware or software which can make it working perfectly. Please can you help me in this regard. If you can help me in code or provide me a code it will be very helpful.

The codes for both Simple Line Following and Maze Solving are as follow :

CODE FOR SIMPLE LINE FOLLOWING

5 feb checked final kd_5.ino (5.8 KB)

CODE FOR MAZE SOLVING

6 feb maze.ino (18.3 KB)

Hello.

Can you clarify what you mean when you say it “takes too much time in turning”?

For the maze solving program, I suggest working through it one step at a time. For example, if the calibration is not working, you should remove everything else except for that for now, and focus on that until it is working. You can also compare it to the calibration routine in your line follower program if that one is working how you want.

By the way, it looks like you are using 2 direction pins for each motor in your line follower program but only 1 for each in the maze solving program. You might look into this more; it might be the cause of one of your motors not working.

Brandon

“It takes too much time” means when it has a turn of 90 degree then it takes too much time in turning.

And my Line following code works properly but it follows a straight line only.
I tried to convert my line following code into maze solving but as you can see i’m unable.
So can you please explain me how can I convert my code into maze solving and "set priority as STRAIGHT - LEFT - RIGHT ".
Else if you have any maze solving code that i want and you can provide it to me (if you have code of any other priority then also you can provide) then it will be very helpful or if you can make code for me or provide me a code.
Please suggest me or provide a code. I will be very thankful to you. Hoping to hear from you soon and a positive response.

If your robot is not turning fast enough to keep on the line during a turn, you probably need to tune your PID to be more aggressive. This might mean increasing the Kp or Kd coefficient, depending on how it is behaving. It is hard to give any more specific advice without seeing the robot’s current behavior.

There are various ways you can go about writing a maze solving program. One common way of doing it is following a right- or left-hand approach, where the robot always prioritizes turning one way over going straight or turning the other. Prioritizing going straight over turning is usually not used since the robot can easily get stuck in an infinite loop that it can never get out of. For example, this very simple maze would never be solved if the robot always prioritizes going straight at the intersection:

You might find our 3pi robot’s maze solving example project a helpful resource. We also have maze solving examples for our Zumo 32U4 Robot and Zumo Robot for Arduino.

Were you able to fix your problem with one motor working in your maze solving code?

Brandon

Yes, I fixed problem of one motor working.
How can I recognize what should I increase Kp or Kd.?
I think it is going more complicated because I clearly doesn’t understand what should I do changes in my code. So it will be more better if you provide me a code of type that I want and that I really need.
If you provide me the same, I will be very thankful to you. Hoping to hear from you soon a positive response.
The pictures of hardware and track is attached here alongwith.

Your PID coefficients will depend on many factors of your robot, so we cannot just give you some correct values; you will likely need to do a lot of trial and error to get the behavior you want. There are various threads on our forum that are about PID tuning, for example, you can find some general advice for tuning PID coefficients in Ben’s posts in this thread. Additional information can be found on the PID controller Wikipedia page. In particular, you might consider the Ziegler–Nichols_method.

Additionally, please note that the QTR sensor board in your picture is not one of our products, so we cannot guarantee it will work correctly with our library.

Brandon

If that sensor array is the one that I am familiar with, it will not work with the QTR sensor library. The description for that board indicates that it only reports high or low. The QTR sensors have analog readings typically 0-1023.

The QTR sensoe that I’m using also gives analog readings and it is working in QTR library.