#ifndef __PTZ_ELECTRIC_STABLE_H_ #define __PTZ_ELECTRIC_STABLE_H_ #include "ptz_type_select.h" #ifdef PTZ_LIGHT_GEAR_L6235D_AS5047D #define PTZ_ELECTRIC_STABLE_L6235D 1 //自锁方式 #define PTZ_ELECTRIC_STABLE_ON 1 //自锁是否打开 #endif #ifdef PTZ_ELECTRIC_STABLE_L6235D #define ANGLE_SAMPLE_NUM 31 #define STABLE_T 5 //任务稳定执行的延时 #define HORI_SLIDE_DIRECTONG_THRESHOLD 24 //判断云台滑动方向的阈值 ANGLE_SAMPLE_NUM * 2 / 3 #define HORI_SLIDE_DIR_CHANGE_NUM 10 //滑动方向改变的次数 #define VERT_SLIDE_DIRECTONG_THRESHOLD 24 //判断云台滑动方向的阈值 ANGLE_SAMPLE_NUM * 2 / 3 #define VERT_SLIDE_DIR_CHANGE_NUM 10 //滑动方向改变的次数 //电子稳定电压等级增量 #define HORI_VREF_INC 300 #define VERT_VREF_INC 300 //刹车后启动电子自锁霍尔脉冲数 #define HORI_STOP_HALL_NUM 5 #define VERT_STOP_HALL_NUM 5 //电子稳定增加倍数 #define HORI_VREF_INC_MUL 2 #define VERT_VREF_INC_MUL 2 //反向力矩作用总周期 #define TORQUE_TOTAL_T 10//ms //固定的反向力矩电压 #define TORQUE_VREF 100 typedef struct _vr_ { unsigned int vref; char dir; }vr; ///云台电子稳定反向力矩 typedef struct _ElectricStable_ { char stable_stop_switch;//刹车延时开关,1打开,0关闭。即刹车停止延时结束后置为1 char stable_sample_switch;//数据采集开关,表示角度采集分析结束。 float stable_angle[ANGLE_SAMPLE_NUM];//用于保存角度,判断云台滑动的趋势 unsigned int sample_count;//样本计数 unsigned int inc_count;//增加计数 unsigned int red_count;//减小计数 unsigned int equ_count;//相等计数 vr v[200]; unsigned int count; unsigned int stable_vref;//输入模拟电压等级 char slide_direction_actual;//云台滑动实际方向 char slide_direction_last;//云台滑动上一次方向 char slide_dir_change_num;//云台换向次数 char reverse_torque_direction_a;//反向力矩初始方向 char reverse_torque_direction;//反向力矩方向 char reverse_torque_direction_last;//上一次反向力矩方向 unsigned int stop_hall_count;//云台停止时霍尔计数 unsigned char state;//反向力矩控制过程 //刹车解除周期 unsigned short int torque_start_t; //刹车周期 unsigned short int torque_stop_t; //开关 char torque_switch; }ElectricStable; #endif #ifdef PTZ_BLDC_MOTOR void ptz_hori_electric_stable_init(); void ptz_vert_electric_stable_init(); void task_electric_stable_init(void); #endif #endif