motor control

Dependents:   1-DoorCloser

Fork of X_NUCLEO_IHM01A1 by Robotique FIP

Committer:
Davidroid
Date:
Wed Nov 18 18:41:55 2015 +0000
Revision:
5:d3c78f12a78d
Parent:
4:83a1eb397a65
Child:
7:f7e0c3621f77
+ SPI registers set as static variables and as arrays of MAX_NUMBER_OF_DEVICES, in order to support daisy-chain configuration.; + Direction type "StepperMotor::direction_t" modified.

Who changed what in which revision?

UserRevisionLine numberNew 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 4:83a1eb397a65 8 * steppermotor component.
Davidroid 4:83a1eb397a65 9 ******************************************************************************
Davidroid 4:83a1eb397a65 10 * @attention
Davidroid 4:83a1eb397a65 11 *
Davidroid 4:83a1eb397a65 12 * <h2><center>&copy; 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 4:83a1eb397a65 65 /* Get the status. */
Davidroid 4:83a1eb397a65 66 virtual unsigned int GetStatus(void) = 0;
Davidroid 4:83a1eb397a65 67
Davidroid 4:83a1eb397a65 68 /* Get the specified parameter. */
Davidroid 4:83a1eb397a65 69 virtual unsigned int GetParameter(unsigned int parameter) = 0;
Davidroid 4:83a1eb397a65 70
Davidroid 4:83a1eb397a65 71 /* Return the current position. */
Davidroid 4:83a1eb397a65 72 virtual signed int GetPosition(void) = 0;
Davidroid 4:83a1eb397a65 73
Davidroid 4:83a1eb397a65 74 /* Return the mark position. */
Davidroid 4:83a1eb397a65 75 virtual signed int GetMark(void) = 0;
Davidroid 4:83a1eb397a65 76
Davidroid 4:83a1eb397a65 77 /* Return the current speed in pps. */
Davidroid 4:83a1eb397a65 78 virtual unsigned int GetSpeed(void) = 0;
Davidroid 4:83a1eb397a65 79
Davidroid 4:83a1eb397a65 80 /* Return the maximum speed in pps. */
Davidroid 4:83a1eb397a65 81 virtual unsigned int GetMaxSpeed(void) = 0;
Davidroid 4:83a1eb397a65 82
Davidroid 4:83a1eb397a65 83 /* Return the minimum speed in pps. */
Davidroid 4:83a1eb397a65 84 virtual unsigned int GetMinSpeed(void) = 0;
Davidroid 4:83a1eb397a65 85
Davidroid 4:83a1eb397a65 86 /* Return the acceleration in pps^2. */
Davidroid 4:83a1eb397a65 87 virtual unsigned int GetAcceleration(void) = 0;
Davidroid 4:83a1eb397a65 88
Davidroid 4:83a1eb397a65 89 /* Return the deceleration in pps^2. */
Davidroid 4:83a1eb397a65 90 virtual unsigned int GetDeceleration(void) = 0;
Davidroid 4:83a1eb397a65 91
Davidroid 5:d3c78f12a78d 92 /* Get the current direction of rotation. */
Davidroid 5:d3c78f12a78d 93 virtual direction_t GetDirection(void) = 0;
Davidroid 5:d3c78f12a78d 94
Davidroid 4:83a1eb397a65 95 /* Set the specified parameter. */
Davidroid 4:83a1eb397a65 96 virtual void SetParameter(unsigned int parameter, unsigned int value) = 0;
Davidroid 4:83a1eb397a65 97
Davidroid 4:83a1eb397a65 98 /* Set the current position to be the home position. */
Davidroid 4:83a1eb397a65 99 virtual void SetHome(void) = 0;
Davidroid 4:83a1eb397a65 100
Davidroid 4:83a1eb397a65 101 /* Set the current position to be the mark position. */
Davidroid 4:83a1eb397a65 102 virtual void SetMark(void) = 0;
Davidroid 4:83a1eb397a65 103
Davidroid 4:83a1eb397a65 104 /* Set the maximum speed in pps. */
Davidroid 4:83a1eb397a65 105 virtual void SetMaxSpeed(unsigned int speed) = 0;
Davidroid 4:83a1eb397a65 106
Davidroid 4:83a1eb397a65 107 /* Set the minimum speed in pps. */
Davidroid 4:83a1eb397a65 108 virtual void SetMinSpeed(unsigned int speed) = 0;
Davidroid 4:83a1eb397a65 109
Davidroid 4:83a1eb397a65 110 /* Set the acceleration in pps^2. */
Davidroid 4:83a1eb397a65 111 virtual void SetAcceleration(unsigned int acceleration) = 0;
Davidroid 4:83a1eb397a65 112
Davidroid 4:83a1eb397a65 113 /* Set the deceleration in pps^2. */
Davidroid 4:83a1eb397a65 114 virtual void SetDeceleration(unsigned int deceleration) = 0;
Davidroid 4:83a1eb397a65 115
Davidroid 4:83a1eb397a65 116 /* Go to the specified position. */
Davidroid 4:83a1eb397a65 117 virtual void GoTo(signed int position) = 0;
Davidroid 4:83a1eb397a65 118
Davidroid 4:83a1eb397a65 119 /* Go to the home position. */
Davidroid 4:83a1eb397a65 120 virtual void GoHome(void) = 0;
Davidroid 4:83a1eb397a65 121
Davidroid 4:83a1eb397a65 122 /* Go to the marked position. */
Davidroid 4:83a1eb397a65 123 virtual void GoMark(void) = 0;
Davidroid 4:83a1eb397a65 124
Davidroid 4:83a1eb397a65 125 /* Run the motor towards a specified direction. */
Davidroid 4:83a1eb397a65 126 virtual void Run(direction_t direction) = 0;
Davidroid 4:83a1eb397a65 127
Davidroid 4:83a1eb397a65 128 /* Run the motor towards a specified direction for a specified number of steps. */
Davidroid 4:83a1eb397a65 129 virtual void Move(direction_t direction, unsigned int steps) = 0;
Davidroid 4:83a1eb397a65 130
Davidroid 4:83a1eb397a65 131 /* Stop the motor. */
Davidroid 4:83a1eb397a65 132 virtual void SoftStop(void) = 0;
Davidroid 4:83a1eb397a65 133
Davidroid 4:83a1eb397a65 134 /* Stop the motor and disable the power bridge. */
Davidroid 4:83a1eb397a65 135 virtual void HardStop(void) = 0;
Davidroid 4:83a1eb397a65 136 };
Davidroid 4:83a1eb397a65 137
Davidroid 4:83a1eb397a65 138 #endif /* __STEPPERMOTOR_CLASS_H */
Davidroid 4:83a1eb397a65 139
Davidroid 4:83a1eb397a65 140 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/