techmannih/nema34-mounted-stepper-controller

A 48 V USB‑C PD 3.1 EPR NEMA‑34 stepper controller PCB combining STM32/TMC5160 control, external MOSFET motor bridges, protected power and regenerative braking, USB data, telemetry, diagnostics, status LEDs, and buzzer alarms.

Version
0.3.92
License
unset
Stars
1

firmware/src/tmc5160_config.c

#include "tmc5160_config.h"

/* ADI Rev. 1.18: SPI velocity ramp, SD_MODE=0, 256 microsteps.
 * TOFF=0 keeps the chopper disabled throughout configuration. The waveform
 * parameters are a tuning starting point, not a qualified motor setup.
 * GLOBALSCALER=139 and IRUN=31 cap the nominal setpoint at 3.78 A RMS.
 * The 6 A/phase ordered motor must not receive a copied 5.5 A RMS setting. */
const tmc5160_register_t pd1180_tmc5160_boot_config[] = {
  {0x27u, 0u}, /* VMAX=0 before any other configuration; no startup motion. */
  {0x6Cu, PD1180_TMC_RAMP_CHOPCONF & ~15u},
  {0x00u, PD1180_TMC_RAMP_GCONF},
  /* Section 11.2: S2G_LEVEL >= 12 when regeneration can raise VS above 52 V.
   * S2VS=6, SHORTFILTER=1 and shortdelay=0 remain initial tuning values. */
  {0x09u, PD1180_TMC_SHORT_CONF},
  /* Make the four-clock dead-time baseline independent of OTP defaults.
   * Weak drive and gate timing still require bridge waveform qualification. */
  {0x0Au, PD1180_TMC_DRV_CONF},
  {0x0Bu, PD1180_GLOBALSCALER},
  {0x11u, 10u},
  {0x6Du, 0u}, /* No automatic CoolStep current scaling before qualification. */
  {0x33u, 0u}, /* VDCMIN: dcStep disabled, matching grounded DCEN/DCIN. */
  {0x20u, 1u}, /* Positive velocity mode. HOLD mode does not mean stop. */
  {0x23u, 0u}, /* VSTART */
  {0x24u, PD1180_BENCH_AMAX},
  {0x25u, 0u}, /* V1=0: use AMAX for the complete velocity ramp. */
  {0x26u, PD1180_BENCH_AMAX}, /* AMAX also controls velocity-mode deceleration. */
  {0x28u, PD1180_BENCH_AMAX},
  {0x2Au, PD1180_BENCH_AMAX},
  {0x2Bu, 10u}, /* Nonzero VSTOP for a defined position-mode fallback. */
  {0x34u, 0u}, /* No external stop switches or automatic stall stop. */
};
const size_t pd1180_tmc5160_boot_config_count =
  sizeof(pd1180_tmc5160_boot_config) / sizeof(pd1180_tmc5160_boot_config[0]);