|
@@ -113,7 +113,7 @@ void MeasTasksInit (void) {
|
|
encoderXTaskArg.pvEncoder = &(sensorsInfo.pvEncoderXraw);
|
|
encoderXTaskArg.pvEncoder = &(sensorsInfo.pvEncoderXraw);
|
|
encoderXTaskArg.currentPosition = &(sensorsInfo.currentXPosition);
|
|
encoderXTaskArg.currentPosition = &(sensorsInfo.currentXPosition);
|
|
encoderXTaskArg.positionOffset = &(sensorsInfo.positionXOffset);
|
|
encoderXTaskArg.positionOffset = &(sensorsInfo.positionXOffset);
|
|
- encoderXTaskArg.maxAngle = MAX_X_AXE_ANGLE;
|
|
|
|
|
|
+ encoderXTaskArg.impPerTurn = ENCODER_X_IMP_PER_TURN;
|
|
osMessageQueueAttr_t encoderMsgQueueAttr = { 0 };
|
|
osMessageQueueAttr_t encoderMsgQueueAttr = { 0 };
|
|
encoderXTaskArg.dataQueue = osMessageQueueNew (16, sizeof (uint32_t), &encoderMsgQueueAttr);
|
|
encoderXTaskArg.dataQueue = osMessageQueueNew (16, sizeof (uint32_t), &encoderMsgQueueAttr);
|
|
encoderXTaskArg.initPinStates = ((HAL_GPIO_ReadPin (GPIOD, GPIO_PIN_15) << 1) | HAL_GPIO_ReadPin (GPIOD, GPIO_PIN_14)) & 0x3;
|
|
encoderXTaskArg.initPinStates = ((HAL_GPIO_ReadPin (GPIOD, GPIO_PIN_15) << 1) | HAL_GPIO_ReadPin (GPIOD, GPIO_PIN_14)) & 0x3;
|
|
@@ -122,7 +122,7 @@ void MeasTasksInit (void) {
|
|
encoderYTaskArg.pvEncoder = &(sensorsInfo.pvEncoderYraw);
|
|
encoderYTaskArg.pvEncoder = &(sensorsInfo.pvEncoderYraw);
|
|
encoderYTaskArg.currentPosition = &(sensorsInfo.currentYPosition);
|
|
encoderYTaskArg.currentPosition = &(sensorsInfo.currentYPosition);
|
|
encoderYTaskArg.positionOffset = &(sensorsInfo.positionYOffset);
|
|
encoderYTaskArg.positionOffset = &(sensorsInfo.positionYOffset);
|
|
- encoderYTaskArg.maxAngle = MAX_Y_AXE_ANGLE;
|
|
|
|
|
|
+ encoderYTaskArg.impPerTurn = ENCODER_Y_IMP_PER_TURN;
|
|
encoderYTaskArg.dataQueue = osMessageQueueNew (16, sizeof (uint32_t), &encoderMsgQueueAttr);
|
|
encoderYTaskArg.dataQueue = osMessageQueueNew (16, sizeof (uint32_t), &encoderMsgQueueAttr);
|
|
encoderYTaskArg.initPinStates = ((HAL_GPIO_ReadPin (GPIOB, GPIO_PIN_11) << 1) | HAL_GPIO_ReadPin (GPIOB, GPIO_PIN_10)) & 0x3;
|
|
encoderYTaskArg.initPinStates = ((HAL_GPIO_ReadPin (GPIOB, GPIO_PIN_11) << 1) | HAL_GPIO_ReadPin (GPIOB, GPIO_PIN_10)) & 0x3;
|
|
|
|
|
|
@@ -374,23 +374,17 @@ void EncoderTask (void* arg) {
|
|
if (encoderStates[(step + 1) % 4] == pinStates) {
|
|
if (encoderStates[(step + 1) % 4] == pinStates) {
|
|
step++;
|
|
step++;
|
|
encoderValue++;
|
|
encoderValue++;
|
|
-// encoderValue += 360.0 / ENCODER_X_IMP_PER_TURN;
|
|
|
|
// printf ("Forward\n");
|
|
// printf ("Forward\n");
|
|
} else if (encoderStates[(step - 1) % 4] == pinStates) {
|
|
} else if (encoderStates[(step - 1) % 4] == pinStates) {
|
|
encoderValue--;
|
|
encoderValue--;
|
|
-// encoderValue -= 360.0 / ENCODER_X_IMP_PER_TURN;
|
|
|
|
-// if (encoderValue < 0) {
|
|
|
|
-// encoderValue = 360.0 + encoderValue;
|
|
|
|
-// }
|
|
|
|
// printf ("Reverse\n");
|
|
// printf ("Reverse\n");
|
|
step--;
|
|
step--;
|
|
} else {
|
|
} else {
|
|
printf ("Forbidden\n");
|
|
printf ("Forbidden\n");
|
|
}
|
|
}
|
|
step = step % 4;
|
|
step = step % 4;
|
|
-// *encoderTaskArg->pvEncoder = fmodf (encoderValue, 360.0);
|
|
|
|
*encoderTaskArg->pvEncoder = encoderValue;
|
|
*encoderTaskArg->pvEncoder = encoderValue;
|
|
- *encoderTaskArg->currentPosition = 100 * (*encoderTaskArg->pvEncoder) / encoderTaskArg->maxAngle;
|
|
|
|
|
|
+ *encoderTaskArg->currentPosition = 100 * (*encoderTaskArg->pvEncoder) / encoderTaskArg->impPerTurn;
|
|
osMutexRelease (sensorsInfoMutex);
|
|
osMutexRelease (sensorsInfoMutex);
|
|
}
|
|
}
|
|
DbgLEDToggle (encoderTaskArg->dbgLed);
|
|
DbgLEDToggle (encoderTaskArg->dbgLed);
|