This commit is contained in:
Rene Hopf
2016-12-18 23:51:19 +01:00
parent f15c9b32f7
commit 7d79dd932c
+10 -1
View File
@@ -3,6 +3,8 @@ HAL_COMP(enc_fb);
HAL_PIN(res) = 2048.0;
HAL_PIN(ires) = 1024.0;
HAL_PIN(pos) = 0.0;
HAL_PIN(abspos) = 0.0;
HAL_PIN(isabs) = 0.0;
HAL_PIN(index) = 0.0;
HAL_PIN(a) = 0.0;
HAL_PIN(b) = 0.0;
@@ -20,6 +22,7 @@ HAL_PIN(c) = 0.0;
MEM(int e_res) = 0.0;
MEM(float absoffset) = 0.0;
RT_INIT(
GPIO_InitTypeDef GPIO_InitStructure;
@@ -79,7 +82,13 @@ RT_DEINIT(
);
FRT(
PIN(pos) = mod(TIM_GetCounter(ENC1_TIM) * 2.0f * M_PI / (float)e_res);
float p = mod(TIM_GetCounter(ENC1_TIM) * 2.0f * M_PI / (float)e_res);
PIN(pos) = p;
if(RISING_EDGE(!GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_11)) && PIN(isabs) != 1.0){
absoffset = -p;
PIN(isabs) = 1.0;
}
PIN(abspos) = mod(p + absoffset);
);
RT(