I need help with my code. I'm trying to make a code with PID control.

Hello! Sorry for the inconvenience! I have a robot with these components: TCRT5000 sensor with 5 channels, an Arduino Uno board, an L298N board and 2 motors (the L298N board is powered by 6 AA batteries of 1.5V each, and the Arduino Uno board is powered by 4 AA batteries of 1.5V each) and I have a code for it that works, but I heard on the internet and in various places that for a line-follower robot, like mine, there is another type of code, that is, with PID control. I would like, if anyone can, to explain to me how that PID works, what it does and if anyone can give me a starting code for my robot ( with PID).
No description
Solution:
Thank you ! Is this code good for something ?...
Jump to solution
28 Replies
MaderDash
MaderDash3mo ago
Do you know what pid is? And what it does? If so explain it back in a basic manner.
Tudic Robert
Tudic RobertOP3mo ago
I don't know. That's why I asked if someone could explain to me what PID does and how it works and if someone could give me some code as an example.
MaderDash
MaderDash3mo ago
https://youtu.be/tFVAaUcOm4I?si=Omb5KWVG6Drp8gtm Its a mathematical algorithm to controll logical controls to respond like analog devices.
DigiKey
YouTube
What is a PID Controller? | DigiKey
PID controllers are popular control mechanisms found in many systems used to help drive the main process’s output to achieve some desired set point. PID stands for “proportional, integral, derivative.” The controller compares the output of the process to some set point to create an error term. That error term is used in three separate calc...
MaderDash
MaderDash3mo ago
Here is a video for you
Solution
Tudic Robert
Tudic Robert3mo ago
Thank you ! Is this code good for something ?
Tudic Robert
Tudic RobertOP3mo ago
Do i need to modify anything ? Or I need to add something ?
Tudic Robert
Tudic RobertOP3mo ago
ignore this . i accidentaly clicked on "Apps" and "Mark solution" Or to delete something? @Maderdash ? I saw you wos online a few hours ago .....
MaderDash
MaderDash3mo ago
What's up?
Tudic Robert
Tudic RobertOP3mo ago
.
MaderDash
MaderDash3mo ago
Oh im not looking at files uploaded im on a cellphone
Tudic Robert
Tudic RobertOP3mo ago
Oh . Should I sent u pictures ? Or text ? I really need this code because I'm participating in a robotics competition in my country and I need this code to win. I'll modify Kp, Ki and Kd. I understand but I want to know if I did the right thing and after all it doesn't say in the rules that we are not allowed to copy or anything like that. If you want I can give you the rules. But after all I asked for an opinion and help and explanations not a code.
MaderDash
MaderDash3mo ago
You can post it in a past bin but to be honest its not going to mean anything to me. Its one of those things you need to load it on your bot. Test. Refine adjust retest. Repeat till you get it dialed in. There's not going to be anything there i can look at and say its going to work or not.
Tudic Robert
Tudic RobertOP3mo ago
If you don't want to help, please don't get involved, because in the end it's none of your business if I get a low grade in the contest or if I don't win. If you want, you'll help, if you don't, you don't have to! I know but I want to see if I understood it correctly and if it really needs to be done that way, because maybe even if it doesn't give me any errors in the code, maybe I didn't do something right or the calculations aren't good. I want the opinion of a professional or something like that. I want to know if the logic is good in the code.
MaderDash
MaderDash3mo ago
I gotcha. I can look at it in a pastbin its a website that you can past code at. Then when you click save it saves it for 7 days and gives you a web link so others can view the code
Tudic Robert
Tudic RobertOP3mo ago
This site : Pastebin.com - #1 paste tool since 2002! https://share.google/SYOK3c2EXdWLVZeKR. ??? Or is there another site? Should I look for it?
MaderDash
MaderDash3mo ago
Thats the site Past your code there set the language arduino give it a name.. all the settings then create the past
Tudic Robert
Tudic RobertOP3mo ago
Ok I'll do it tomorrow because it's a bit late in my country now and I've been working on the robot all day on the case code version and I'm tired. See you tomorrow!
MaderDash
MaderDash3mo ago
Again idk if there is much I can do but I will look at it for you
Tudic Robert
Tudic RobertOP2mo ago
Hello again ! in what category i put the code ? and should I put a tag? or a password ?
MaderDash
MaderDash2mo ago
No password needed , no need for a tag. Syntax cpp or arduino
Tudic Robert
Tudic RobertOP2mo ago
ok wich category ? Source code ??
MaderDash
MaderDash2mo ago
Sure
Tudic Robert
Tudic RobertOP2mo ago
the name is same like here . "I need help with my code. I'm trying to make a code with PID control." . I didn't register. Should I?
MaderDash
MaderDash2mo ago
No just coppy and past the web link now
Tudic Robert
Tudic RobertOP2mo ago
Pastebin
I need help with my code. I'm trying to make a code with PID contro...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
MaderDash
MaderDash2mo ago
Ty looking So it looks like your applying it to the sensor reads correctly. You're looking fine as far as I can tell; I don't know what the values should be.
Tudic Robert
Tudic RobertOP2mo ago
ok . should i ask someone else ? who knows the PID ?
MaderDash
MaderDash2mo ago
Sure

Did you find this page helpful?