Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/code/motor_stall/motor_stall_header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
typedef struct {
float commanded_bus_voltage_V; // Commanded motor bus voltage in Volts
// float proposed_sensor_UNIT;
} motor_input_data_t;

typedef struct {
bool is_stalled; // True if the motor is stalled, false otherwise
// Additional variables can be added as needed
} motor_handle_t;

/**
* @brief Function to be called every 1 ms for motor stall detection
* @param input_data Pointer to the motor input data structure
* @param motor Pointer to the static motor handle structure
*/
void motor_stall_detect_period_run_1ms(const motor_input_data_t* const input_data, motor_handle_t *motor);

2 changes: 2 additions & 0 deletions src/main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@
\newpage
\subfile{buck_vs_ldo.tex} % place after passives.tex, opamp.tex
\newpage
\subfile{motor_stall.tex}
\newpage

% Appendix
\subfile{appendix_packet_parsing_tests.tex}
Expand Down
58 changes: 58 additions & 0 deletions src/motor_stall.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
\documentclass[main.tex]{subfiles}

\begin{document}
\section{Suppose a Brushed DC motor is connected to a load - how would you detect a stalled-rotor condition?}
Discuss what sensor(s) could be used to detect a stalled-rotor condition, and provide a C code snippet that implements the algorithm with the proposed sensor. Assume a header similar to the one in listing \ref{code:motor-stall-header} is provided.

\lstinputlisting[caption={Motor Stall Detection Sample Header}, label={code:motor-stall-header}]{code/motor_stall/motor_stall_header.h}

\spoilerline

\subsection{Defining a Stalled-Rotor Condition}
A stalled-rotor condiition occurs when the motor's rotor can no longer rotate, typically due to an excessive load or mechanical obstruction. If a motor is left in this condition, it may result in overheating (and damage to the motor windings), increased power consumption, and depending on the system, cause damage to other systems or people. Accordingly, implementing stall detection is a classic requirement for active control systems that use motors.
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "condiition" should be "condition".

Suggested change
A stalled-rotor condiition occurs when the motor's rotor can no longer rotate, typically due to an excessive load or mechanical obstruction. If a motor is left in this condition, it may result in overheating (and damage to the motor windings), increased power consumption, and depending on the system, cause damage to other systems or people. Accordingly, implementing stall detection is a classic requirement for active control systems that use motors.
A stalled-rotor condition occurs when the motor's rotor can no longer rotate, typically due to an excessive load or mechanical obstruction. If a motor is left in this condition, it may result in overheating (and damage to the motor windings), increased power consumption, and depending on the system, cause damage to other systems or people. Accordingly, implementing stall detection is a classic requirement for active control systems that use motors.

Copilot uses AI. Check for mistakes.

\subsubsection{DC Motor Model}
When analyzing how to detect a stalled-rotor condition, it is useful to understand the first-principles electrical model of a DC motor, shown in Figure \ref{fig:dc-motor-model}.
\begin{figure}[H]
\centering
\begin{circuitikz}[american]
\draw
(0,0) to[short, o-] (1,0)
to[R, l=$R$] (3,0)
to[L, l=$L$] (6,0)
to[vsource, l_=$V_{emf}$] (6,-3)
to[short] (0,-3)
to[vsource, l_=$V_{in}$, invert] (0,0)
;
\end{circuitikz}
\caption{Electrical Model of a DC Motor with Upright Voltage Sources}
\label{fig:dc-motor-model}
\end{figure}

\newnoindentpara Where $V_{in}$ is the input voltage to the motor, $R$ is the resistance of the motor windings, $L$ is the inductance of the motor windings, and $V_{emf}$ is the back electromotive force (EMF) generated by the motor as it spins - $V_{emf} = K_e \cdot \omega$, where $K_e$ is the motor's back EMF constant and $\omega$ is the angular velocity of the motor shaft. Additionally, the torque generated by the motor is given by $T = K_t \cdot I$, where $K_t$ is the motor's torque constant and $I$ is the current flowing through the motor windings.\footnote{Note that for a given motor, $K_e$ and $K_t$ are numerically equal when using SI units.}

\subsection{Fundamental Principle of Stalled-Rotor Detection}
As we've defined a stalled-rotor condition to be one where the motor's rotor is not rotating ($\omega = 0$), we can leverage the DC motor model to inform our detection strategy. Since $V_{emf} = K_e \cdot \omega$, when the rotor is stalled, $V_{emf}$ will be zero. By extension, the motor's current draw will be at its maximum - all of the input voltage $V_{in}$ will be dropped across the motor's resistance and inductance, leading to a high current draw according to Ohm's Law ($I = \frac{V_{in}}{R}$ for a stalled motor). A schematic of this concept is shown in Figure \ref{fig:dc-motor-stall}.

\begin{figure}[H]
\centering
\begin{circuitikz}[american]
\draw
(0,0) to[short, o-] (1,0)
to[R, l=$R$] (3,0)
to[L, l=$L$] (6,0)
to[short] (6,-3)
to[short] (0,-3)
to[vsource, l_=$V_{in}$, invert] (0,0)
;
\draw[->, thick] (2.5, 0.5) -- (3.5, 0.5) node[midway, above] {$I$};
\end{circuitikz}
\caption{DC Motor Electrical Model with Shunted Back-EMF and Current Direction}
\label{fig:dc-motor-stall}
\end{figure}

\newnoindentpara As a result, we can detect a stalled-rotor condition either by monitoring the motor's current draw (as a high current draw indicates a stall) or by monitoring the motor's angular velocity (as a zero angular velocity indicates a stall).



\end{document}