Switch controlling step driver to serial interface

This commit is contained in:
2026-07-07 05:31:54 +07:00
parent 2c4aae9523
commit 15645f7d25
8 changed files with 473 additions and 282 deletions

View File

@@ -1,6 +1,5 @@
#include "config.h"
// WiFi & MQTT
const char* WIFI_SSID = "Home";
const char* WIFI_PASS = "88888888qwE";
const char* MQTT_SERVER = "192.168.31.225";
@@ -9,12 +8,21 @@ const char* MQTT_USER = "test";
const char* MQTT_PASS = "1234";
const char* MQTT_CLIENT_ID = "ESP32_Stepper";
// Pins
const int DIR_PIN = 18;
const int STEP_PIN = 19;
// UART2: RX=16, TX=17
HardwareSerial& TMC_SERIAL = Serial2;
const uint32_t TMC_BAUD_RATE = 115200;
const uint8_t TMC_SERIAL_ADDRESS = 0; // Если MS1 и MS2 на GND
const int16_t TMC_RX_PIN = 16;
const int16_t TMC_TX_PIN = 17;
const int EN_PIN = 21;
// Motor Params
const int STEPS_PER_REVOLUTION = 200;
const int MICROSTEP_FACTOR = 1;
const unsigned long RAMP_DURATION_MS = 2000;
const unsigned long RAMP_DURATION_MS = 2000;
// Ток задается в процентах от максимума (зависит от R_sense).
// Для R_sense=0.11 Ом, 100% ~ 1.77А RMS. Для R_sense=0.15 Ом, 100% ~ 1.2А RMS.
const uint8_t TMC_RUN_CURRENT_PERCENT = 50; // 50% тока при движении
const uint8_t TMC_HOLD_CURRENT_PERCENT = 20; // 20% тока в простое
const uint8_t TMC_STALL_GUARD_THRESH = 10;
const uint16_t TMC_MICROSTEPS = 1;