diff --git a/src/code/motor_stall/motor_stall_header.h b/src/code/motor_stall/motor_stall_header.h new file mode 100644 index 0000000..01abe84 --- /dev/null +++ b/src/code/motor_stall/motor_stall_header.h @@ -0,0 +1,18 @@ +typedef struct { + float measured_current_A; // Measured current in Amperes + float commanded_bus_voltage_V; // Commanded bus voltage in Volts + float motor_speed_rad_per_s; // Motor speed in radians per second from encoder +} motor_input_data_t; + +typedef struct { + motor_input_data_t input_data; + 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 motor Pointer to the motor handle structure + */ +void motor_stall_detect_period_run_1ms(motor_handle_t *motor); + diff --git a/src/main.tex b/src/main.tex index fb4bdd7..328ed24 100644 --- a/src/main.tex +++ b/src/main.tex @@ -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} diff --git a/src/motor_stall.tex b/src/motor_stall.tex new file mode 100644 index 0000000..f91f3fd --- /dev/null +++ b/src/motor_stall.tex @@ -0,0 +1,16 @@ +\documentclass[main.tex]{subfiles} + +\begin{document} +\section{Suppose a DC motor is connected to a load - how would you detect a stalled-rotor condition?} +Assume the header in Listing \ref{code:motor-stall-header} is provided. Discuss the implementation of stalled-rotor detection in the following circumstances: +\begin{itemize} + \item The DC motor features only a current sensor. + \item The DC motor features only an encoder. +\end{itemize} + +\lstinputlisting[caption={Motor Stall Detection Header}, label={code:motor-stall-header}]{code/motor_stall/motor_stall_header.h} + +\spoilerline + + +\end{document} \ No newline at end of file