astra/nema17-stepper-motor-controller-spring-clamp-rp2040
A 4-layer RP2040 controller board that negotiates USB‑C PD motor power and drives a NEMA17 stepper via a DRV8825, with current sensing, thermal shutdown, RGB status LED, buzzer alarm, optional AS5600 encoder, protection/filtering, and test points.
- Version
- 1.4.0
- License
- unset
- Stars
- 0
firmware/audible_alarm.py
"""Passive buzzer driven through Q_BUZZER. No GPIO load current."""
from tmp102 import WARN_C, TRIP_C
def alarm_duty(temperature_c, hardware_alert_ok, now_ms):
if not hardware_alert_ok or temperature_c is None or temperature_c >= TRIP_C:
return 32768
if temperature_c >= WARN_C:
# Short chirp each second before shutdown temperature is reached.
return 32768 if now_ms % 1000 < 200 else 0
return 0
class AudibleAlarm:
def __init__(self, pwm):
self.pwm = pwm
self.pwm.freq(4000)
self.pwm.duty_u16(0)
def update(self, temperature_c, hardware_alert_ok, now_ms):
self.pwm.duty_u16(alarm_duty(temperature_c, hardware_alert_ok, now_ms))
def close(self):
self.pwm.duty_u16(0)
self.pwm.deinit()