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.
Diff: Components/l6208/l6208_class.h
- Revision:
- 2:2af31245e67e
- Parent:
- 1:5cc2691ccfff
--- a/Components/l6208/l6208_class.h Wed Apr 27 16:30:55 2016 +0000
+++ b/Components/l6208/l6208_class.h Fri Apr 29 14:58:30 2016 +0000
@@ -96,8 +96,8 @@
vrefB_pwm(vrefB_pwm_pin)
{
/* Checking stackability. */
- if (!(numberOfDevices < MAX_NUMBER_OF_DEVICES))
- error("Instantiation of the L6208 component failed: it can be stacked up to %d times.\r\n", MAX_NUMBER_OF_DEVICES);
+ if (numberOfDevices!=0)
+ error("Instantiation of the L6208 component failed: it can't be stacked on itself.\r\n");
/* ACTION 4 ----------------------------------------------------------*
* Initialize here the component's member variables, one variable per *
@@ -663,15 +663,6 @@
{
L6208_SetStopMode(stopMode);
}
-
- /**
- * @brief Public static functions
- */
-
- static uint8_t GetNbDevices(void)
- {
- return numberOfDevices;
- }
/*** Public Interrupt Related Methods ***/
@@ -791,6 +782,34 @@
void L6208_VrefPwmSetFreq(uint32_t newFreq);
void L6208_WaitWhileActive(void);
+ /*** Functions intended to be used only internally ***/
+
+ void L6208_ClearSysFlag(uint32_t mask);
+ uint32_t L6208_ComputeNbAccOrDecSteps(uint16_t accOrDecRate);
+ uint16_t L6208_ConvertAcceDecelRateValue(uint16_t newAccOrDecRate);
+ void L6208_DoAccel(void);
+ void L6208_DoDecel(void);
+ void L6208_DoRun(void);
+ uint8_t L6208_GetMicrostepSample2Scale(void);
+ void L6208_Indexmodeinit(void);
+ bool L6208_IsSysFlag(uint32_t mask);
+ void L6208_ResetSteps(void);
+ uint32_t L6208_ScaleWaveformSample(uint8_t sampleIndex);
+ void L6208_ScaleWaveformTable(void);
+ void L6208_SetDeviceParamsToGivenValues(l6208_Init_t* pInitDevicePrm);
+ void L6208_SetDeviceParamsToPredefinedValues(void);
+ void L6208_SetMicrostepSample2Scale(uint8_t value);
+ void L6208_SetMicrostepSample2Update(uint8_t value);
+ void L6208_SetMotionState(motorState_t newMotionState);
+ bool L6208_SetSpeed(uint16_t newSpeed, uint32_t volatile *pSpeed);
+ void L6208_SetSysFlag(uint32_t mask);
+ bool L6208_StartMovement(void);
+ void L6208_UpdateScanWaveformTable(void);
+ void L6208_UstepWaveformHandling(void);
+ bool L6208_VectorCalc(uint8_t newTorque);
+ bool L6208_VrefPwmComputePulseWidth(uint8_t bridgeId, uint16_t value, bool valueIsPwmDutyCycle);
+ void L6208_VrefPwmUpdatePulseWidth(void);
+
/*** Component's I/O Methods ***/
/* ACTION 8 --------------------------------------------------------------*
@@ -1065,36 +1084,6 @@
else return false;
return true;
}
-
-private:
-
- /*** Private Component Related Methods ***/
-
- void L6208_ClearSysFlag(uint32_t mask);
- uint32_t L6208_ComputeNbAccOrDecSteps(uint16_t accOrDecRate);
- uint16_t L6208_ConvertAcceDecelRateValue(uint16_t newAccOrDecRate);
- void L6208_DoAccel(void);
- void L6208_DoDecel(void);
- void L6208_DoRun(void);
- uint8_t L6208_GetMicrostepSample2Scale(void);
- void L6208_Indexmodeinit(void);
- bool L6208_IsSysFlag(uint32_t mask);
- void L6208_ResetSteps(void);
- uint32_t L6208_ScaleWaveformSample(uint8_t sampleIndex);
- void L6208_ScaleWaveformTable(void);
- void L6208_SetDeviceParamsToGivenValues(l6208_Init_t* pInitDevicePrm);
- void L6208_SetDeviceParamsToPredefinedValues(void);
- void L6208_SetMicrostepSample2Scale(uint8_t value);
- void L6208_SetMicrostepSample2Update(uint8_t value);
- void L6208_SetMotionState(motorState_t newMotionState);
- bool L6208_SetSpeed(uint16_t newSpeed, uint32_t volatile *pSpeed);
- void L6208_SetSysFlag(uint32_t mask);
- bool L6208_StartMovement(void);
- void L6208_UpdateScanWaveformTable(void);
- void L6208_UstepWaveformHandling(void);
- bool L6208_VectorCalc(uint8_t newTorque);
- bool L6208_VrefPwmComputePulseWidth(uint8_t bridgeId, uint16_t value, bool valueIsPwmDutyCycle);
- void L6208_VrefPwmUpdatePulseWidth(void);
protected:

X-NUCLEO-IHM05A1 Bipolar Stepper Motor Driver