芯片复制STM32单片机对正交编码器的驱动
芯片复制STM32正交编码器驱动,引入(突变)带进位的位置环和速度环
#include “stm32f10x.h”
#include “stm32f10x_encoder.h”
#include “sys.h”
#include “usart.h”
#include “led.h”
#define COUNTER_RESET(u16)0
#define ICx_FILTER(u8) 0 // 6《-》 670nsec
#define TIMx_PRE_EMPTION_PRIORITY 1
#define TIMx_SUB_PRIORITY 0
//#define MAX_COUNT ENCODER_TIM_PERIOD/2
volatile s16 Right_hEncoder_Timer_Overflow; //编码器计数值溢出标志
volatile s16 Right_hEncoder_Timer_Overflow_High;//编码器计数值溢出标志高位
volatile s16 Right_hRot_Speed;//当前的速度
volatile s16 Right_hRot_Acceleration;//当前的加速度
s32 Right_CurrentCount = 0;//编码器当前的总计数值
s32 Right_CurrentCount_high = 0;//编码器当前的总计数值高位计算公式,注意结果可能超过32位的表示范围Left_CurrentCount_high*S32_MAX+Left_CurrentCount
volatile s16 Left_hEncoder_Timer_Overflow;
volatile s16 Left_hEncoder_Timer_Overflow_High;
volatile s16 Left_hRot_Speed;
volatile s16 Left_hRot_Acceleration;
s32 Left_CurrentCount = 0;
芯片复制s32 Left_CurrentCount_high = 0;

芯片解密