-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help Request: Passive braking not working #84
Comments
Sometimes it is hard to tell much of a difference between the braking modes, depending on the exact motor and setup. You should be able to tell a difference between freewheeling and the other braking modes however. It should be noticeably easier to spin the motor in freewheeling mode than in the other braking modes. I do not see anything obviously wrong in your code. Have you tried any other examples to see if you can communicate with the motor driver and get your motor to spin properly? |
Hey Peter, thanks for the quick reply. Yes all 4 modes, including freewheeling, feel exactly the same. I am currently able to use the One wrinkle that I am now realising is that I am using these TMC2209 modules (schematic below) that have the ENN pin pulled high. Does this have an impact? Would I need to EDIT: Am now realising there is the IOIN register and the hardwareDisabled(). Unfortunately only able to try it on Monday so will report back after checking that. |
Yes, you need to pull the enable pin low in order for the move and standstill functions to work properly. |
I've made sure the enable pin is pulled low and added a read for the hardwareDisabled() reading. Here is the updated code and the output. All 4 states still feel the same strong-ish braking to the hand. #include <TMC2209.h>
// LilyGo ESP32 UART configuration
const long SERIAL_BAUD_RATE = 115200;
const int UART1_RX = 26; // LilyGo UART1 RX pin
const int UART1_TX = 17; // LilyGo UART1 TX pin
// Motor parameters
const int32_t RUN_VELOCITY = 14000; // 36000 steps per period * 2 seconds is 1 revolution.
const int32_t STOP_VELOCITY = 0;
// Test specific parameters
const int DELAY = 4000;
const uint8_t RUN_CURRENT_PERCENT = 100;
const uint8_t HOLD_CURRENT_STANDSTILL = 0;
// Init global variables
HardwareSerial &serial_stream1 = Serial1;
TMC2209 driver1;
void setup() {
// Initialize Serial for debugging
Serial.begin(SERIAL_BAUD_RATE);
// Setup TMC2209
driver1.setup(serial_stream1, SERIAL_BAUD_RATE, TMC2209::SERIAL_ADDRESS_0, UART1_RX, UART1_TX);
driver1.setRunCurrent(RUN_CURRENT_PERCENT);
driver1.setHoldCurrent(HOLD_CURRENT_STANDSTILL);
// driver1.enableAutomaticCurrentScaling();
driver1.enableCoolStep();
driver1.enable();
}
void loop() {
change_mode(TMC2209::NORMAL);
driver1.moveAtVelocity(RUN_VELOCITY);
delay(DELAY);
driver1.moveAtVelocity(STOP_VELOCITY);
delay(DELAY);
change_mode(TMC2209::FREEWHEELING);
driver1.moveAtVelocity(RUN_VELOCITY);
delay(DELAY);
driver1.moveAtVelocity(STOP_VELOCITY);
delay(DELAY);
change_mode(TMC2209::STRONG_BRAKING);
driver1.moveAtVelocity(RUN_VELOCITY);
delay(DELAY);
driver1.moveAtVelocity(STOP_VELOCITY);
delay(DELAY);
change_mode(TMC2209::BRAKING);
driver1.moveAtVelocity(RUN_VELOCITY);
delay(DELAY);
driver1.moveAtVelocity(STOP_VELOCITY);
delay(DELAY);
}
void change_mode(TMC2209::StandstillMode mode) {
TMC2209::Settings settings;
bool hardware_disabled;
Serial.print("Setting Mode: ");
switch (mode)
{
case TMC2209::NORMAL:
Serial.println("normal");
break;
case TMC2209::FREEWHEELING:
Serial.println("freewheeling");
break;
case TMC2209::STRONG_BRAKING:
Serial.println("strong_braking");
break;
case TMC2209::BRAKING:
Serial.println("braking");
break;
}
driver1.setStandstillMode(mode);
Serial.println("Reading:");
settings = driver1.getSettings();
hardware_disabled = driver1.hardwareDisabled();
Serial.print("hardware_disabled = ");
Serial.println(hardware_disabled);
Serial.print("Mode = ");
switch (settings.standstill_mode)
{
case TMC2209::NORMAL:
Serial.println("normal");
break;
case TMC2209::FREEWHEELING:
Serial.println("freewheeling");
break;
case TMC2209::STRONG_BRAKING:
Serial.println("strong_braking");
break;
case TMC2209::BRAKING:
Serial.println("braking");
break;
}
Serial.print("irun_percent = ");
Serial.println(settings.irun_percent);
Serial.print("ihold_percent = ");
Serial.println(settings.ihold_percent);
Serial.println();
}
|
Hi there,
I'm trying to set up the freewheel / passive braking feature. I first used the given example, but there is no difference in the braking for the 4 modes.
To my hand it feels like stronger braking than if I manually short both coils with a jumper. I added reading of the registers to check if the registers are setting correctly but it seems like it is. Is it a configuration issue? Am I using features that don't work together? I'm terribly confused by the TMC2209's various features and am not sure what conflicts with that. Any help is appreciated.
Test Code
Output:
Braking (based on turning by hand), is the same for all 4 states, and is stronger than manually shorting both coils.
The text was updated successfully, but these errors were encountered: