Linororobot with stm32F407 board

16 views
Skip to first unread message

Aguacristalina Santiago

unread,
Oct 27, 2024, 3:06:22 PM10/27/24
to LINOROBOT
I have tried to adapt linorobot hardware to stm32F407 board  but I have a problem 

In the program said:

// the PWM value sent to the motor driver is the calculated PID based on required RPM vs measured RPM
    motor1_controller.spin(motor1_pid.compute(req_rpm.motor1, current_rpm1));

but in the pid_compute there is not transformation from RPM to  pwm pulse

pid::compute() {
error = setpoint - measured_value;
    integral_ += error;
    derivative_ = error - prev_error_;

    if(setpoint == 0 && error == 0)
    {
        integral_ = 0;
        derivative_ = 0;
    }

    pid = (kp_ * error) + (ki_ * integral_) + (kd_ * derivative_);
    prev_error_ = error;rror = setpoint - measured_value;
    integral_ += error;
    derivative_ = error - prev_error_;
   return pid;
}

so that it is valid only if every RPM is equal to a  pwm pulse  but in the stm32F407 every RPM needs 60 pwm  units if the RPM  value is less than 100,  18 if the value is more than 100 but less than 200  etc. The value is not progress. so that I cannot compare pwm pulse with RPM in the pid compute function.    Please How I can  solve this problem.  Thanks
Reply all
Reply to author
Forward
0 new messages