-
Notifications
You must be signed in to change notification settings - Fork 1
more motor stall work #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sahil-kale
wants to merge
1
commit into
main
Choose a base branch
from
motor-stall
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
|
|
||
| \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} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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".