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