BEMF Loop Calculation Concept
This document describes the conceptual design for calculating Back Electromotive Force (bEMF) signals during ADC readout gaps, based on the previous cycles of PWM.
Mathematical Model
The bEMF voltage (\(V_{bemf}\)) of a brushed DC motor is proportional to the motor's angular velocity (\(\omega\)):
Where \(K_e\) is the back-EMF constant (V/(rad/s)).
In a PWM-driven system, the effective voltage applied to the motor terminals depends on the duty cycle (\(D\)):
During the "OFF" period of the PWM cycle (the readout gap), the motor is coasting, and the voltage measured on the motor terminals is the bEMF generated by the spinning rotor.
bEMF Estimation from PWM
By tracking the PWM duty cycle and the resulting motor speed from previous cycles, we can estimate the expected bEMF during the current cycle's gap.
Motor Configuration
To support various real-world motors, the simulation allows configuring motor-specific parameters:
| Parameter | Description | Units |
|---|---|---|
MotorType |
Identifier for the motor model (e.g., H0_Can_Motor, Mabuchi_RS-360) |
- |
Kv |
Motor velocity constant | RPM/V |
Resistance |
Internal resistance | Ohms |
Inductance |
Internal inductance | Henrys |
Inertia |
Rotor moment of inertia | kg·m² |
Config Example
motor_config:
type: "H0_Standard_Can"
kv: 1000
resistance: 10.0
inductance: 0.001
ADC Synchronization and Readout Gaps
To accurately measure bEMF, the ADC sampling must be synchronized with the PWM "OFF" time to avoid switching noise.
- PWM Trigger: The PWM peripheral generates a trigger signal at a specific point in its cycle (usually center-aligned or at the end of the ON pulse).
- ADC Delay: A configurable delay ensures the MOSFETs have fully switched and ringing has subsided.
- Sampling Window: The ADC captures the voltage on the motor terminals.
- Integration: The bEMF loop controller uses these samples to update the speed estimate for the PID loop.
Logging and Graphical Analysis
For comparison with real-world motor data, the system logs PWM and bEMF values in a CSV-compatible format via UART:
TIMESTAMP, PWM_DUTY, MOTOR_V, BEMF_EST
Data Flow
- Simulation: Renode calculates the "virtual" bEMF based on the motor model and PWM inputs.
- Firmware: Reads simulated ADC values and applies the BEMF loop logic.
- Host: Captures UART logs and uses tools like
matplotliborTeleplotfor real-time graphical analysis.