Software Requirements

Purpose

This document lists the software-level requirements for the MOTSEN Tool. Each requirement is a small testable “shall” statement derived from a single SWARCH_* block in Software Architecture or, where the software is the primary realization of a system behavior, directly from a SYS_* node in System Requirements.

Conventions:

  • One requirement, one observable behavior.

  • derived_from points to exactly one SWARCH_* or SYS_*.

  • All requirements are MCU-agnostic. Where a requirement references the MCU, it does so through the HAL, never by vendor name.

  • Items pending an open decision use status: placeholder and linked_to the relevant DEC_*.

HAL Requirements

Software Requirement: HAL covers required peripheral classes SWREQ_010
status: draft
derived from: SWARCH_010

The HAL shall expose interfaces for GPIO, UART, timer, ADC, PWM, and NVM peripheral classes.

Software Requirement: HAL header purity SWREQ_011
status: draft
derived from: SWARCH_011

HAL public headers shall not contain MCU vendor identifiers, SDK macros, or register definitions.

Software Requirement: HAL is the only MCU-aware code SWREQ_012
status: draft
derived from: SWARCH_011

Source files outside the HAL implementation directory shall not include MCU vendor headers or access MCU registers.

Software Requirement: HAL selected at build time SWREQ_013
status: draft
derived from: SWARCH_012

The HAL implementation for a given build target shall be selected at build time via a single configuration parameter.

Software Requirement: HAL pin/peripheral mapping is build configuration SWREQ_014
status: draft
derived from: SWARCH_012

Pin assignments and peripheral instance bindings shall be supplied to the HAL as build-time configuration; they shall not be hard-coded in HAL source files.

Driver Requirements

Software Requirement: PWM driver entry points SWREQ_020
status: draft
derived from: SWARCH_020

The PWM driver shall expose apply_duties, enable, and disable entry points and no others related to PWM output.

Software Requirement: PWM driver configures dead-time SWREQ_021
status: draft
derived from: SWARCH_020

The PWM driver shall configure the HAL PWM unit for center-aligned complementary output with a non-zero dead-time.

Software Requirement: ADC sampler latency SWREQ_022
status: draft
derived from: SWARCH_021

The ADC sampler shall publish a fresh sample frame (three phase currents and DC-bus voltage) within one PWM period of the ADC end-of-conversion interrupt.

Software Requirement: ADC sampler applies calibration SWREQ_023
status: draft
derived from: SWARCH_021

The ADC sampler shall apply per-channel scale and offset from the calibration store before publishing sample values.

Software Requirement: Hall reader maintains sector and direction SWREQ_024
status: draft
derived from: SWARCH_022

The Hall reader shall maintain the current commutation sector and an inferred direction of rotation, updated on every Hall edge and on a periodic poll.

Software Requirement: Comms framer is byte-stream symmetric SWREQ_025
status: draft
derived from: SWARCH_025

The comms framer shall encode and decode frames of the on-wire format using a single byte-stream interface in each direction.

Services Layer Requirements

Software Requirement: System tick SWREQ_030
status: draft
derived from: SWARCH_030

The firmware shall provide a 1 kHz (or faster) system tick driven by a HAL timer.

Software Requirement: Non-blocking timing primitives SWREQ_031
status: draft
derived from: SWARCH_030

The firmware shall provide non-blocking delay and timeout primitives backed by the system tick.

Software Requirement: Cooperative scheduler SWREQ_032
status: draft
derived from: SWARCH_030

The firmware shall provide a cooperative scheduler that runs registered periodic tasks from the main loop. The scheduler shall not preempt.

Software Requirement: Real-time work in ISR context SWREQ_033
status: draft
derived from: SWARCH_031

The control / measurement step, Hall sector update, and comms RX byte intake shall execute in interrupt context and shall not depend on the cooperative scheduler.

Software Requirement: Parameter access by ID SWREQ_040
status: draft
derived from: SWARCH_040

The parameter store shall expose every runtime-tunable parameter by a stable numeric ID.

Software Requirement: Parameter write validation SWREQ_041
status: draft
derived from: SWARCH_040

A parameter write shall be range-checked against the parameter’s declared bounds; writes outside the bounds shall be rejected and reported to the host.

Software Requirement: Calibration store applied before publication SWREQ_042
status: draft
derived from: SWARCH_041

The measurement engine shall refuse to publish a characterization result when the calibration store does not contain values for every channel used in the procedure.

Software Requirement: Protocol message classes SWREQ_050
status: draft
derived from: SWARCH_050

The protocol shall support three message classes: Parameter, Telemetry, and Command.

Software Requirement: Protocol version negotiation SWREQ_051
status: draft
derived from: SWARCH_050

The protocol shall include a version field in the frame header and the firmware shall report a mismatch back to the host without entering any error state of its own.

Software Requirement: Safety supervisor runs every sample SWREQ_060
status: draft
derived from: SWARCH_060

The safety supervisor shall run on every ADC sample frame and check instantaneous phase currents and DC-bus voltage against the configured limits.

Software Requirement: Safety supervisor disables PWM on breach SWREQ_061
status: draft
derived from: SWARCH_060

On any limit breach the safety supervisor shall disable PWM via the PWM driver before returning from the sample ISR.

Software Requirement: Safety supervisor transitions to Fault SWREQ_062
status: draft
derived from: SWARCH_060

After disabling PWM, the safety supervisor shall request a transition to the Fault state and shall record the fault cause and the offending sample frame in the logger.

Software Requirement: Logger non-blocking SWREQ_070
status: draft
derived from: SWARCH_070

The logger shall not block its caller and shall not perform dynamic allocation.

Software Requirement: Logger forwards on telemetry SWREQ_071
status: draft
derived from: SWARCH_070

The logger shall forward events on the protocol’s telemetry channel as the host comms scheduler runs.

Application Layer Requirements

Software Requirement: State machine owns mode SWREQ_080
status: draft
derived from: SWARCH_080

The operating-mode state machine shall be the sole writer of the current operating mode. No other module shall change the mode directly.

Software Requirement: Mode transition rules enforced SWREQ_081
status: draft
derived from: SWARCH_080

The state machine shall reject any mode transition request that does not satisfy the rules in Firmware-enforced transitions (SYS_111) through No direct Characterization ... (SYS_114).

Software Requirement: Fault entry from any mode SWREQ_082
status: draft
derived from: SWARCH_080

The state machine shall accept a Fault entry request from any source mode and shall execute the Fault entry actions before returning.

Software Requirement: Fault exit requires acknowledgement SWREQ_083
status: draft
derived from: SWARCH_080

The state machine shall exit Fault only on receiving an explicit acknowledgement command from the host, and shall transition only to Idle / Safe.

Software Requirement: Sensor health check end-to-end SWREQ_090
status: draft
derived from: SWARCH_090

The sensor health check procedure shall complete on a real motor and shall return one of {pass, fail-phase-sequence, fail-hall-alignment, fail-connectivity} along with a textual diagnostic.

Software Requirement: Sensor health check current cap SWREQ_091
status: draft
derived from: SWARCH_090

The sensor health check procedure shall declare its own current limit before enabling PWM, and that limit shall be lower than the configured Run-mode current limit.

Software Requirement: Rs procedure declares its limit SWREQ_100
status: draft
derived from: SWARCH_091

The Rs measurement procedure shall declare its own current limit before enabling PWM and shall abort the procedure on any safety-supervisor trip.

Software Requirement: Rs result reporting SWREQ_101
status: draft
derived from: SWARCH_091

The Rs measurement procedure shall return a result containing the measured Rs value, the test current, the measured DC voltage, and the pass/fail outcome against the configured tolerance.

Software Requirement: Open-loop commutation control rate SWREQ_110
status: draft
derived from: SWARCH_100

The open-loop commutation control loop shall run in the ADC sampler interrupt context and shall complete within one PWM period.

Software Requirement: Open-loop current limit enforcement SWREQ_111
status: draft
derived from: SWARCH_100

The open-loop commutation control loop shall not command a duty cycle that would cause the safety supervisor’s current limit to be reached under nominal conditions.

Host-Side Software Requirements

Software Requirement: Browser UI single-page SWREQ_120
status: draft
derived from: SWARCH_111

The browser UI shall be a single-page application that does not require a page reload during normal use.

Software Requirement: UI live signal panel SWREQ_121
status: draft
derived from: SWARCH_111

The UI shall display live phase currents, position sensor state, the current operating mode, and any active fault, updated from the telemetry channel.

Software Requirement: UI procedure trigger SWREQ_122
status: draft
derived from: SWARCH_111

The UI shall provide an explicit trigger for the sensor health check and for the Rs measurement procedure, and shall display the returned result.

Software Requirement: Host protocol parity SWREQ_123
status: draft
derived from: SWARCH_112

The host-side protocol implementation shall implement the same message classes, the same version negotiation, and the same frame format as the firmware-side implementation.

Software Requirement: Host single-user SWREQ_124
status: draft
derived from: SWARCH_110

The host application shall not implement user authentication or multi-user session handling.

Software Requirement: Local server binds local interface SWREQ_125
status: draft
derived from: SWARCH_110

The local web server shall bind to a loopback interface by default and shall not be reachable from outside the host PC without an explicit user opt-in.

Build and Configuration Requirements

Software Requirement: Single source tree, multiple targets SWREQ_130
status: draft
derived from: SWARCH_120

The firmware source tree shall build for every supported target without modification to source files outside the HAL implementation directory.

Software Requirement: Feature gating at compile time SWREQ_131
status: draft
derived from: SWARCH_121

Optional features (CAN, encoder, resolver, FOC, scripting) shall be compiled out of builds for which they are not enabled.

Software Requirement: No dynamic allocation after startup SWREQ_132
status: draft
derived from: SWARCH_122

The firmware shall not call dynamic memory allocation routines after the startup phase has completed.

Phase 2 and Phase 3 Placeholders

Software Requirement: Encoder reader SWREQ_200
status: placeholder
links to: MIL_042
derived from: SWARCH_023

Incremental encoder driver software. Scheduled for Phase 2 (MIL_042).

Software Requirement: Resolver driver SWREQ_201
status: placeholder
links to: MIL_077
derived from: SWARCH_024

Resolver driver software. Scheduled for Phase 3 (MIL_077).

Software Requirement: Ld / Lq measurement SWREQ_202
status: placeholder
links to: MIL_040
derived from: SWARCH_092

Ld / Lq measurement procedure. Scheduled for Phase 2 (MIL_040).

Software Requirement: Back-EMF / Kt measurement SWREQ_203
status: placeholder
links to: MIL_041
derived from: SWARCH_093

Back-EMF and torque-constant measurement procedure. Scheduled for Phase 2 (MIL_041).

Software Requirement: FOC control SWREQ_204
status: placeholder
links to: MIL_045
derived from: SWARCH_101

Field-oriented closed-loop control. Scheduled for Phase 2 (MIL_045).

Software Requirement: Scripting interface SWREQ_205
status: placeholder
links to: MIL_044
derived from: SWARCH_113

Host scripting interface for measurement sequences. Scheduled for Phase 2 (MIL_044).

Software Requirement: Host persistence SWREQ_206
status: placeholder
links to: MIL_047
derived from: SWARCH_114

Persistent storage of parameters and results on the host. Scheduled for Phase 2 (MIL_047).

Open-Decision Placeholders

Software Requirement: Host backend stack — pending SWREQ_900
status: placeholder
links to: DEC_002
derived from: SWARCH_900

Backend language and framework for the local web server are pending DEC_002.

Software Requirement: Host link protocol — pending SWREQ_901
status: placeholder
links to: DEC_003
derived from: SWARCH_901

Final on-wire frame format and physical layer are pending DEC_003.

Software Requirement: HAL strategy — pending SWREQ_902
status: placeholder
links to: DEC_005
derived from: SWARCH_014

Whether HAL implementations wrap the MCU vendor SDK or sit on registers is pending DEC_005.

Software Requirement: Sensorless control — pending SWREQ_903
status: placeholder
links to: DEC_006
derived from: SWARCH_902

Sensorless observer scope is pending DEC_006.

Traceability

Forward links from swreq to software test cases (TEST_* in <no title>) will be added as the software test plan is populated.