Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
StepperMotor.h
00001 /** 00002 ****************************************************************************** 00003 * @file StepperMotor.h 00004 * @author Davide Aliprandi, STMicroelectronics 00005 * @version V1.1.0 00006 * @date April 6th, 2016 00007 * @brief This file contains the abstract class describing the interface of a 00008 * stepper-motor component. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00013 * 00014 * Redistribution and use in source and binary forms, with or without modification, 00015 * are permitted provided that the following conditions are met: 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00022 * may be used to endorse or promote products derived from this software 00023 * without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00028 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00029 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00031 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00033 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00034 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************** 00037 */ 00038 00039 00040 /* Define to prevent from recursive inclusion --------------------------------*/ 00041 00042 #ifndef __STEPPERMOTOR_CLASS_H 00043 #define __STEPPERMOTOR_CLASS_H 00044 00045 00046 /* Includes ------------------------------------------------------------------*/ 00047 00048 #include <Component.h> 00049 00050 00051 /* Classes ------------------------------------------------------------------*/ 00052 00053 /** 00054 * An abstract class for StepperMotor components. 00055 */ 00056 class StepperMotor : public Component { 00057 public: 00058 00059 /** 00060 * @brief Rotation modes. 00061 */ 00062 typedef enum { 00063 BWD = 0, /* Backward. */ 00064 FWD = 1 /* Forward. */ 00065 } direction_t; 00066 00067 /** 00068 * @brief Step modes. 00069 */ 00070 typedef enum { 00071 STEP_MODE_FULL = 0, /* Full-step. */ 00072 STEP_MODE_HALF, /* Half-step. */ 00073 STEP_MODE_1_4, /* 1/4 microstep. */ 00074 STEP_MODE_1_8, /* 1/8 microstep. */ 00075 STEP_MODE_1_16, /* 1/16 microstep. */ 00076 STEP_MODE_1_32, /* 1/32 microstep. */ 00077 STEP_MODE_1_64, /* 1/64 microstep. */ 00078 STEP_MODE_1_128, /* 1/128 microstep. */ 00079 STEP_MODE_1_256, /* 1/256 microstep. */ 00080 STEP_MODE_UNKNOWN, /* Unknown. */ 00081 STEP_MODE_WAVE /* Full-step one-phase-on. */ 00082 } step_mode_t; 00083 00084 /** 00085 * @brief Getting the status. 00086 * @param None. 00087 * @retval The status. 00088 */ 00089 virtual unsigned int get_status(void) = 0; 00090 00091 /** 00092 * @brief Getting the position. 00093 * @param None. 00094 * @retval The position. 00095 */ 00096 virtual signed int get_position(void) = 0; 00097 00098 /** 00099 * @brief Getting the marked position. 00100 * @param None. 00101 * @retval The marked position. 00102 */ 00103 virtual signed int get_mark(void) = 0; 00104 00105 /** 00106 * @brief Getting the current speed in pps. 00107 * @param None. 00108 * @retval The current speed in pps. 00109 */ 00110 virtual unsigned int get_speed(void) = 0; 00111 00112 /** 00113 * @brief Getting the maximum speed in pps. 00114 * @param None. 00115 * @retval The maximum speed in pps. 00116 */ 00117 virtual unsigned int get_max_speed(void) = 0; 00118 00119 /** 00120 * @brief Getting the minimum speed in pps. 00121 * @param None. 00122 * @retval The minimum speed in pps. 00123 */ 00124 virtual unsigned int get_min_speed(void) = 0; 00125 00126 /** 00127 * @brief Getting the acceleration in pps^2. 00128 * @param None. 00129 * @retval The acceleration in pps^2. 00130 */ 00131 virtual unsigned int get_acceleration(void) = 0; 00132 00133 /** 00134 * @brief Getting the deceleration in pps^2. 00135 * @param None. 00136 * @retval The deceleration in pps^2. 00137 */ 00138 virtual unsigned int get_deceleration(void) = 0; 00139 00140 /** 00141 * @brief Getting the direction of rotation. 00142 * @param None. 00143 * @retval The direction of rotation. 00144 */ 00145 virtual direction_t get_direction(void) = 0; 00146 00147 /** 00148 * @brief Setting the current position to be the home position. 00149 * @param None. 00150 * @retval None. 00151 */ 00152 virtual void set_home(void) = 0; 00153 00154 /** 00155 * @brief Setting the current position to be the marked position. 00156 * @param None. 00157 * @retval None. 00158 */ 00159 virtual void set_mark(void) = 0; 00160 00161 /** 00162 * @brief Setting the maximum speed in pps. 00163 * @param speed The maximum speed in pps. 00164 * @retval "true" in case of success, "false" otherwise. 00165 */ 00166 virtual bool set_max_speed(unsigned int speed) = 0; 00167 00168 /** 00169 * @brief Setting the minimum speed in pps. 00170 * @param speed The minimum speed in pps. 00171 * @retval "true" in case of success, "false" otherwise. 00172 */ 00173 virtual bool set_min_speed(unsigned int speed) = 0; 00174 00175 /** 00176 * @brief Setting the acceleration in pps^2. 00177 * @param acceleration The acceleration in pps^2. 00178 * @retval "true" in case of success, "false" otherwise. 00179 */ 00180 virtual bool set_acceleration(unsigned int acceleration) = 0; 00181 00182 /** 00183 * @brief Setting the deceleration in pps^2. 00184 * @param deceleration The deceleration in pps^2. 00185 * @retval "true" in case of success, "false" otherwise. 00186 */ 00187 virtual bool set_deceleration(unsigned int deceleration) = 0; 00188 00189 /** 00190 * @brief Setting the Step Mode. 00191 * @param step_mode The Step Mode. 00192 * @retval "true" in case of success, "false" otherwise. 00193 */ 00194 virtual bool set_step_mode(step_mode_t step_mode) = 0; 00195 00196 /** 00197 * @brief Going to a specified position. 00198 * @param position The desired position. 00199 * @retval None. 00200 */ 00201 virtual void go_to(signed int position) = 0; 00202 00203 /** 00204 * @brief Going to the home position. 00205 * @param None. 00206 * @retval None. 00207 */ 00208 virtual void go_home(void) = 0; 00209 00210 /** 00211 * @brief Going to the marked position. 00212 * @param None. 00213 * @retval None. 00214 */ 00215 virtual void go_mark(void) = 0; 00216 00217 /** 00218 * @brief Running the motor towards a specified direction. 00219 * @param direction The direction of rotation. 00220 * @retval None. 00221 */ 00222 virtual void run(direction_t direction) = 0; 00223 00224 /** 00225 * @brief Moving the motor towards a specified direction for a certain number of steps. 00226 * @param direction The direction of rotation. 00227 * @param steps The desired number of steps. 00228 * @retval None. 00229 */ 00230 virtual void move(direction_t direction, unsigned int steps) = 0; 00231 00232 /** 00233 * @brief Stopping the motor through an immediate deceleration up to zero speed. 00234 * @param None. 00235 * @retval None. 00236 */ 00237 virtual void soft_stop(void) = 0; 00238 00239 /** 00240 * @brief Stopping the motor through an immediate infinite deceleration. 00241 * @param None. 00242 * @retval None. 00243 */ 00244 virtual void hard_stop(void) = 0; 00245 00246 /** 00247 * @brief Disabling the power bridge after performing a deceleration to zero. 00248 * @param None. 00249 * @retval None. 00250 */ 00251 virtual void soft_hiz(void) = 0; 00252 00253 /** 00254 * @brief Disabling the power bridge immediately. 00255 * @param None. 00256 * @retval None. 00257 */ 00258 virtual void hard_hiz(void) = 0; 00259 00260 /** 00261 * @brief Waiting while the motor is active. 00262 * @param None. 00263 * @retval None. 00264 */ 00265 virtual void wait_while_active(void) = 0; 00266 00267 /** 00268 * @brief Destructor. 00269 */ 00270 virtual ~StepperMotor() {}; 00271 }; 00272 00273 #endif /* __STEPPERMOTOR_CLASS_H */ 00274 00275 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 20:07:14 by
1.7.2