Expansion SW library to control a bipolar stepper motor using X-NUCLEO-IHM05A1 expansion board based on L6208.
Dependencies: ST_INTERFACES
Dependents: HelloWorld_IHM05A1 TAU_ROTATING_PLATFORM_IHM05A1 Amaldi_13_Exercise_IHM05A1 Amaldi_13_Exercise_IHM05A1motore ... more
Fork of X-NUCLEO-IHM05A1 by
Motor Control Library
Library to handle the X-NUCLEO-IHM05A1 Motor Control Expansion Board based on the L6208 component.
It features the:
- Read and write of device parameters
- Configuration of GPIOs and IRQs (for enabling, direction, current decay and microstepping)
- Control of position, speed, acceleration and deceleration
- Command locking until the device completes movement
- Handling of overcurrent and thermal alarms (flag interrupt handling)
The API allows to easily:
- perform various positioning, moves and stops
- get/set or monitor the motor positions
- set home position and mark another position
- get/set minimum and maximum speed
- get current speed
- get/set acceleration and deceleration
- get/set the step mode (up to 1/16)
Board configuration
Platform compatibility
Compatible platforms have been tested with the configurations provided by the HelloWorld_IHM05A1 example.
Components/l6208/l6208.h@1:5cc2691ccfff, 2016-04-27 (annotated)
- Committer:
- nucleosam
- Date:
- Wed Apr 27 16:30:55 2016 +0000
- Revision:
- 1:5cc2691ccfff
- Parent:
- 0:52a66fac0f64
- Child:
- 3:63a8d672fe5e
Initial version tested on NUCLEO-F401RE and NUCLEO-F334R8
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| nucleosam | 1:5cc2691ccfff | 1 | /******************************************************//** |
| nucleosam | 1:5cc2691ccfff | 2 | * @file l6208.h |
| nucleosam | 1:5cc2691ccfff | 3 | * @author IPC Rennes |
| nucleosam | 1:5cc2691ccfff | 4 | * @version V1.1.0 |
| nucleosam | 1:5cc2691ccfff | 5 | * @date February 11th, 2016 |
| nucleosam | 1:5cc2691ccfff | 6 | * @brief Header for l6208.c module |
| nucleosam | 1:5cc2691ccfff | 7 | * @note (C) COPYRIGHT 2016 STMicroelectronics |
| nucleosam | 1:5cc2691ccfff | 8 | ****************************************************************************** |
| nucleosam | 1:5cc2691ccfff | 9 | * @attention |
| nucleosam | 1:5cc2691ccfff | 10 | * |
| nucleosam | 1:5cc2691ccfff | 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
| nucleosam | 1:5cc2691ccfff | 12 | * |
| nucleosam | 1:5cc2691ccfff | 13 | * Redistribution and use in source and binary forms, with or without modification, |
| nucleosam | 1:5cc2691ccfff | 14 | * are permitted provided that the following conditions are met: |
| nucleosam | 1:5cc2691ccfff | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
| nucleosam | 1:5cc2691ccfff | 16 | * this list of conditions and the following disclaimer. |
| nucleosam | 1:5cc2691ccfff | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| nucleosam | 1:5cc2691ccfff | 18 | * this list of conditions and the following disclaimer in the documentation |
| nucleosam | 1:5cc2691ccfff | 19 | * and/or other materials provided with the distribution. |
| nucleosam | 1:5cc2691ccfff | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| nucleosam | 1:5cc2691ccfff | 21 | * may be used to endorse or promote products derived from this software |
| nucleosam | 1:5cc2691ccfff | 22 | * without specific prior written permission. |
| nucleosam | 1:5cc2691ccfff | 23 | * |
| nucleosam | 1:5cc2691ccfff | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| nucleosam | 1:5cc2691ccfff | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| nucleosam | 1:5cc2691ccfff | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| nucleosam | 1:5cc2691ccfff | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| nucleosam | 1:5cc2691ccfff | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| nucleosam | 1:5cc2691ccfff | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| nucleosam | 1:5cc2691ccfff | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| nucleosam | 1:5cc2691ccfff | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| nucleosam | 1:5cc2691ccfff | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| nucleosam | 1:5cc2691ccfff | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| nucleosam | 1:5cc2691ccfff | 34 | * |
| nucleosam | 1:5cc2691ccfff | 35 | ****************************************************************************** |
| nucleosam | 1:5cc2691ccfff | 36 | */ |
| nucleosam | 1:5cc2691ccfff | 37 | |
| nucleosam | 1:5cc2691ccfff | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
| nucleosam | 1:5cc2691ccfff | 39 | #ifndef _L6208_H_INCLUDED |
| nucleosam | 1:5cc2691ccfff | 40 | #define _L6208_H_INCLUDED |
| nucleosam | 1:5cc2691ccfff | 41 | |
| nucleosam | 1:5cc2691ccfff | 42 | #ifdef __cplusplus |
| nucleosam | 1:5cc2691ccfff | 43 | extern "C" { |
| nucleosam | 1:5cc2691ccfff | 44 | #endif |
| nucleosam | 1:5cc2691ccfff | 45 | |
| nucleosam | 1:5cc2691ccfff | 46 | /* Includes ------------------------------------------------------------------*/ |
| nucleosam | 1:5cc2691ccfff | 47 | #include "l6208_target_config.h" |
| nucleosam | 1:5cc2691ccfff | 48 | #include "motor.h" |
| nucleosam | 1:5cc2691ccfff | 49 | |
| nucleosam | 1:5cc2691ccfff | 50 | /* Definitions ---------------------------------------------------------------*/ |
| nucleosam | 1:5cc2691ccfff | 51 | |
| nucleosam | 1:5cc2691ccfff | 52 | /** @addtogroup Components |
| nucleosam | 1:5cc2691ccfff | 53 | * @{ |
| nucleosam | 1:5cc2691ccfff | 54 | */ |
| nucleosam | 1:5cc2691ccfff | 55 | |
| nucleosam | 1:5cc2691ccfff | 56 | /** @defgroup L6208 |
| nucleosam | 1:5cc2691ccfff | 57 | * @{ |
| nucleosam | 1:5cc2691ccfff | 58 | */ |
| nucleosam | 1:5cc2691ccfff | 59 | |
| nucleosam | 1:5cc2691ccfff | 60 | /** @defgroup L6208_Exported_Defines L6208 Exported Defines |
| nucleosam | 1:5cc2691ccfff | 61 | * @{ |
| nucleosam | 1:5cc2691ccfff | 62 | */ |
| nucleosam | 1:5cc2691ccfff | 63 | /// Current FW major version |
| nucleosam | 1:5cc2691ccfff | 64 | #define L6208_FW_MAJOR_VERSION (uint8_t)(1) |
| nucleosam | 1:5cc2691ccfff | 65 | /// Current FW minor version |
| nucleosam | 1:5cc2691ccfff | 66 | #define L6208_FW_MINOR_VERSION (uint8_t)(1) |
| nucleosam | 1:5cc2691ccfff | 67 | /// Current FW patch version |
| nucleosam | 1:5cc2691ccfff | 68 | #define L6208_FW_PATCH_VERSION (uint8_t)(0) |
| nucleosam | 1:5cc2691ccfff | 69 | /// Current FW version |
| nucleosam | 1:5cc2691ccfff | 70 | #define L6208_FW_VERSION (uint32_t)((L6208_FW_MAJOR_VERSION<<16)|\ |
| nucleosam | 1:5cc2691ccfff | 71 | (L6208_FW_MINOR_VERSION<<8)|\ |
| nucleosam | 1:5cc2691ccfff | 72 | (L6208_FW_PATCH_VERSION)) |
| nucleosam | 1:5cc2691ccfff | 73 | |
| nucleosam | 1:5cc2691ccfff | 74 | /// Exponent used to scale the sine function for the RefMicroTable |
| nucleosam | 1:5cc2691ccfff | 75 | #define L6208_SINE_WAVEFORM_POWER_OF_TWO_MAX_VALUE (15) |
| nucleosam | 1:5cc2691ccfff | 76 | |
| nucleosam | 1:5cc2691ccfff | 77 | /// Tick frequency (Hz) |
| nucleosam | 1:5cc2691ccfff | 78 | #define TIMER_TICK_FREQUENCY (10000) |
| nucleosam | 1:5cc2691ccfff | 79 | |
| nucleosam | 1:5cc2691ccfff | 80 | /// MCU wait time after power bridges are enabled |
| nucleosam | 1:5cc2691ccfff | 81 | #define BRIDGE_TURN_ON_DELAY (10) |
| nucleosam | 1:5cc2691ccfff | 82 | |
| nucleosam | 1:5cc2691ccfff | 83 | /// The maximum number of devices |
| nucleosam | 1:5cc2691ccfff | 84 | #define MAX_NUMBER_OF_DEVICES (1) |
| nucleosam | 1:5cc2691ccfff | 85 | |
| nucleosam | 1:5cc2691ccfff | 86 | /// Max position |
| nucleosam | 1:5cc2691ccfff | 87 | #define L6208_MAX_POSITION (0x7FFFFFFF) |
| nucleosam | 1:5cc2691ccfff | 88 | |
| nucleosam | 1:5cc2691ccfff | 89 | /// Min position |
| nucleosam | 1:5cc2691ccfff | 90 | #define L6208_MIN_POSITION (0x80000000) |
| nucleosam | 1:5cc2691ccfff | 91 | |
| nucleosam | 1:5cc2691ccfff | 92 | /// Position range |
| nucleosam | 1:5cc2691ccfff | 93 | #define L6208_POSITION_RANGE ((uint32_t)(L6208_MAX_POSITION -\ |
| nucleosam | 1:5cc2691ccfff | 94 | L6208_MIN_POSITION)) |
| nucleosam | 1:5cc2691ccfff | 95 | /// micro step samples per period/4 |
| nucleosam | 1:5cc2691ccfff | 96 | #define L6208_USTEPS_PER_QUARTER_PERIOD (16) |
| nucleosam | 1:5cc2691ccfff | 97 | |
| nucleosam | 1:5cc2691ccfff | 98 | /// minimum speed |
| nucleosam | 1:5cc2691ccfff | 99 | #define L6208_MIN_SPEED (16) |
| nucleosam | 1:5cc2691ccfff | 100 | |
| nucleosam | 1:5cc2691ccfff | 101 | /// minimum acceleration and deceleration rate |
| nucleosam | 1:5cc2691ccfff | 102 | #define L6208_MIN_ACC_DEC_RATE (24) |
| nucleosam | 1:5cc2691ccfff | 103 | |
| nucleosam | 1:5cc2691ccfff | 104 | /// Mask for HiZ bit in motorDecayMode_t enum |
| nucleosam | 1:5cc2691ccfff | 105 | #define L6208_FAST_DECAY_MODE_MASK (0x1) |
| nucleosam | 1:5cc2691ccfff | 106 | |
| nucleosam | 1:5cc2691ccfff | 107 | /// L6208 error base number |
| nucleosam | 1:5cc2691ccfff | 108 | #define L6208_ERROR_BASE (0x9000) |
| nucleosam | 1:5cc2691ccfff | 109 | /** |
| nucleosam | 1:5cc2691ccfff | 110 | * @} |
| nucleosam | 1:5cc2691ccfff | 111 | */ |
| nucleosam | 1:5cc2691ccfff | 112 | |
| nucleosam | 1:5cc2691ccfff | 113 | /* Types ---------------------------------------------------------------------*/ |
| nucleosam | 1:5cc2691ccfff | 114 | |
| nucleosam | 1:5cc2691ccfff | 115 | /** @defgroup L6208_Exported_Types L6208 Exported Types |
| nucleosam | 1:5cc2691ccfff | 116 | * @{ |
| nucleosam | 1:5cc2691ccfff | 117 | */ |
| nucleosam | 1:5cc2691ccfff | 118 | |
| nucleosam | 1:5cc2691ccfff | 119 | /** @defgroup Error_Types Error Types |
| nucleosam | 1:5cc2691ccfff | 120 | * @{ |
| nucleosam | 1:5cc2691ccfff | 121 | */ |
| nucleosam | 1:5cc2691ccfff | 122 | /// Errors |
| nucleosam | 1:5cc2691ccfff | 123 | typedef enum { |
| nucleosam | 1:5cc2691ccfff | 124 | L6208_ERROR_SET_HOME = L6208_ERROR_BASE, /// Error while setting home position |
| nucleosam | 1:5cc2691ccfff | 125 | L6208_ERROR_SET_MAX_SPEED = L6208_ERROR_BASE + 1, /// Error while setting max speed |
| nucleosam | 1:5cc2691ccfff | 126 | L6208_ERROR_SET_MIN_SPEED = L6208_ERROR_BASE + 2, /// Error while setting min speed |
| nucleosam | 1:5cc2691ccfff | 127 | L6208_ERROR_SET_ACCELERATION = L6208_ERROR_BASE + 3, /// Error while setting acceleration |
| nucleosam | 1:5cc2691ccfff | 128 | L6208_ERROR_SET_DECELERATION = L6208_ERROR_BASE + 4, /// Error while setting decelaration |
| nucleosam | 1:5cc2691ccfff | 129 | L6208_ERROR_MCU_OSC_CONFIG = L6208_ERROR_BASE + 5, /// Error while configuring mcu oscillator |
| nucleosam | 1:5cc2691ccfff | 130 | L6208_ERROR_MCU_CLOCK_CONFIG = L6208_ERROR_BASE + 6, /// Error while configuring mcu clock |
| nucleosam | 1:5cc2691ccfff | 131 | L6208_ERROR_POSITION = L6208_ERROR_BASE + 7, /// Unexpected current position (wrong number of steps) |
| nucleosam | 1:5cc2691ccfff | 132 | L6208_ERROR_SPEED = L6208_ERROR_BASE + 8, /// Unexpected current speed |
| nucleosam | 1:5cc2691ccfff | 133 | L6208_ERROR_INIT = L6208_ERROR_BASE + 9, /// Unexpected number of devices |
| nucleosam | 1:5cc2691ccfff | 134 | L6208_ERROR_SET_DIRECTION = L6208_ERROR_BASE + 10,/// Error while setting direction |
| nucleosam | 1:5cc2691ccfff | 135 | L6208_ERROR_SET_STEP_MODE = L6208_ERROR_BASE + 11,/// Attempt to set an unsupported step mode |
| nucleosam | 1:5cc2691ccfff | 136 | L6208_ERROR_SET_PWM = L6208_ERROR_BASE + 12,/// Error while setting a PWM parameter |
| nucleosam | 1:5cc2691ccfff | 137 | }errorTypes_t; |
| nucleosam | 1:5cc2691ccfff | 138 | /** |
| nucleosam | 1:5cc2691ccfff | 139 | * @} |
| nucleosam | 1:5cc2691ccfff | 140 | */ |
| nucleosam | 1:5cc2691ccfff | 141 | |
| nucleosam | 1:5cc2691ccfff | 142 | /** @defgroup Device_Parameters Device Parameters |
| nucleosam | 1:5cc2691ccfff | 143 | * @{ |
| nucleosam | 1:5cc2691ccfff | 144 | */ |
| nucleosam | 1:5cc2691ccfff | 145 | /// Device Parameters Structure Type |
| nucleosam | 1:5cc2691ccfff | 146 | typedef struct |
| nucleosam | 1:5cc2691ccfff | 147 | { |
| nucleosam | 1:5cc2691ccfff | 148 | /// dwelling waiting time counter (tick) |
| nucleosam | 1:5cc2691ccfff | 149 | volatile uint32_t dwellCounter; |
| nucleosam | 1:5cc2691ccfff | 150 | /// motor position indicator (tick) |
| nucleosam | 1:5cc2691ccfff | 151 | uint32_t ticks; |
| nucleosam | 1:5cc2691ccfff | 152 | /// LSByte copy of the previous position (tick) |
| nucleosam | 1:5cc2691ccfff | 153 | uint8_t lsbOldTicks; |
| nucleosam | 1:5cc2691ccfff | 154 | /// LSByte copy of the previous position (tick) ( micro stepping ) |
| nucleosam | 1:5cc2691ccfff | 155 | uint8_t lsbOldUSteppingTicks; |
| nucleosam | 1:5cc2691ccfff | 156 | /// LSByte copy of the current position (tick) |
| nucleosam | 1:5cc2691ccfff | 157 | uint8_t lsbTicks; |
| nucleosam | 1:5cc2691ccfff | 158 | /// P1 = acceleration phase steps number (motor position control mode) |
| nucleosam | 1:5cc2691ccfff | 159 | uint32_t positionTarget1; |
| nucleosam | 1:5cc2691ccfff | 160 | /// P2 = constant speed steps number (motor position control mode) |
| nucleosam | 1:5cc2691ccfff | 161 | uint32_t positionTarget2; |
| nucleosam | 1:5cc2691ccfff | 162 | /// P3 = deceleration phase steps number (motor position control mode) |
| nucleosam | 1:5cc2691ccfff | 163 | uint32_t positionTarget3; |
| nucleosam | 1:5cc2691ccfff | 164 | /// P = total move distance in steps (motor position control mode) |
| nucleosam | 1:5cc2691ccfff | 165 | uint32_t positionTarget; |
| nucleosam | 1:5cc2691ccfff | 166 | /// absolute motor position in microsteps (motor position control mode) |
| nucleosam | 1:5cc2691ccfff | 167 | volatile int32_t absolutePos; |
| nucleosam | 1:5cc2691ccfff | 168 | /// mark position in microsteps (motor position control mode) |
| nucleosam | 1:5cc2691ccfff | 169 | volatile int32_t markPos; |
| nucleosam | 1:5cc2691ccfff | 170 | /// motor position in microsteps (motor position control mode) |
| nucleosam | 1:5cc2691ccfff | 171 | volatile uint32_t step; |
| nucleosam | 1:5cc2691ccfff | 172 | /// dwelling time after position got (ms) |
| nucleosam | 1:5cc2691ccfff | 173 | volatile uint16_t moveDwellTime; |
| nucleosam | 1:5cc2691ccfff | 174 | /// number of micro stepping waveform samples to be rescaled according to selected torque value |
| nucleosam | 1:5cc2691ccfff | 175 | volatile uint8_t uStepsample2scale; |
| nucleosam | 1:5cc2691ccfff | 176 | /// number of micro stepping waveform samples to be updated into the waveform scanning table |
| nucleosam | 1:5cc2691ccfff | 177 | volatile uint8_t uStepsample2update; |
| nucleosam | 1:5cc2691ccfff | 178 | /// microstepping waveform sample index |
| nucleosam | 1:5cc2691ccfff | 179 | volatile uint8_t uStepSample; |
| nucleosam | 1:5cc2691ccfff | 180 | /// system status flags |
| nucleosam | 1:5cc2691ccfff | 181 | volatile uint32_t flags; |
| nucleosam | 1:5cc2691ccfff | 182 | /// current stepper state machine index |
| nucleosam | 1:5cc2691ccfff | 183 | volatile motorState_t motionState; |
| nucleosam | 1:5cc2691ccfff | 184 | /// current step mode |
| nucleosam | 1:5cc2691ccfff | 185 | volatile motorStepMode_t stepMode; |
| nucleosam | 1:5cc2691ccfff | 186 | /// micro stepping waveform scanning sample index increment |
| nucleosam | 1:5cc2691ccfff | 187 | uint8_t uStepInc; |
| nucleosam | 1:5cc2691ccfff | 188 | /// frequency of the VREFA and VREFB PWM |
| nucleosam | 1:5cc2691ccfff | 189 | uint32_t vrefPwmFreq; |
| nucleosam | 1:5cc2691ccfff | 190 | /// period of the VREFA and VREFB PWM in 1/256th of a microsecond |
| nucleosam | 1:5cc2691ccfff | 191 | uint16_t vrefPwmPeriod; |
| nucleosam | 1:5cc2691ccfff | 192 | /// pulse width target of the VREFA PWM in 1/256th of a microsecond |
| nucleosam | 1:5cc2691ccfff | 193 | volatile uint16_t vrefPwmPulseWidthTargetA; |
| nucleosam | 1:5cc2691ccfff | 194 | /// pulse width target of the VREFB PWM in 1/256th of a microsecond |
| nucleosam | 1:5cc2691ccfff | 195 | volatile uint16_t vrefPwmPulseWidthTargetB; |
| nucleosam | 1:5cc2691ccfff | 196 | /// pulse width to be generated for VREFA PWM in 1/256th of a microsecond |
| nucleosam | 1:5cc2691ccfff | 197 | volatile int16_t vrefPwmPulseWidthToBeGeneratedA; |
| nucleosam | 1:5cc2691ccfff | 198 | /// pulse width to be generated for VREFB PWM in 1/256th of a microsecond |
| nucleosam | 1:5cc2691ccfff | 199 | volatile int16_t vrefPwmPulseWidthToBeGeneratedB; |
| nucleosam | 1:5cc2691ccfff | 200 | /// current selected torque value |
| nucleosam | 1:5cc2691ccfff | 201 | volatile uint16_t curTorqueScaler; |
| nucleosam | 1:5cc2691ccfff | 202 | /// selected VREFA value (%) |
| nucleosam | 1:5cc2691ccfff | 203 | volatile uint16_t vRefAVal; |
| nucleosam | 1:5cc2691ccfff | 204 | /// selected VREFB value (%) |
| nucleosam | 1:5cc2691ccfff | 205 | volatile uint16_t vRefBVal; |
| nucleosam | 1:5cc2691ccfff | 206 | /// constant speed phase torque value (%) |
| nucleosam | 1:5cc2691ccfff | 207 | volatile uint8_t runTorque; |
| nucleosam | 1:5cc2691ccfff | 208 | /// acceleration phase torque value (%) |
| nucleosam | 1:5cc2691ccfff | 209 | volatile uint8_t accelTorque; |
| nucleosam | 1:5cc2691ccfff | 210 | /// deceleration phase torque value (%) |
| nucleosam | 1:5cc2691ccfff | 211 | volatile uint8_t decelTorque; |
| nucleosam | 1:5cc2691ccfff | 212 | /// holding phase torque value (%) |
| nucleosam | 1:5cc2691ccfff | 213 | volatile uint8_t holdTorque; |
| nucleosam | 1:5cc2691ccfff | 214 | /// acceleration (steps/s^2) |
| nucleosam | 1:5cc2691ccfff | 215 | volatile uint16_t accelerationSps2; |
| nucleosam | 1:5cc2691ccfff | 216 | /// deceleration (steps/s^2) |
| nucleosam | 1:5cc2691ccfff | 217 | volatile uint16_t decelerationSps2; |
| nucleosam | 1:5cc2691ccfff | 218 | /// acceleration (steps/tick^2) |
| nucleosam | 1:5cc2691ccfff | 219 | volatile uint16_t accelerationSpt2; |
| nucleosam | 1:5cc2691ccfff | 220 | /// deceleration (steps/tick^2) |
| nucleosam | 1:5cc2691ccfff | 221 | volatile uint16_t decelerationSpt2; |
| nucleosam | 1:5cc2691ccfff | 222 | /// maximum speed (steps/s) |
| nucleosam | 1:5cc2691ccfff | 223 | volatile uint16_t maxSpeedSps; |
| nucleosam | 1:5cc2691ccfff | 224 | /// minimum speed (steps/s) |
| nucleosam | 1:5cc2691ccfff | 225 | volatile uint16_t minSpeedSps; |
| nucleosam | 1:5cc2691ccfff | 226 | /// current speed (steps/s) |
| nucleosam | 1:5cc2691ccfff | 227 | volatile uint16_t speedSps; |
| nucleosam | 1:5cc2691ccfff | 228 | /// maximum speed (steps/tick) |
| nucleosam | 1:5cc2691ccfff | 229 | volatile uint32_t maxSpeedSpt; |
| nucleosam | 1:5cc2691ccfff | 230 | /// minimum speed (steps/tick) |
| nucleosam | 1:5cc2691ccfff | 231 | volatile uint32_t minSpeedSpt; |
| nucleosam | 1:5cc2691ccfff | 232 | /// current speed (steps/tick) |
| nucleosam | 1:5cc2691ccfff | 233 | volatile uint32_t speedSpt; |
| nucleosam | 1:5cc2691ccfff | 234 | }deviceParams_t; |
| nucleosam | 1:5cc2691ccfff | 235 | /** |
| nucleosam | 1:5cc2691ccfff | 236 | * @} |
| nucleosam | 1:5cc2691ccfff | 237 | */ |
| nucleosam | 1:5cc2691ccfff | 238 | |
| nucleosam | 1:5cc2691ccfff | 239 | /// Motor driver initialization structure definition |
| nucleosam | 1:5cc2691ccfff | 240 | typedef struct |
| nucleosam | 1:5cc2691ccfff | 241 | { |
| nucleosam | 1:5cc2691ccfff | 242 | /// acceleration (steps/s^2) |
| nucleosam | 1:5cc2691ccfff | 243 | uint16_t accelerationSps2; |
| nucleosam | 1:5cc2691ccfff | 244 | /// acceleration phase torque value (%) |
| nucleosam | 1:5cc2691ccfff | 245 | uint8_t accelTorque; |
| nucleosam | 1:5cc2691ccfff | 246 | /// deceleration (steps/s^2) |
| nucleosam | 1:5cc2691ccfff | 247 | uint16_t decelerationSps2; |
| nucleosam | 1:5cc2691ccfff | 248 | /// deceleration phase torque value (%) |
| nucleosam | 1:5cc2691ccfff | 249 | uint8_t decelTorque; |
| nucleosam | 1:5cc2691ccfff | 250 | /// maximum speed (steps/s) |
| nucleosam | 1:5cc2691ccfff | 251 | uint16_t maxSpeedSps; |
| nucleosam | 1:5cc2691ccfff | 252 | /// constant speed phase torque value (%) |
| nucleosam | 1:5cc2691ccfff | 253 | uint8_t runTorque; |
| nucleosam | 1:5cc2691ccfff | 254 | /// holding phase torque value (%) |
| nucleosam | 1:5cc2691ccfff | 255 | uint8_t holdTorque; |
| nucleosam | 1:5cc2691ccfff | 256 | /// current step mode |
| nucleosam | 1:5cc2691ccfff | 257 | motorStepMode_t stepMode; |
| nucleosam | 1:5cc2691ccfff | 258 | /// current decay mode (SLOW_DECAY or FAST_DECAY) |
| nucleosam | 1:5cc2691ccfff | 259 | motorDecayMode_t decayMode; |
| nucleosam | 1:5cc2691ccfff | 260 | /// dwelling time after position got (ms) |
| nucleosam | 1:5cc2691ccfff | 261 | uint16_t moveDwellTime; |
| nucleosam | 1:5cc2691ccfff | 262 | /// automatic HiZ on stop |
| nucleosam | 1:5cc2691ccfff | 263 | bool autoHiZstop; |
| nucleosam | 1:5cc2691ccfff | 264 | /// frequency of the VREFA and VREFB PWM |
| nucleosam | 1:5cc2691ccfff | 265 | uint32_t vrefPwmFreq; |
| nucleosam | 1:5cc2691ccfff | 266 | } l6208_Init_t; |
| nucleosam | 1:5cc2691ccfff | 267 | /** |
| nucleosam | 1:5cc2691ccfff | 268 | * @} |
| nucleosam | 1:5cc2691ccfff | 269 | */ |
| nucleosam | 1:5cc2691ccfff | 270 | |
| nucleosam | 1:5cc2691ccfff | 271 | /* Functions --------------------------------------------------------*/ |
| nucleosam | 1:5cc2691ccfff | 272 | |
| nucleosam | 1:5cc2691ccfff | 273 | /** @defgroup MotorControl_Board_Linked_Functions MotorControl Board Linked Functions |
| nucleosam | 1:5cc2691ccfff | 274 | * @{ |
| nucleosam | 1:5cc2691ccfff | 275 | */ |
| nucleosam | 1:5cc2691ccfff | 276 | ///Delay of the requested number of milliseconds |
| nucleosam | 1:5cc2691ccfff | 277 | extern void L6208_Board_Delay(uint32_t delay); |
| nucleosam | 1:5cc2691ccfff | 278 | ///Enable Irq |
| nucleosam | 1:5cc2691ccfff | 279 | extern void L6208_Board_EnableIrq(void); |
| nucleosam | 1:5cc2691ccfff | 280 | ///Disable Irq |
| nucleosam | 1:5cc2691ccfff | 281 | extern void L6208_Board_DisableIrq(void); |
| nucleosam | 1:5cc2691ccfff | 282 | //Initialize the VREFA or VREFB PWM |
| nucleosam | 1:5cc2691ccfff | 283 | extern bool L6208_Board_VrefPwmInit(uint8_t bridgeId, uint32_t pwmFreq); |
| nucleosam | 1:5cc2691ccfff | 284 | ///Initialize the tick |
| nucleosam | 1:5cc2691ccfff | 285 | extern void L6208_Board_TickInit(void); |
| nucleosam | 1:5cc2691ccfff | 286 | ///Release the reset pin |
| nucleosam | 1:5cc2691ccfff | 287 | extern void L6208_Board_ReleaseReset(void); |
| nucleosam | 1:5cc2691ccfff | 288 | ///Set the reset pin |
| nucleosam | 1:5cc2691ccfff | 289 | extern void L6208_Board_Reset(void); |
| nucleosam | 1:5cc2691ccfff | 290 | ///Set the control pin |
| nucleosam | 1:5cc2691ccfff | 291 | extern void L6208_Board_CONTROL_PIN_Set(void); |
| nucleosam | 1:5cc2691ccfff | 292 | ///Reset the control pin |
| nucleosam | 1:5cc2691ccfff | 293 | extern void L6208_Board_CONTROL_PIN_Reset(void); |
| nucleosam | 1:5cc2691ccfff | 294 | ///Set the clock pin |
| nucleosam | 1:5cc2691ccfff | 295 | extern void L6208_Board_CLOCK_PIN_Set(void); |
| nucleosam | 1:5cc2691ccfff | 296 | ///Reset the clock pin |
| nucleosam | 1:5cc2691ccfff | 297 | extern void L6208_Board_CLOCK_PIN_Reset(void); |
| nucleosam | 1:5cc2691ccfff | 298 | ///Set the half full pin |
| nucleosam | 1:5cc2691ccfff | 299 | extern void L6208_Board_HALF_FULL_PIN_Set(void); |
| nucleosam | 1:5cc2691ccfff | 300 | ///Reset the half full pin |
| nucleosam | 1:5cc2691ccfff | 301 | extern void L6208_Board_HALF_FULL_PIN_Reset(void); |
| nucleosam | 1:5cc2691ccfff | 302 | ///Set the dir pin |
| nucleosam | 1:5cc2691ccfff | 303 | extern void L6208_Board_DIR_PIN_Set(void); |
| nucleosam | 1:5cc2691ccfff | 304 | ///Reset the dir pin |
| nucleosam | 1:5cc2691ccfff | 305 | extern void L6208_Board_DIR_PIN_Reset(void); |
| nucleosam | 1:5cc2691ccfff | 306 | ///Enable the power bridges (leave the output bridges HiZ) |
| nucleosam | 1:5cc2691ccfff | 307 | extern void L6208_Board_Enable(void); |
| nucleosam | 1:5cc2691ccfff | 308 | ///Disable the power bridges (leave the output bridges HiZ) |
| nucleosam | 1:5cc2691ccfff | 309 | extern void L6208_Board_Disable(void); |
| nucleosam | 1:5cc2691ccfff | 310 | /** |
| nucleosam | 1:5cc2691ccfff | 311 | * @} |
| nucleosam | 1:5cc2691ccfff | 312 | */ |
| nucleosam | 1:5cc2691ccfff | 313 | |
| nucleosam | 1:5cc2691ccfff | 314 | /** |
| nucleosam | 1:5cc2691ccfff | 315 | * @} |
| nucleosam | 1:5cc2691ccfff | 316 | */ |
| nucleosam | 1:5cc2691ccfff | 317 | |
| nucleosam | 1:5cc2691ccfff | 318 | /** |
| nucleosam | 1:5cc2691ccfff | 319 | * @} |
| nucleosam | 1:5cc2691ccfff | 320 | */ |
| nucleosam | 1:5cc2691ccfff | 321 | |
| nucleosam | 1:5cc2691ccfff | 322 | #ifdef __cplusplus |
| nucleosam | 1:5cc2691ccfff | 323 | } |
| nucleosam | 1:5cc2691ccfff | 324 | #endif |
| nucleosam | 1:5cc2691ccfff | 325 | |
| nucleosam | 1:5cc2691ccfff | 326 | #endif /* __L6208_H */ |
| nucleosam | 1:5cc2691ccfff | 327 | |
| nucleosam | 1:5cc2691ccfff | 328 | /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/ |

X-NUCLEO-IHM05A1 Bipolar Stepper Motor Driver