Skip to content

Commit

Permalink
Cleanup of servo register parameterization + disabled semaphore nullp…
Browse files Browse the repository at this point in the history
…ointer log output
  • Loading branch information
ChrGri committed Nov 16, 2023
1 parent e5fd30a commit 42ee828
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 73 deletions.
14 changes: 7 additions & 7 deletions Arduino/Esp32/Main/Main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void pedalUpdateTask( void * pvParameters )
else
{
semaphore_updateConfig = xSemaphoreCreateMutex();
Serial.println("semaphore_updateConfig == 0");
//Serial.println("semaphore_updateConfig == 0");
}
}

Expand Down Expand Up @@ -645,7 +645,7 @@ void pedalUpdateTask( void * pvParameters )
else
{
semaphore_updateJoystick = xSemaphoreCreateMutex();
Serial.println("semaphore_updateJoystick == 0");
//Serial.println("semaphore_updateJoystick == 0");
}

#ifdef PRINT_USED_STACK_SIZE
Expand Down Expand Up @@ -798,10 +798,10 @@ void serialCommunicationTask( void * pvParameters )
joystickNormalizedToInt32_local = joystickNormalizedToInt32;
xSemaphoreGive(semaphore_updateJoystick);
}
else
{
Serial.println("semaphore_updateJoystick == 0");
}
//else
//{
//Serial.println("semaphore_updateJoystick == 0");
//}
}
SetControllerOutputValue(joystickNormalizedToInt32_local);
}
Expand Down Expand Up @@ -940,7 +940,7 @@ void servoCommunicationTask( void * pvParameters )
else
{
semaphore_resetServoPos = xSemaphoreCreateMutex();
Serial.println("semaphore_resetServoPos == 0");
//Serial.println("semaphore_resetServoPos == 0");
}


Expand Down
122 changes: 56 additions & 66 deletions Arduino/Esp32/Main/isv57communication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,82 +40,72 @@ void isv57communication::sendTunedServoParameters() {

bool retValue_b = false;

// servo config update
//modbus.holdingRegisterWrite(slaveId, pr_0_00+2, 0); // deactivate auto gain
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+2, 0);

//modbus.holdingRegisterWrite(slaveId, pr_0_00+3, 10); // machine stiffness
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+3, 10);

//modbus.holdingRegisterWrite(slaveId, pr_0_00+4, 80); // ratio of inertia
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+4, 80);

//modbus.holdingRegisterWrite(slaveId, pr_0_00+8, 1600); // microsteps
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+8, 1600);

//modbus.holdingRegisterWrite(slaveId, pr_0_00+13, 300); // 1st torque limit
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+13, 300);

//modbus.holdingRegisterWrite(slaveId, pr_0_00+14, 500); // position deviation setup
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+14, 500);

//modbus.holdingRegisterWrite(slaveId, pr_1_00+0, 500); // 1st position gain
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+0, 600);

//modbus.holdingRegisterWrite(slaveId, pr_1_00+1, 300); // 1st velocity loop gain
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+1, 300);

//modbus.holdingRegisterWrite(slaveId, pr_1_00+2, 300); // 1st time constant of velocity loop
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+2, 300);

//modbus.holdingRegisterWrite(slaveId, pr_1_00+3, 15); // 1st filter of velocity detection
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+3, 15);

//modbus.holdingRegisterWrite(slaveId, pr_1_00+4, 150); // 1st torque filter
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+4, 150);

//modbus.holdingRegisterWrite(slaveId, pr_1_00+10, 150); // velocity feed forward gain
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+10, 200);

//modbus.holdingRegisterWrite(slaveId, pr_1_00+11, 6000); // velocity feed forward filter
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+11, 6000);

//modbus.holdingRegisterWrite(slaveId, pr_1_00+12, 0); // torque feed forward gain
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+12, 0);

//modbus.holdingRegisterWrite(slaveId, pr_1_00+13, 0); // torque feed forward filter
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+13, 0);

//modbus.holdingRegisterWrite(slaveId, pr_1_00+15, 0); // control switching mode
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+15, 0);

//modbus.holdingRegisterWrite(slaveId, pr_1_00+37, 0); // special function register
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+37, 1048);

//modbus.holdingRegisterWrite(slaveId, pr_3_00+24, 5000); // maximum rpm
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_3_00+24, 5000);

//modbus.holdingRegisterWrite(slaveId, pr_5_00+13, 1); // overspeed level
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_5_00+13, 5000);

//modbus.holdingRegisterWrite(slaveId, pr_5_00+20, 1); // encoder output resolution
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_5_00+20, 1);

// Pr0 register
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+1, 0); // control mode
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+2, 0); // deactivate auto gain
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+3, 10); // machine stiffness
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+4, 80); // ratio of inertia
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+8, 1600); // microsteps
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+9, 1); // 1st numerator
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+10, 1); // & denominator
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+13, 300); // 1st torque limit
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+14, 500); // position deviation setup
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+16, 50); // regenerative braking resitor
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+17, 50);
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+18, 0); // vibration suppression
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_0_00+19, 0);

// Pr1 register
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+0, 600); // 1st position gain
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+1, 300); // 1st velocity loop gain
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+2, 300); // 1st time constant of velocity loop
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+3, 15); // 1st filter of velocity detection
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+4, 150); // 1st torque filter
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+10, 200); // velocity feed forward gain
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+11, 6000); // velocity feed forward filter
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+12, 0); // torque feed forward gain
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+13, 0); // torque feed forward filter
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+15, 0); // control switching mode
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+33, 0); // speed given filter
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+35, 0); // position command filter
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+36, 0); // encoder feedback
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_1_00+37, 1052); // special function register
// see https://www.oyostepper.com/images/upload/File/ISV57T-180.pdf
// 0x01 = 1: velocity feedforward disabled
// 0x02 = 2: torque feedforward disabled
// 0x04 = 4: motor overspeed alarm disabled
// 0x08 = 8: position following alarm disabled
// 0x10 = 16: overload alarm disabled
// 0x400 = 1024: undervoltage disabled

// Pr2 register
// vibration suppression
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_2_00+1, 50);
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_2_00+2, 20);
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_2_00+3, 99);
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_2_00+4, 90);
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_2_00+5, 20);
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_2_00+6, 99);
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_2_00+22, 0);
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_2_00+23, 0);

// Pr3 register
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_3_00+24, 5000); // maximum rpm

// Pr5 register
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_5_00+13, 5000); // overspeed level
retValue_b |= modbus.checkAndReplaceParameter(slaveId, pr_5_00+20, 1); // encoder output resolution






// store the settings to servos NVM
// store the settings to servos NVM if necesssary
if (retValue_b)
{
Serial.println("Servo registered in NVM have been updated! Please power cycle the servo and the ESP!");
modbus.holdingRegisterWrite(slaveId, 0x019A, 0x5555); // store the settings to servos NVM
delay(2000);
}



}

Expand Down

0 comments on commit 42ee828

Please sign in to comment.