fine tune the parameters
parent
835e673b24
commit
56cc473eb7
19
src/main.cpp
19
src/main.cpp
|
@ -46,7 +46,7 @@ void setup() {
|
|||
// TOFF General enable for the motor driver, the actual value does not influence StealthChop
|
||||
driver.toff(4);
|
||||
// RMS (mA) current for running, second arg - hold current multiplier
|
||||
driver.rms_current(1500, 0.5);
|
||||
driver.rms_current(1800, 0.5);
|
||||
driver.microsteps(0);
|
||||
|
||||
// Enable stealthChop
|
||||
|
@ -72,20 +72,20 @@ void setup() {
|
|||
// 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(20);
|
||||
driver.SGTHRS(35);
|
||||
|
||||
// default value: SGTHRS / 16 + 1
|
||||
// for sgResult = semin * 16, the current starts getting increased to resist the resistance
|
||||
// the bigger it is, the bigger the chance the motor is going to react to adversity
|
||||
// by increasing the current
|
||||
// 0..15
|
||||
driver.semin(9);
|
||||
driver.semin(15);
|
||||
|
||||
// SEMAX is used to determine when the extra current should be disabled.
|
||||
// the higher it is, the harder it's going to be to go back to energy efficient mode
|
||||
// 0 to 2 recommended
|
||||
// 0..15
|
||||
driver.semax(15);
|
||||
driver.semax(8);
|
||||
|
||||
// If the StallGuard4result is equal to or above (SEMIN+SEMAX+1)*32 the motro current becomes decreased to save energy
|
||||
driver.sedn(0b01);
|
||||
|
@ -114,7 +114,7 @@ void setup() {
|
|||
}
|
||||
|
||||
bool shaft = false;
|
||||
unsigned int stepsDelay = 28000 / MICROSTEPS;
|
||||
unsigned int stepsDelay = 10000;
|
||||
bool shouldRun = true;
|
||||
int stepsMade = 0;
|
||||
int stallSigs = 0;
|
||||
|
@ -156,6 +156,9 @@ void loop() {
|
|||
Serial.print("SGTHRS: ");
|
||||
Serial.println(driver.SGTHRS(), DEC);
|
||||
|
||||
Serial.print("SG_RESULT: ");
|
||||
Serial.println(driver.SG_RESULT()/2, DEC);
|
||||
|
||||
Serial.print("GCONF: ");
|
||||
Serial.println(driver.GCONF(), DEC);
|
||||
|
||||
|
@ -185,7 +188,7 @@ void loop() {
|
|||
// driver.shaft(shaft);
|
||||
}
|
||||
|
||||
for (uint32_t i = 20; i>0; i--) {
|
||||
for (uint32_t i = 24; i>0; i--) {
|
||||
digitalWrite(STEP_PIN, LOW);
|
||||
delayMicroseconds(1);
|
||||
digitalWrite(STEP_PIN, HIGH);
|
||||
|
@ -206,7 +209,9 @@ void loop() {
|
|||
Serial.print("STALLs ");
|
||||
Serial.println(stallSigs, DEC);
|
||||
|
||||
if (stallSigs > 3) {
|
||||
if (stallSigs >= 3) {
|
||||
Serial.print("Will reverse at");
|
||||
Serial.println(driver.SG_RESULT()/2, DEC);
|
||||
delay(200);
|
||||
shaft = !shaft;
|
||||
driver.shaft(shaft);
|
||||
|
|
Loading…
Reference in New Issue