Refine this doc
Ask about this doc
Project Specification
Project Overview
Status: Review
Battery-powered electronics for a timed bag-lock mechanism using a bidirectional N20-class brushed DC gearmotor. Scope includes power, MCU, timer display, two-button UI, motor drive, battery measurement, endstop input, protection, debug, schematic, and a compact 2-layer PCB. Mechanical lock, enclosure, and 3D design are excluded.
Intended Use
A prototype/production-intent controller mounted in a compact bag-lock assembly. It closes the mechanism for a selected interval, then opens automatically. Reliability, battery safety, fault observability, and guaranteed reopening take priority over minimum cost.
What the Device Should Do
  • Operate from two series AAA cells.
  • Select 30 min, 1 h, 2 h, or 4 h lock intervals.
  • Pulse the motor for approximately 1–2 s in opposite directions to close and open.
  • Keep the motor fully off/coasting between pulses; never hold with continuous current.
  • Refuse closing when battery voltage is too low to reliably reopen later.
  • Open when the timer expires, when the primary button is pressed while locked, or after a ~6 s override hold.
  • Gate display power so the UI can fully sleep.
  • Optionally confirm opening using an external cam/endstop switch with firmware timeout/retries.
Main Features
  • PY32F002A-family MCU, TSSOP-20 preferred.
  • 4-digit common-anode LED timer display with TM1637 driver.
  • Two tactile buttons.
  • Bidirectional low-voltage H-bridge motor drive.
  • Switched battery ADC divider.
  • Side-exit motor and endstop connectors.
  • SWD-style debug header.
  • Safe reset defaults and low sleep current.
System Architecture

Diagram


2x AAA Battery Battery Rail PY32 MCU H-Bridge N20 Motor Display Power Gate TM1637 + 4-Digit Display Switched Battery Divider Two Buttons Optional Endstop SWD Header
Hardware Subsystems
Power
  • Two AAA cells in series, nominally ~3.0 V, connected through two PCB wire pads.
  • No regulator in the baseline design; MCU and motor driver operate directly from the battery rail.
  • Local MCU decoupling: 100 nF plus 10 µF.
  • Local motor-driver decoupling: 100 nF plus 10 µF.
  • Gated display rail local decoupling: 100 nF.
MCU and Debug
  • PUYA PY32F002AF15P6TU or compatible PY32F002A TSSOP-20.
  • Functions: buttons, endstop, H-bridge control, TM1637 CLK/DIO, display enable, battery-divider enable, battery ADC, NRST, BOOT0, and SWD.
  • NRST 10 kΩ pull-up; BOOT0 10 kΩ pull-down; debug header exposes battery, GND, SWDIO, and SWCLK.
Motor Drive
  • TI DRV8837/DRV8837C-class bidirectional H-bridge preferred.
  • VM/VCC from battery, OUT1/OUT2 to motor, IN1/IN2 from MCU.
  • 100 kΩ pull-down on both motor inputs for reset-safe OFF/coast behavior.
  • Sleep/enable arrangement must guarantee no accidental motor drive during reset and near-zero idle motor current.
  • Driver and battery source must tolerate short N20 startup/stall-current pulses; final motor stall current remains a required confirmation.
Display and UI
  • TM1637 SOP-20 driving a 0.56-inch four-digit common-anode LED display.
  • AO3401-class P-channel MOSFET high-side power gate; 100 kΩ gate pull-up makes display default OFF.
  • Two 6×6 mm SMD tactile switches.
  • Exact display pinout must be verified against the selected part before PCB routing.
Battery Measurement
  • 100 kΩ / 100 kΩ divider into an MCU ADC input.
  • AO3400-class N-MOSFET switches the divider return; 100 kΩ gate pull-down keeps measurement disabled by default.
  • Firmware measures battery before CLOSE and applies a conservative reopen reserve threshold.
External Connections
  • Motor: JST-SH 1.0 mm 2-pin right-angle SMD or equivalent.
  • Endstop: JST-SH 1.0 mm 2-pin right-angle SMD or equivalent.
  • Battery: two wire pads.
  • Debug: 1×4, 2.54 mm header.
Interfaces and Connections

Table


InterfaceSignals
BatteryBAT+, GND
MotorMOTOR_A, MOTOR_B
EndstopENDSTOP, GND
DisplaySEG1–SEG8, DIG1–DIG4 between TM1637 and display; CLK/DIO to MCU
DebugBAT, GND, SWDIO, SWCLK
ButtonsSW_A and SW_B active-low to MCU
Power and Runtime Expectations
  • Low-power sleep is the dominant idle mode: display rail off, battery divider off, motor disabled/coasting.
  • Display operates only briefly after user interaction.
  • Motor operates only for ~1–2 s close/open pulses.
  • Runtime depends strongly on MCU sleep current, display duty cycle, motor stall/start current, pulse duration, and battery chemistry.
Power Tree and Power Budget

Table


LoadSleepActive typicalPeak/transient
MCUDatasheet low-power modeFew mA classDatasheet maximum TBD
TM1637 + LED display0 when gatedDisplay-dependentSegment current dependent
H-bridge logicSleep/off currentLogic currentMotor current
N20 motor0Motor-dependentStall/start current TBD
Battery divider0 when gated~15 µA at 3.0 VSame
The motor dominates peak current. The final driver, connectors, copper, and source impedance must be validated against the selected motor’s measured or specified stall current at fresh-cell voltage. AAA alkaline voltage sag is a central feasibility risk; NiMH starts near 2.4–2.8 V and is acceptable only if MCU, display, and driver UVLO/headroom remain valid.
Manufacturing and Assembly Expectations
  • 85 mm × 55 mm, 2-layer, ~1.6 mm PCB.
  • 0603 passives preferred; larger package permitted for 10 µF capacitance retention.
  • Practical JLCPCB-style SMT parts and second-source-friendly footprints preferred.
  • WSON exposed-pad assembly and inspection require attention.
Firmware-Relevant Hardware Requirements
  • Safe GPIO defaults prevent motor activation during reset/programming.
  • Battery check occurs before every close command.
  • Display is enabled only when needed and disabled before deep sleep.
  • Endstop input supports configurable polarity, debounce, timeout, and retry behavior.
  • Motor truth table provides explicit CLOSE, OPEN, coast, and forbidden/brake states.
  • Countdown persists or fails safely across resets as defined by firmware policy.
Physical Design Expectations
  • User face: display, Switch A, Switch B, and battery pads; visually clean with no screw heads/spacers.
  • Electronics face: MCU, TM1637, H-bridge, MOSFETs, passives, JST connectors, debug header, and four M2 female SMD spacers at least 3 mm high.
  • Cables exit sideways at board edges.
  • Rear screws enter spacers from the electronics face side arrangement.
  • Maintain approximately 8 mm keepout between a THT display and battery zone.
  • Short/wide motor-current paths and a solid ground return are required.
Important Design Decisions
  • Bidirectional H-bridge retained; a single low-side MOSFET is unacceptable.
  • Direct battery operation retained unless voltage-range verification forces a regulator/alternate architecture.
  • Display and battery divider are independently power-gated for low sleep current.
  • Safe reset behavior is the highest electrical priority.
  • Robustness and guaranteed reopening override lowest cost.
Assumptions
  • Exact N20 motor stall current and winding resistance will be confirmed before PCB release.
  • Endstop electrical polarity and whether an external pull-up is needed will be confirmed.
  • Exact close/open pulse duration and retry limits are firmware-tuned mechanical parameters.
  • Exact LED display model and pinout will be selected and verified before footprint lock.
  • Battery polarity protection is desirable and may be added if voltage drop can be kept acceptably low.
Success Criteria
  • Complete datasheet-backed schematic with all power, reset, boot, debug, UI, display, measurement, motor, and connector circuitry wired.
  • Motor is guaranteed safe-OFF during MCU reset and sleep.
  • Opposite-direction pulse control and zero-current idle behavior are supported.
  • Battery voltage can be measured with negligible sleep leakage.
  • ERC has no unresolved critical errors.
  • PCB fits 85 mm × 55 mm, meets face/edge constraints, has no unrouted nets, and passes DRC.
Change Notes
  • Initial specification captured from the supplied electronics requirements.
  • Project Overview

  • Intended Use

  • What the Device Should Do

  • Main Features

  • System Architecture

  • Hardware Subsystems

  • Power

  • MCU and Debug

  • Motor Drive

  • Display and UI

  • Battery Measurement

  • External Connections

  • Interfaces and Connections

  • Power and Runtime Expectations

  • Power Tree and Power Budget

  • Manufacturing and Assembly Expectations

  • Firmware-Relevant Hardware Requirements

  • Physical Design Expectations

  • Important Design Decisions

  • Assumptions

  • Success Criteria

  • Change Notes