6020角度双环控制一种用于电机控制的策略

6020角度双环控制是一种用于电机控制的策略,主要用于精确控制电机的角度位置。以下是关于6020角度双环控制的详细信息:

工作原理

6020角度双环控制由两个反馈环组成:角度环和速度环。

  • 角度环(外环):角度环的主要任务是控制电机的最终位置。通过比较目标角度和实际角度的差值,角度环PID控制器计算出一个速度指令,作为速度环的输入。
  • 速度环(内环):速度环根据角度环给出的速度指令,控制电机的实际转速。速度环PID控制器会根据速度差值调整电机的电流,从而实现快速且稳定的转速控制。

控制流程

  1. 设置目标角度:根据实际应用需求,设定电机需要达到的目标角度。
  2. 角度反馈更新:通过电机内置的角度传感器,实时获取电机的当前角度,并更新角度环的反馈值。
  3. 角度PID计算:角度环PID控制器根据目标角度和当前角度的差值,计算出一个速度指令。
  4. 速度PID计算:速度环PID控制器根据角度环给出的速度指令和电机当前的实际转速,计算出电机需要的电流。
  5. 电机驱动:根据速度环PID控制器的输出,驱动电机以相应的速度转动,最终使电机达到目标角度。

代码示例

以下是一个简单的6020角度双环控制的代码示例:

c 复制代码
manipulator_motor_pid[i].AnglePID.target=30;//degree
update_angle(&manipulator_motor_pid[i]._angle,motor_manipulator[i].angle);
pid_calc(&manipulator_motor_pid[i].AnglePID);

manipulator_motor_pid[i].SpeedPID.target=manipulator_motor_pid[i].AnglePID.total_out;
manipulator_motor_pid[i].SpeedPID.current=motor_manipulator[i].speed_rpm;
pid_calc(&manipulator_motor_pid[i].SpeedPID);

/*位置pid算法*/
void pid_calc(_pid* pid){
    pid->e =pid->target-pid->current;
    //倍数
    pid->p_out=(int32_t)(pid->Kp*pid->e);

    //积分分离
    if(fabs(pid->e)<I_Band){
        //积分
        pid->i_out +=(int32_t)(pid->Ki*pid->e);
        //积分限幅
        limit(&(pid->i_out),pid->IntegralLimit);
    }else{
        pid->i_out=0;
    }

    pid->d_out=(int32_t)(pid->Kd*(pid->e-pid->last_e));
    pid->total_out=pid->p_out+pid->i_out+pid->d_out;

    //pid 输出限幅
    limit(&(pid->total_out),pid->MaxOutput);
    pid->last_e=pid->e;

}

/*角度更新*/
void update_angle(motor_angle* _angle, uint16_t angle_fb){
    _angle->encoder=angle_fb;
    if(_angle->encoder_is_init){
        if(_angle->encoder-_angle->last_encoder>4096){
            _angle->round_cnt --;
        }else if(_angle->encoder-_angle->last_encoder<-4096){
            _angle->round_cont++;
        }
    }else{
        _angle->encoder_offset=_angle->encoder;
        _angle->encoder_is_init=1;
    }
    _angle->angle_offset=_angle->encoder_offset /8192.of *360.of;
    _angle->last_encoder= _angle->encoder;
    _angle->total_encoder=_angle->round_cnt *8192+_angle->encoder-_angle->encoder_offset;
    _angle->angle=_angle->total_encoder / 8192.0f * 360.0f;
}

注意事项

  • PID参数整定:角度环和速度环的PID参数(Kp、Ki、Kd)需要根据实际应用进行调整,以达到最佳的控制效果。
  • 积分限幅:为了避免积分项过大导致系统不稳定,需要对积分项进行限幅处理。
  • 微分先行:在某些情况下,可以采用微分先行的方法,以减少输入突变对系统的影响。

应用场景

6020角度双环控制广泛应用于需要精确角度控制的场合,如机器人云台控制、机械臂关节控制等。在RoboMaster比赛中,6020角度双环控制被用于云台的精确角度控制,以确保云台能够快速响应并维持在预设的角度位置。

如果你有更具体的问题或需要进一步的帮助,请随时告诉我。

相关推荐
异方辰电子1 小时前
8.原理图为什么看不到具体的电路(比如STM32的晶振等)
stm32·单片机·嵌入式硬件
richxu202510012 小时前
嵌入式学习之路->stm32篇->(11)SPI通信(下)
stm32·嵌入式硬件·学习
电子科技圈3 小时前
从进迭时空K3看RISC-V CPU与Imagination GPU协同:如何构建高性能SoC能力
大数据·图像处理·人工智能·嵌入式硬件·边缘计算·智能硬件·risc-v
LCG元4 小时前
STM32实战:基于STM32F103的智能消防报警联动系统
stm32·单片机·嵌入式硬件
ivy159868377154 小时前
CH32V203G6U6 ‌沁恒32位 RISC-V 微控制器(MCU)‌
单片机·嵌入式硬件·risc-v
北山有鸟4 小时前
Linux第一宏:container_of
笔记·嵌入式硬件·学习
blevoice4 小时前
杰理蓝牙音箱开发板AC696N上演示降本设计:AC696N“省晶振”方案配置
单片机·嵌入式硬件·jl杰理蓝牙音频芯片·杰理ac696n开发板·ac6966b蓝牙音响芯片·蓝牙芯片ble透传·杰理蓝牙音箱方案开发
Ww.xh5 小时前
STM32+ESP8266智能农业系统开发指南
stm32·单片机·嵌入式硬件
charlie1145141915 小时前
嵌入式Linux驱动开发(3)——内核模块机制 - Linux 的插件系统
linux·运维·开发语言·驱动开发·嵌入式硬件·学习
yong99905 小时前
在 STC15W201S 上实现 MODBUS RTU 协议
stm32·单片机·嵌入式硬件