Skip to content

Commit

Permalink
Bugfix for step loss recovery when motor direction is inverted
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrGri committed Nov 14, 2023
1 parent d1a9d1a commit c7d4502
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Arduino/Esp32/Main/Main.ino
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define ESTIMATE_LOADCELL_VARIANCE
#define ISV_COMMUNICATION
#define PRINT_SERVO_STATES
//#define PRINT_SERVO_STATES


bool resetServoEncoder = true;
Expand Down Expand Up @@ -919,6 +919,11 @@ void servoCommunicationTask( void * pvParameters )
}


// invert the compensation wrt the motor direction
if (MOTOR_INVERT_MOTOR_DIR)
{
servo_offset_compensation_steps_local_i32 *= -1;
}


if(semaphore_resetServoPos!=NULL)
Expand All @@ -927,8 +932,7 @@ void servoCommunicationTask( void * pvParameters )
// Take the semaphore and just update the config file, then release the semaphore
if(xSemaphoreTake(semaphore_resetServoPos, (TickType_t)1)==pdTRUE)
{
//servo_offset_compensation_steps_i32 = servo_offset_compensation_steps_local_i32;
servo_offset_compensation_steps_i32 = -servo_offset_compensation_steps_local_i32;
servo_offset_compensation_steps_i32 = servo_offset_compensation_steps_local_i32;
xSemaphoreGive(semaphore_resetServoPos);
}

Expand Down

0 comments on commit c7d4502

Please sign in to comment.