implemented the calculation for the time that has to pass to make one step

This commit is contained in:
Gregor Wüst 2021-02-13 15:25:02 +01:00
parent c06ae5e360
commit edf029fd31
3 changed files with 66 additions and 70 deletions

View File

@ -80,13 +80,13 @@
/* #define HAL_SD_MODULE_ENABLED */
#define HAL_SPI_MODULE_ENABLED
#define HAL_TIM_MODULE_ENABLED
/* #define HAL_UART_MODULE_ENABLED */
#define HAL_UART_MODULE_ENABLED */
/* #define HAL_USART_MODULE_ENABLED */
/* #define HAL_IRDA_MODULE_ENABLED */
/* #define HAL_SMARTCARD_MODULE_ENABLED*/
/* #define HAL_WWDG_MODULE_ENABLED */
#define HAL_CORTEX_MODULE_ENABLED
/* #define HAL_PCD_MODULE_ENABLED */
/* #define HAL_PCD_MODULE_aENABLED */
/* #define HAL_HCD_MODULE_ENABLED */

View File

@ -46,8 +46,10 @@
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart2;
static volatile uint16_t gLastError;
static volatile bool gButtonPressed = FALSE;
static volatile float sunWindow;
/* Initialization parameters. */
l6208_Init_t initDeviceParameters =
@ -80,7 +82,7 @@ void ButtonHandler(void);
int main(void)
{
int32_t pos;
uint32_t freqPwm;
uint32_t freqPwm, timeToNextStep;
/* STM32xx HAL library initialization */
HAL_Init();
@ -132,35 +134,23 @@ int main(void)
BSP_MotorControl_SetHome(0, pos);
//BSP_MotorControl_Move(0, FORWARD, 4000);
//BSP_MotorControl_WaitWhileActive(0);
//HAL_Delay(2000);
//BSP_MotorControl_Move(0, BACKWARD, 4000);
//BSP_MotorControl_WaitWhileActive(0);
//BSP_MotorControl_SoftStop(0);
timeToNextStep = (float)(sunWindow / 100) * 60 * 60 * 1000;
BSP_MotorControl_SelectStepMode(0, STEP_MODE_FULL);
//BSP_MotorControl_Move(0, FORWARD, 25);
//BSP_MotorControl_WaitWhileActive(0);
/* Infinite loop */
while(1)
{
if (gButtonPressed)
{
gButtonPressed = FALSE;
BSP_MotorControl_Move(0, FORWARD, 25);
BSP_MotorControl_WaitWhileActive(0);
BSP_MotorControl_Move(0, FORWARD, 25);
BSP_MotorControl_WaitWhileActive(0);
BSP_MotorControl_Move(0, FORWARD, 25);
BSP_MotorControl_WaitWhileActive(0);
BSP_MotorControl_Move(0, FORWARD, 25);
BSP_MotorControl_WaitWhileActive(0);
HAL_Delay(2000);
// Sleep for timeToNextStep
// Shut down motor for timeToNextStep
// Wake up F401RE and motor after timeToNextStep
// Make the Step
}
BSP_MotorControl_GoHome(0);
BSP_MotorControl_WaitWhileActive(0);
@ -210,6 +200,12 @@ void ButtonHandler(void)
HAL_NVIC_ClearPendingIRQ(KEY_BUTTON_EXTI_IRQn);
}
void transmit_uart(char *string){
uint8_t len = strlen(string);
HAL_UART_Transmit(&huart2, (uint8_t*) string, len, 200);
}
#ifdef USE_FULL_ASSERT
/**

View File

@ -1,4 +1,4 @@
main.c:188:6:MyErrorHandler 0 static
main.c:177:6:MyFlagInterruptHandler 0 static
main.c:187:6:MyErrorHandler 0 static
main.c:176:6:MyFlagInterruptHandler 0 static
main.c:80:5:main 16 static
main.c:205:6:ButtonHandler 8 static
main.c:204:6:ButtonHandler 8 static