k i'm gettin the hang of it
parent
7ea42e6ca7
commit
835e673b24
17
src/main.cpp
17
src/main.cpp
|
@ -63,12 +63,16 @@ void setup() {
|
|||
// driver.toff(5);
|
||||
// driver.freewheel(0b01);
|
||||
|
||||
// This is the lower threshold velocity for switching on smart energy CoolStep and StallGuard to DIAG output
|
||||
// Set this parameter to disable CoolStep at low speeds, where it cannot work reliably.
|
||||
// The stall output signal become enabled when exceeding this velocity. It becomes disabled again once the velocity falls below this threshold
|
||||
// (TCOOLTHRS ≥ TSTEP > TPWMTHRS)
|
||||
driver.TCOOLTHRS(0xFFFFF); // 20bit max
|
||||
|
||||
// The driver.SG_RESULT() returns the result in the legacy 10 bit format, where the first and the last bit are always set to 0.
|
||||
// Dividing it by 2 gives us the value in the same range as driver.SGTHRS(STALL_VALUE);
|
||||
// if the (converted) SG_RESULT <= 2 * SGTHRS, stall is reported
|
||||
driver.SGTHRS(30);
|
||||
driver.SGTHRS(20);
|
||||
|
||||
// default value: SGTHRS / 16 + 1
|
||||
// for sgResult = semin * 16, the current starts getting increased to resist the resistance
|
||||
|
@ -90,7 +94,6 @@ void setup() {
|
|||
// driver.en_pwm_mode(true); // Toggle stealthChop on TMC2130/2160/5130/5160
|
||||
// driver.pwm_autoscale(true); // Needed for stealthChop
|
||||
|
||||
// delay(200);
|
||||
Serial.print(F("\nTesting connection..."));
|
||||
uint8_t result = driver.test_connection();
|
||||
if (result) {
|
||||
|
@ -105,6 +108,9 @@ void setup() {
|
|||
abort();
|
||||
}
|
||||
Serial.println(F("OK"));
|
||||
|
||||
// stealthChop2 regulates to nominal current and stores result to PWM_OFS_AUTO (Requires stand still for >130ms)
|
||||
delay(130);
|
||||
}
|
||||
|
||||
bool shaft = false;
|
||||
|
@ -200,7 +206,7 @@ void loop() {
|
|||
Serial.print("STALLs ");
|
||||
Serial.println(stallSigs, DEC);
|
||||
|
||||
if (stallSigs > 5) {
|
||||
if (stallSigs > 3) {
|
||||
delay(200);
|
||||
shaft = !shaft;
|
||||
driver.shaft(shaft);
|
||||
|
@ -209,6 +215,11 @@ void loop() {
|
|||
stallSigs = 0;
|
||||
}
|
||||
|
||||
// Serial.println(driver.TCOOLTHRS(), DEC);
|
||||
// Serial.println(driver.TSTEP(), DEC);
|
||||
// Serial.println(driver.TPWMTHRS(), DEC);
|
||||
// Serial.println();
|
||||
|
||||
// if (driver.SG_RESULT() > 105) {
|
||||
// shaft = !shaft;
|
||||
// driver.shaft(shaft);
|
||||
|
|
Loading…
Reference in New Issue