more kinematics
This commit is contained in:
+24
-4
@@ -49,6 +49,8 @@
|
||||
#define STEPS_PER_REV 2048
|
||||
#define DEFAULT_SPEED 600.0f // steps/sec
|
||||
#define DEFAULT_ACCEL 100.0f // steps/sec²
|
||||
float currentMaxSpeed = DEFAULT_SPEED;
|
||||
float currentAccel = DEFAULT_ACCEL;
|
||||
|
||||
// ─── BLE UUIDs ────────────────────────────────────────────────────
|
||||
#define SERVICE_UUID "18f3b235-9831-4c75-8ec0-210469b820a0"
|
||||
@@ -147,6 +149,7 @@ void parseCommand(const String &cmd) {
|
||||
// SPD:<n>
|
||||
if (cmd.startsWith("SPD:")) {
|
||||
float spd = cmd.substring(4).toFloat();
|
||||
currentMaxSpeed = spd;
|
||||
stepper1.setMaxSpeed(spd);
|
||||
stepper2.setMaxSpeed(spd);
|
||||
Serial.printf("[CFG] Max speed → %.0f steps/sec\n", spd);
|
||||
@@ -155,6 +158,7 @@ void parseCommand(const String &cmd) {
|
||||
// ACC:<n>
|
||||
if (cmd.startsWith("ACC:")) {
|
||||
float acc = cmd.substring(4).toFloat();
|
||||
currentAccel = acc;
|
||||
stepper1.setAcceleration(acc);
|
||||
stepper2.setAcceleration(acc);
|
||||
Serial.printf("[CFG] Acceleration → %.0f steps/sec²\n", acc);
|
||||
@@ -281,6 +285,10 @@ void loop() {
|
||||
if (stepper1.distanceToGo() == 0 && stepper2.distanceToGo() == 0) {
|
||||
stepper1.disableOutputs();
|
||||
stepper2.disableOutputs();
|
||||
stepper1.setMaxSpeed(currentMaxSpeed);
|
||||
stepper2.setMaxSpeed(currentMaxSpeed);
|
||||
stepper1.setAcceleration(currentAccel);
|
||||
stepper2.setAcceleration(currentAccel);
|
||||
homingState = HOME_IDLE;
|
||||
Serial.println("[SYS] Homing all complete.");
|
||||
}
|
||||
@@ -293,6 +301,8 @@ void loop() {
|
||||
} else if (homingState == HOME_1_PHASE2) {
|
||||
if (stepper1.distanceToGo() == 0) {
|
||||
stepper1.disableOutputs();
|
||||
stepper1.setMaxSpeed(currentMaxSpeed);
|
||||
stepper1.setAcceleration(currentAccel);
|
||||
homingState = HOME_IDLE;
|
||||
}
|
||||
} else if (homingState == HOME_2_PHASE1) {
|
||||
@@ -304,6 +314,8 @@ void loop() {
|
||||
} else if (homingState == HOME_2_PHASE2) {
|
||||
if (stepper2.distanceToGo() == 0) {
|
||||
stepper2.disableOutputs();
|
||||
stepper2.setMaxSpeed(currentMaxSpeed);
|
||||
stepper2.setAcceleration(currentAccel);
|
||||
homingState = HOME_IDLE;
|
||||
}
|
||||
}
|
||||
@@ -323,19 +335,27 @@ void loop() {
|
||||
|
||||
void performHomingAll() {
|
||||
Serial.println("[SYS] Homing all: Phase 1 (Stall UP)");
|
||||
stepper1.move(-2048);
|
||||
stepper2.move(2048);
|
||||
stepper1.setMaxSpeed(1500);
|
||||
stepper2.setMaxSpeed(1500);
|
||||
stepper1.setAcceleration(1500);
|
||||
stepper2.setAcceleration(1500);
|
||||
stepper1.move(-1200);
|
||||
stepper2.move(1200);
|
||||
homingState = HOME_ALL_PHASE1;
|
||||
}
|
||||
|
||||
void performHoming1() {
|
||||
Serial.println("[S1] Homing Motor 1: Phase 1 (Stall UP)");
|
||||
stepper1.move(-2048);
|
||||
stepper1.setMaxSpeed(1500);
|
||||
stepper1.setAcceleration(1500);
|
||||
stepper1.move(-1200);
|
||||
homingState = HOME_1_PHASE1;
|
||||
}
|
||||
|
||||
void performHoming2() {
|
||||
Serial.println("[S2] Homing Motor 2: Phase 1 (Stall UP)");
|
||||
stepper2.move(2048);
|
||||
stepper2.setMaxSpeed(1500);
|
||||
stepper2.setAcceleration(1500);
|
||||
stepper2.move(1200);
|
||||
homingState = HOME_2_PHASE1;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ function buildHTML() {
|
||||
<label class="form-label" style="margin:0;">Accel</label>
|
||||
<span id="accel-val" style="font-size: 0.8rem; color: var(--text-muted);">${Settings.accel}</span>
|
||||
</div>
|
||||
<input type="range" id="bc-slider-accel" min="50" max="1000" step="50" value="${Settings.accel}" style="width:100%;">
|
||||
<input type="range" id="bc-slider-accel" min="50" max="2000" step="50" value="${Settings.accel}" style="width:100%;">
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-bottom: 12px;">
|
||||
|
||||
@@ -139,7 +139,7 @@ function buildHTML() {
|
||||
<label class="form-label" style="margin:0;">Accel</label>
|
||||
<span id="accel-val" style="font-size: 0.8rem; color: var(--text-muted);">${Settings.accel}</span>
|
||||
</div>
|
||||
<input type="range" id="slider-accel" min="50" max="1000" step="50" value="${Settings.accel}" style="width:100%; margin-bottom: 8px;">
|
||||
<input type="range" id="slider-accel" min="50" max="2000" step="50" value="${Settings.accel}" style="width:100%; margin-bottom: 8px;">
|
||||
|
||||
<div class="setting-row">
|
||||
<label class="form-label" style="margin:0;">Global Delay (ms)</label>
|
||||
|
||||
@@ -273,7 +273,7 @@ function buildHTML() {
|
||||
<label class="form-label" style="margin:0;">Accel</label>
|
||||
<span id="accel-val" style="font-size: 0.8rem; color: var(--text-muted);">${Settings.accel}</span>
|
||||
</div>
|
||||
<input type="range" id="slider-accel" min="50" max="1000" step="50" value="${Settings.accel}" style="width:100%; margin-bottom: 8px;">
|
||||
<input type="range" id="slider-accel" min="50" max="2000" step="50" value="${Settings.accel}" style="width:100%; margin-bottom: 8px;">
|
||||
|
||||
<div class="setting-row">
|
||||
<label class="form-label" style="margin:0;">Global Delay (ms)</label>
|
||||
|
||||
@@ -561,7 +561,7 @@ function buildHTML() {
|
||||
<label class="form-label">Speed (steps/s)</label>
|
||||
<div class="range-row">
|
||||
<input class="form-range" type="range" id="speed-slider"
|
||||
min="100" max="1000" step="50" value="600"/>
|
||||
min="100" max="2000" step="50" value="600"/>
|
||||
<span class="range-value" id="speed-val">600</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -569,7 +569,7 @@ function buildHTML() {
|
||||
<label class="form-label">Accel (steps/s²)</label>
|
||||
<div class="range-row">
|
||||
<input class="form-range" type="range" id="accel-slider"
|
||||
min="50" max="500" step="25" value="100"/>
|
||||
min="50" max="2000" step="25" value="100"/>
|
||||
<span class="range-value" id="accel-val">100</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user