motor control
Fork of X_NUCLEO_IHM01A1 by
Components/Interfaces/StepperMotor_class.h@8:42e0b00b1e4d, 2015-11-23 (annotated)
- Committer:
- Davidroid
- Date:
- Mon Nov 23 11:10:54 2015 +0000
- Revision:
- 8:42e0b00b1e4d
- Parent:
- 7:f7e0c3621f77
- Child:
- 10:c3824af0caf4
+ Doxygen documentation completed.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Davidroid | 4:83a1eb397a65 | 1 | /** |
Davidroid | 4:83a1eb397a65 | 2 | ****************************************************************************** |
Davidroid | 4:83a1eb397a65 | 3 | * @file StepperMotor_class.h |
Davidroid | 4:83a1eb397a65 | 4 | * @author AST |
Davidroid | 4:83a1eb397a65 | 5 | * @version V1.0.0 |
Davidroid | 4:83a1eb397a65 | 6 | * @date November 12th, 2015 |
Davidroid | 4:83a1eb397a65 | 7 | * @brief This file contains the abstract class describing the interface of a |
Davidroid | 8:42e0b00b1e4d | 8 | * stepper-motor component. |
Davidroid | 4:83a1eb397a65 | 9 | ****************************************************************************** |
Davidroid | 4:83a1eb397a65 | 10 | * @attention |
Davidroid | 4:83a1eb397a65 | 11 | * |
Davidroid | 4:83a1eb397a65 | 12 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
Davidroid | 4:83a1eb397a65 | 13 | * |
Davidroid | 4:83a1eb397a65 | 14 | * Redistribution and use in source and binary forms, with or without modification, |
Davidroid | 4:83a1eb397a65 | 15 | * are permitted provided that the following conditions are met: |
Davidroid | 4:83a1eb397a65 | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
Davidroid | 4:83a1eb397a65 | 17 | * this list of conditions and the following disclaimer. |
Davidroid | 4:83a1eb397a65 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Davidroid | 4:83a1eb397a65 | 19 | * this list of conditions and the following disclaimer in the documentation |
Davidroid | 4:83a1eb397a65 | 20 | * and/or other materials provided with the distribution. |
Davidroid | 4:83a1eb397a65 | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
Davidroid | 4:83a1eb397a65 | 22 | * may be used to endorse or promote products derived from this software |
Davidroid | 4:83a1eb397a65 | 23 | * without specific prior written permission. |
Davidroid | 4:83a1eb397a65 | 24 | * |
Davidroid | 4:83a1eb397a65 | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Davidroid | 4:83a1eb397a65 | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Davidroid | 4:83a1eb397a65 | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Davidroid | 4:83a1eb397a65 | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
Davidroid | 4:83a1eb397a65 | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Davidroid | 4:83a1eb397a65 | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
Davidroid | 4:83a1eb397a65 | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Davidroid | 4:83a1eb397a65 | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Davidroid | 4:83a1eb397a65 | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Davidroid | 4:83a1eb397a65 | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Davidroid | 4:83a1eb397a65 | 35 | * |
Davidroid | 4:83a1eb397a65 | 36 | ****************************************************************************** |
Davidroid | 4:83a1eb397a65 | 37 | */ |
Davidroid | 4:83a1eb397a65 | 38 | |
Davidroid | 4:83a1eb397a65 | 39 | |
Davidroid | 4:83a1eb397a65 | 40 | /* Define to prevent from recursive inclusion --------------------------------*/ |
Davidroid | 4:83a1eb397a65 | 41 | |
Davidroid | 4:83a1eb397a65 | 42 | #ifndef __STEPPERMOTOR_CLASS_H |
Davidroid | 4:83a1eb397a65 | 43 | #define __STEPPERMOTOR_CLASS_H |
Davidroid | 4:83a1eb397a65 | 44 | |
Davidroid | 4:83a1eb397a65 | 45 | |
Davidroid | 4:83a1eb397a65 | 46 | /* Includes ------------------------------------------------------------------*/ |
Davidroid | 4:83a1eb397a65 | 47 | |
Davidroid | 4:83a1eb397a65 | 48 | #include <Component_class.h> |
Davidroid | 4:83a1eb397a65 | 49 | |
Davidroid | 4:83a1eb397a65 | 50 | |
Davidroid | 4:83a1eb397a65 | 51 | /* Classes ------------------------------------------------------------------*/ |
Davidroid | 4:83a1eb397a65 | 52 | |
Davidroid | 4:83a1eb397a65 | 53 | /** An abstract class for StepperMotor components. |
Davidroid | 4:83a1eb397a65 | 54 | */ |
Davidroid | 4:83a1eb397a65 | 55 | class StepperMotor : public Component |
Davidroid | 4:83a1eb397a65 | 56 | { |
Davidroid | 4:83a1eb397a65 | 57 | public: |
Davidroid | 4:83a1eb397a65 | 58 | /** Rotation modes. */ |
Davidroid | 4:83a1eb397a65 | 59 | typedef enum |
Davidroid | 4:83a1eb397a65 | 60 | { |
Davidroid | 5:d3c78f12a78d | 61 | BWD = 0, /* Backward. */ |
Davidroid | 5:d3c78f12a78d | 62 | FWD = 1 /* Forward. */ |
Davidroid | 4:83a1eb397a65 | 63 | } direction_t; |
Davidroid | 4:83a1eb397a65 | 64 | |
Davidroid | 7:f7e0c3621f77 | 65 | /** |
Davidroid | 8:42e0b00b1e4d | 66 | * @brief Getting the status. |
Davidroid | 7:f7e0c3621f77 | 67 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 68 | * @retval The status. |
Davidroid | 7:f7e0c3621f77 | 69 | */ |
Davidroid | 4:83a1eb397a65 | 70 | virtual unsigned int GetStatus(void) = 0; |
Davidroid | 4:83a1eb397a65 | 71 | |
Davidroid | 8:42e0b00b1e4d | 72 | /** |
Davidroid | 7:f7e0c3621f77 | 73 | * @brief Getting a parameter. |
Davidroid | 8:42e0b00b1e4d | 74 | * @param parameter The parameter's identifier (or its register address). |
Davidroid | 8:42e0b00b1e4d | 75 | * @retval The parameter's value. |
Davidroid | 7:f7e0c3621f77 | 76 | */ |
Davidroid | 4:83a1eb397a65 | 77 | virtual unsigned int GetParameter(unsigned int parameter) = 0; |
Davidroid | 4:83a1eb397a65 | 78 | |
Davidroid | 8:42e0b00b1e4d | 79 | /** |
Davidroid | 8:42e0b00b1e4d | 80 | * @brief Getting the position. |
Davidroid | 8:42e0b00b1e4d | 81 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 82 | * @retval The position. |
Davidroid | 8:42e0b00b1e4d | 83 | */ |
Davidroid | 4:83a1eb397a65 | 84 | virtual signed int GetPosition(void) = 0; |
Davidroid | 4:83a1eb397a65 | 85 | |
Davidroid | 8:42e0b00b1e4d | 86 | /** |
Davidroid | 8:42e0b00b1e4d | 87 | * @brief Getting the marked position. |
Davidroid | 8:42e0b00b1e4d | 88 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 89 | * @retval The marked position. |
Davidroid | 8:42e0b00b1e4d | 90 | */ |
Davidroid | 4:83a1eb397a65 | 91 | virtual signed int GetMark(void) = 0; |
Davidroid | 4:83a1eb397a65 | 92 | |
Davidroid | 8:42e0b00b1e4d | 93 | /** |
Davidroid | 8:42e0b00b1e4d | 94 | * @brief Getting the current speed in pps. |
Davidroid | 8:42e0b00b1e4d | 95 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 96 | * @retval The current speed in pps. |
Davidroid | 8:42e0b00b1e4d | 97 | */ |
Davidroid | 4:83a1eb397a65 | 98 | virtual unsigned int GetSpeed(void) = 0; |
Davidroid | 4:83a1eb397a65 | 99 | |
Davidroid | 8:42e0b00b1e4d | 100 | /** |
Davidroid | 8:42e0b00b1e4d | 101 | * @brief Getting the maximum speed in pps. |
Davidroid | 8:42e0b00b1e4d | 102 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 103 | * @retval The maximum speed in pps. |
Davidroid | 8:42e0b00b1e4d | 104 | */ |
Davidroid | 4:83a1eb397a65 | 105 | virtual unsigned int GetMaxSpeed(void) = 0; |
Davidroid | 4:83a1eb397a65 | 106 | |
Davidroid | 8:42e0b00b1e4d | 107 | /** |
Davidroid | 8:42e0b00b1e4d | 108 | * @brief Getting the minimum speed in pps. |
Davidroid | 8:42e0b00b1e4d | 109 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 110 | * @retval The minimum speed in pps. |
Davidroid | 8:42e0b00b1e4d | 111 | */ |
Davidroid | 4:83a1eb397a65 | 112 | virtual unsigned int GetMinSpeed(void) = 0; |
Davidroid | 4:83a1eb397a65 | 113 | |
Davidroid | 8:42e0b00b1e4d | 114 | /** |
Davidroid | 8:42e0b00b1e4d | 115 | * @brief Getting the acceleration in pps^2. |
Davidroid | 8:42e0b00b1e4d | 116 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 117 | * @retval The acceleration in pps^2. |
Davidroid | 8:42e0b00b1e4d | 118 | */ |
Davidroid | 4:83a1eb397a65 | 119 | virtual unsigned int GetAcceleration(void) = 0; |
Davidroid | 4:83a1eb397a65 | 120 | |
Davidroid | 8:42e0b00b1e4d | 121 | /** |
Davidroid | 8:42e0b00b1e4d | 122 | * @brief Getting the deceleration in pps^2. |
Davidroid | 8:42e0b00b1e4d | 123 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 124 | * @retval The deceleration in pps^2. |
Davidroid | 8:42e0b00b1e4d | 125 | */ |
Davidroid | 4:83a1eb397a65 | 126 | virtual unsigned int GetDeceleration(void) = 0; |
Davidroid | 4:83a1eb397a65 | 127 | |
Davidroid | 8:42e0b00b1e4d | 128 | /** |
Davidroid | 8:42e0b00b1e4d | 129 | * @brief Getting the direction of rotation. |
Davidroid | 8:42e0b00b1e4d | 130 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 131 | * @retval The direction of rotation. |
Davidroid | 8:42e0b00b1e4d | 132 | */ |
Davidroid | 5:d3c78f12a78d | 133 | virtual direction_t GetDirection(void) = 0; |
Davidroid | 5:d3c78f12a78d | 134 | |
Davidroid | 7:f7e0c3621f77 | 135 | /** |
Davidroid | 7:f7e0c3621f77 | 136 | * @brief Setting a parameter. |
Davidroid | 8:42e0b00b1e4d | 137 | * @param parameter The parameter's identifier (or its register address). |
Davidroid | 8:42e0b00b1e4d | 138 | * @param value The parameter's value. |
Davidroid | 7:f7e0c3621f77 | 139 | * @retval None. |
Davidroid | 7:f7e0c3621f77 | 140 | */ |
Davidroid | 4:83a1eb397a65 | 141 | virtual void SetParameter(unsigned int parameter, unsigned int value) = 0; |
Davidroid | 4:83a1eb397a65 | 142 | |
Davidroid | 8:42e0b00b1e4d | 143 | /** |
Davidroid | 8:42e0b00b1e4d | 144 | * @brief Setting the current position to be the home position. |
Davidroid | 8:42e0b00b1e4d | 145 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 146 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 147 | */ |
Davidroid | 4:83a1eb397a65 | 148 | virtual void SetHome(void) = 0; |
Davidroid | 4:83a1eb397a65 | 149 | |
Davidroid | 8:42e0b00b1e4d | 150 | /** |
Davidroid | 8:42e0b00b1e4d | 151 | * @brief Setting the current position to be the marked position. |
Davidroid | 8:42e0b00b1e4d | 152 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 153 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 154 | */ |
Davidroid | 4:83a1eb397a65 | 155 | virtual void SetMark(void) = 0; |
Davidroid | 4:83a1eb397a65 | 156 | |
Davidroid | 8:42e0b00b1e4d | 157 | /** |
Davidroid | 8:42e0b00b1e4d | 158 | * @brief Setting the maximum speed in pps. |
Davidroid | 8:42e0b00b1e4d | 159 | * @param speed The maximum speed in pps. |
Davidroid | 8:42e0b00b1e4d | 160 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 161 | */ |
Davidroid | 4:83a1eb397a65 | 162 | virtual void SetMaxSpeed(unsigned int speed) = 0; |
Davidroid | 4:83a1eb397a65 | 163 | |
Davidroid | 8:42e0b00b1e4d | 164 | /** |
Davidroid | 8:42e0b00b1e4d | 165 | * @brief Setting the minimum speed in pps. |
Davidroid | 8:42e0b00b1e4d | 166 | * @param speed The minimum speed in pps. |
Davidroid | 8:42e0b00b1e4d | 167 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 168 | */ |
Davidroid | 4:83a1eb397a65 | 169 | virtual void SetMinSpeed(unsigned int speed) = 0; |
Davidroid | 4:83a1eb397a65 | 170 | |
Davidroid | 8:42e0b00b1e4d | 171 | /** |
Davidroid | 8:42e0b00b1e4d | 172 | * @brief Setting the acceleration in pps^2. |
Davidroid | 8:42e0b00b1e4d | 173 | * @param acceleration The acceleration in pps^2. |
Davidroid | 8:42e0b00b1e4d | 174 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 175 | */ |
Davidroid | 4:83a1eb397a65 | 176 | virtual void SetAcceleration(unsigned int acceleration) = 0; |
Davidroid | 4:83a1eb397a65 | 177 | |
Davidroid | 8:42e0b00b1e4d | 178 | /** |
Davidroid | 8:42e0b00b1e4d | 179 | * @brief Setting the deceleration in pps^2. |
Davidroid | 8:42e0b00b1e4d | 180 | * @param deceleration The deceleration in pps^2. |
Davidroid | 8:42e0b00b1e4d | 181 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 182 | */ |
Davidroid | 4:83a1eb397a65 | 183 | virtual void SetDeceleration(unsigned int deceleration) = 0; |
Davidroid | 4:83a1eb397a65 | 184 | |
Davidroid | 8:42e0b00b1e4d | 185 | /** |
Davidroid | 8:42e0b00b1e4d | 186 | * @brief Going to a specified position. |
Davidroid | 8:42e0b00b1e4d | 187 | * @param position The desired position. |
Davidroid | 8:42e0b00b1e4d | 188 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 189 | */ |
Davidroid | 4:83a1eb397a65 | 190 | virtual void GoTo(signed int position) = 0; |
Davidroid | 4:83a1eb397a65 | 191 | |
Davidroid | 8:42e0b00b1e4d | 192 | /** |
Davidroid | 8:42e0b00b1e4d | 193 | * @brief Going to the home position. |
Davidroid | 8:42e0b00b1e4d | 194 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 195 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 196 | */ |
Davidroid | 4:83a1eb397a65 | 197 | virtual void GoHome(void) = 0; |
Davidroid | 4:83a1eb397a65 | 198 | |
Davidroid | 8:42e0b00b1e4d | 199 | /** |
Davidroid | 8:42e0b00b1e4d | 200 | * @brief Going to the marked position. |
Davidroid | 8:42e0b00b1e4d | 201 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 202 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 203 | */ |
Davidroid | 4:83a1eb397a65 | 204 | virtual void GoMark(void) = 0; |
Davidroid | 4:83a1eb397a65 | 205 | |
Davidroid | 8:42e0b00b1e4d | 206 | /** |
Davidroid | 8:42e0b00b1e4d | 207 | * @brief Running the motor towards a specified direction. |
Davidroid | 8:42e0b00b1e4d | 208 | * @param direction The direction of rotation. |
Davidroid | 8:42e0b00b1e4d | 209 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 210 | */ |
Davidroid | 4:83a1eb397a65 | 211 | virtual void Run(direction_t direction) = 0; |
Davidroid | 4:83a1eb397a65 | 212 | |
Davidroid | 8:42e0b00b1e4d | 213 | /** |
Davidroid | 8:42e0b00b1e4d | 214 | * @brief Moving the motor towards a specified direction for a certain number of steps. |
Davidroid | 8:42e0b00b1e4d | 215 | * @param direction The direction of rotation. |
Davidroid | 8:42e0b00b1e4d | 216 | * @param steps The desired number of steps. |
Davidroid | 8:42e0b00b1e4d | 217 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 218 | */ |
Davidroid | 4:83a1eb397a65 | 219 | virtual void Move(direction_t direction, unsigned int steps) = 0; |
Davidroid | 4:83a1eb397a65 | 220 | |
Davidroid | 8:42e0b00b1e4d | 221 | /** |
Davidroid | 8:42e0b00b1e4d | 222 | * @brief Stopping the motor. |
Davidroid | 8:42e0b00b1e4d | 223 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 224 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 225 | */ |
Davidroid | 4:83a1eb397a65 | 226 | virtual void SoftStop(void) = 0; |
Davidroid | 4:83a1eb397a65 | 227 | |
Davidroid | 8:42e0b00b1e4d | 228 | /** |
Davidroid | 8:42e0b00b1e4d | 229 | * @brief Stopping the motor and disabling the power bridge. |
Davidroid | 8:42e0b00b1e4d | 230 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 231 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 232 | */ |
Davidroid | 4:83a1eb397a65 | 233 | virtual void HardStop(void) = 0; |
Davidroid | 7:f7e0c3621f77 | 234 | |
Davidroid | 8:42e0b00b1e4d | 235 | /** |
Davidroid | 8:42e0b00b1e4d | 236 | * @brief Waiting while the motor is active. |
Davidroid | 8:42e0b00b1e4d | 237 | * @param None. |
Davidroid | 8:42e0b00b1e4d | 238 | * @retval None. |
Davidroid | 8:42e0b00b1e4d | 239 | */ |
Davidroid | 7:f7e0c3621f77 | 240 | virtual void WaitWhileActive(void) = 0; |
Davidroid | 4:83a1eb397a65 | 241 | }; |
Davidroid | 4:83a1eb397a65 | 242 | |
Davidroid | 4:83a1eb397a65 | 243 | #endif /* __STEPPERMOTOR_CLASS_H */ |
Davidroid | 4:83a1eb397a65 | 244 | |
Davidroid | 4:83a1eb397a65 | 245 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |