You are here

Pid_Speed is braking despite no brake option

3 posts / 0 new
Last post
Flyingtux
Offline
Last seen: 1 year 8 months ago
Joined: 2021-08-23 17:00
Posts: 16
Pid_Speed is braking despite no brake option

Hi,

I'm using the vesc 75_300 with firmwware 5.3 version with pwm app

In "pid speed no reverse" mode (helicopter application), when the servo reach 0, I have a strong brake of the motor.

In "current mode no reverse", there is not his problem, current and duty seems always positive and I can stop more quickly without active braking.

Here is the graph screenshot with a pwm down ramp of 17s to avoid to break all my mechanic (no free wheel, so active breaking is prohibited)

Thanks in advance

Screenshot from 2022-04-07 09-37-47.png

 

frank
Offline
Last seen: 3 weeks 5 days ago
VESC BronzeVESC FreeVESC GoldVESC OriginalVESC PlatinumVESC Silver
Joined: 2016-12-27 20:19
Posts: 847

For most propeller applications current control is the best choice. Is there a reason for PID choosing speed control? The motor will try to reach the dialed speed as quickly as possible when you cahnge a speed command. That includes braking the rotor to achieve that speed.

Flyingtux
Offline
Last seen: 1 year 8 months ago
Joined: 2021-08-23 17:00
Posts: 16

Hi,

Thanks for answering.

Yes for first integration I need the vesc internal pid since I used it on the castle creation controler I used before.

My helicopter autopilot fly with constant consign but you're right, in the futur, I probably change the way to do (but current) it but I need first to have CAN bus support to have all the data with good bandwidth to do it correctly.

Regarding the pid no reverse, In the code there is already a limitation when "allow brake" is disable to avoid putting negative output if abs(rpm) > 20

file mcpwm_foc.c : function run_pid_control_speed

    // Optionally disable braking
    if (!conf_now->s_pid_allow_braking) {
        if (rpm > 20.0 && output < 0.0) {
            output = 0.0;
        }

        if (rpm < -20.0 && output > 0.0) {
            output = 0.0;
        }
    }

I will try to let a minimum of output instead 0.0 by adding something like this block  just before the line : utils_truncate_number_abs(&output, 1.0);

#ifdef PID_FOC_TRUE_NO_BRAKE
    if (!conf_now->s_pid_allow_braking)
    {
        //memorize the sign of output if possible
        static int last_speed_pid_set_rpm_sign = 0;
        if (motor->m_speed_pid_set_rpm > FLT_EPSILON)
            last_speed_pid_set_rpm_sign = 1;
        else if (motor->m_speed_pid_set_rpm < -FLT_EPSILON)
            last_speed_pid_set_rpm_sign = -1;
        else
        {
            if (fabsf(rpm) > 20)
            {            
                //m_speed_pid_set_rpm is near zero [-FLT_EPSILON ; FLT_EPSILON]
                if (last_speed_pid_set_rpm_sign > 0)
                    output = 0.001;
                else if (last_speed_pid_set_rpm_sign < 0)
                    output = -0.001;
            }
            else
            {
                //current rpm is enough low, we can set output at 0                
                output = 0.0;
motor->m_speed_i_term = 0.0;
            }
                
        }                            
    }
    else
#endif //PID_FOC_TRUE_NO_BRAKE    
        utils_truncate_number_abs(&output, 1.0);