Skip to content

Commit 24ac94c

Browse files
firmware: friendly Motor Current (mA) + Motion Tuning directly under Control
- Add a "Motor Current" number in milliamps to Motion Tuning, driven by the driver's own read_run_current_mA / write_run_current_mA (no hand formula). Capped at 600 mA = IRUN 19, this motor's thermal ceiling. Keeps global_irun in sync. - Demote the raw IRUN register to "IRUN value" in the advanced StallGuard group for power users (still capped at 19). - Move the Motion Tuning group to weight 12 so it sits immediately under Control. Verified on hardware: Motor Current reads 538 mA at IRUN 17 (exact conversion). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 289e124 commit 24ac94c

1 file changed

Lines changed: 33 additions & 8 deletions

File tree

‎firmware/esphome/glasscalibur-product.yaml‎

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ logger:
417417
# while the TMC2209 StallGuard registers drop to an advanced group at the bottom.
418418
web_server:
419419
sorting_groups:
420-
- { id: group_tuning, name: "Motion Tuning", sorting_weight: 20 }
420+
- { id: group_tuning, name: "Motion Tuning", sorting_weight: 12 }
421421
- { id: group_cal, name: "Calibration", sorting_weight: 22 }
422422
- { id: group_stall, name: "Stall Detection", sorting_weight: 24 }
423423
- { id: group_security, name: "Security / Tamper", sorting_weight: 45 }
@@ -968,16 +968,41 @@ number:
968968
- id: !extend num_accel
969969
web_server: { sorting_weight: 2, sorting_group_id: group_tuning }
970970

971-
# Cap motor current at IRUN 19 (rated 0.6 A on this board's sense-resistor math,
972-
# I_RMS = (CS+1)/32 × 0.9575 A). Core's num_irun allows up to 31; anything above
973-
# 19 pushes this motor past its 60 °C case limit — never raise it. The on_boot
974-
# clamp (priority 650) also fixes values restored from older firmware. Sits in
975-
# Motion Tuning with Speed/Acceleration.
971+
# Friendly motor current in milliamps (Motion Tuning). The driver knows this
972+
# board's Rsense (220 mOhm) and Vsense, so read_run_current_mA / write_run_current_mA
973+
# do the register conversion — no formula here. IRUN 19 (this motor's thermal
974+
# ceiling, rated 0.6 A) is ~600 mA on this board, so max_value caps there: the
975+
# motor's 60 °C case limit leaves no headroom above it. Values snap to the
976+
# nearest of the 32 register steps (~30 mA). Keeps global_irun (persisted,
977+
# reapplied on boot) in sync with the register the driver just derived.
978+
- platform: template
979+
name: "Motor Current"
980+
id: num_motor_current
981+
unit_of_measurement: "mA"
982+
icon: "mdi:current-dc"
983+
web_server: { sorting_weight: 3, sorting_group_id: group_tuning }
984+
min_value: 100
985+
max_value: 600
986+
step: 10
987+
mode: BOX
988+
entity_category: CONFIG
989+
lambda: "return id(driver)->read_run_current_mA();"
990+
update_interval: 5s
991+
set_action:
992+
- lambda: "id(driver)->write_run_current_mA((uint16_t) x);"
993+
- globals.set:
994+
id: global_irun
995+
value: !lambda "return id(driver)->read_field(IRUN_FIELD);"
996+
997+
# Raw IRUN register (1-19) is meaningless to most users — the friendly Motor
998+
# Current above drives it in mA. Keep the raw register in the advanced group for
999+
# power users, still capped at 19.
9761000
- id: !extend num_irun
1001+
name: "IRUN value"
9771002
max_value: 19
9781003
web_server:
979-
sorting_weight: 3
980-
sorting_group_id: group_tuning
1004+
sorting_weight: 6
1005+
sorting_group_id: group_sg_adv
9811006

9821007
# TCOOLTHRS + SGTHRS are TMC2209 StallGuard registers -> the advanced group at
9831008
# the bottom of the page (they are tuning knobs for StallGuard, not everyday

0 commit comments

Comments
 (0)