Hello everyone , my name is Rares and I start this topic cuz i need help from you guys . I am building a new Line Follower robot. I am using Reduino Core , Motor driver TB6612FNG (DUAL) , QTR8 Analog Sensors (8 active sensors) and 2x 10:1 motors (3000rpm). Its not my first line follower robot. I had another one with 10:1 motors but now .. its a little bit old. It was at the level of 2013-2014 difficulty and now .. its just for showcase or Dragster... nvm
Is the first time when i am using PID (its just PD) so.. i have a lot of problems. First problem is with the weight of the robot. The "Inertia" give me a lot of problems. Ok.. robot works in straight line but with oscilation.. and if it turns left or right and the radius of turn is big, the robot start oscilating so hard and after another turn , it loses the line. I tryed a lot of Kp and Kd values. I seen a topic on polulu forum about a formule to calculate the Kp and its sounds someting like:
255(max motor speed) / 3500(position) = ~0.07 (i tryed from 0.01 to 0.10 and noting good) after i got the Kd witch was 10times bigger than Kp = 0.7 and again.. it doesn't work verry good. I tryed 20times bigger.. 1.4 again .. noting good. Another problem is : The lowest speed of motor (that's mean brake) its 0. It worked on 30:1 motors cuz they have more traction power.. but at 10:1 , the motor keep going.
What can I do? I know I have a lot of variants but I am blocked.. I don't have any Ideea.
My robot dimensions: FROM MOTOR1 TO MOTOR2 (ax) 140mm . From MOTOR1 / MOTOR2 to the middle of the sensors 140mm. So my robot its a equilateral triangle.
The weight of the robot is about ~110grams (+/- 10grams).
-The LiPo batteries which I am using ATM has 50grams (7.4V @1200mAh) but i wanna change them with 2 Drone LiPo batteries (7.2V @ 380mAh) which has 28grams.
-Motor and Wheels : ~15-20grams / motor
-The PCB plate(chassis) has 5-10grams
-And an extended "motherboard" with Reduino , Driver motor and voltage controll part (60mmx50mm) about 15-20grams.
My target is to make the robot very light(not heavy) so i can control the inertia.
- Another question: Can I use a function to brake the motor for 100milliseconds or someting to brake it? If yes , tell me how.
To move motors I am using the classic analogWrite (pwm) and a function which works someting like:
move(motor,speed,direction)
motor: 1 or 2
speed: 0-255
direction: 0 (backward) - 1 (forward)
I don't have the code right in this moment (its on my friend's laptop) but PD formula is:
unsigned int sensors[8];
int position = qtrrc.readLine(sensors); // get calibrated readings along with the line position, refer to the QTR Sensors Arduino Library for more details on line position.
int error = position - 3500;
int motorSpeed = Kp * error + Kd * (error - lastError);
lastError = error;
int rightMotorSpeed = rightBaseSpeed + motorSpeed;
int leftMotorSpeed = leftBaseSpeed - motorSpeed;
if (rightMotorSpeed > rightMaxSpeed ) rightMotorSpeed = rightMaxSpeed; // prevent the motor from going beyond max speed
if (leftMotorSpeed > leftMaxSpeed ) leftMotorSpeed = leftMaxSpeed; // prevent the motor from going beyond max speed
if (rightMotorSpeed < 0) rightMotorSpeed = 0; // keep the motor speed positive
if (leftMotorSpeed < 0) leftMotorSpeed = 0; // keep the motor speed positive
{
digitalWrite(motorPower, HIGH); // move forward with appropriate speeds
digitalWrite(rightMotor1, HIGH);
digitalWrite(rightMotor2, LOW);
analogWrite(rightMotorPWM, rightMotorSpeed);
digitalWrite(motorPower, HIGH);
digitalWrite(leftMotor1, HIGH);
digitalWrite(leftMotor2, LOW);
analogWrite(leftMotorPWM, leftMotorSpeed);
}
}