2021-05-19 08:31 AM
Hi,
I am working on below setup.
1) P-NUCLEO-IHM001 with BLDC Motor
2) mcsdk 5.4.6
3) IAR 9.10.1
4) STMCubeMX 5.6.0
I am able to Start/Stop the motor with push button available on kit as below code .
1) How do I control Speed of Motor with potentiometer (ADC) available on Kit .
(Which function should I use )
2) If any how (By holding rotor with hand) speed feedback error comes how do I clear
speed Feedback error in code
And motor will restart after some time ( say 1 min).
(Which function should I use )
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
if(MC_GetSTMStateMotor1() == RUN)
{
HAL_GPIO_WritePin( Green_LED_GPIO_Port , Green_LED_Pin , GPIO_PIN_SET ) ;
}
else
{
HAL_GPIO_WritePin( Green_LED_GPIO_Port , Green_LED_Pin , GPIO_PIN_RESET ) ;
}
if(MC_GetSTMStateMotor1() == FAULT_NOW || MC_GetSTMStateMotor1() == FAULT_OVER )
{
HAL_GPIO_WritePin( Red_LED_GPIO_Port , Red_LED_Pin , GPIO_PIN_SET ) ;
}
else
{
HAL_GPIO_WritePin( Red_LED_GPIO_Port , Red_LED_Pin , GPIO_PIN_RESET ) ;
}
}
void HAL_GPIO_EXTI_Rising_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == Start_Stop_Pin)
{
State_t MState = MC_GetSTMStateMotor1();
int16_t MSpeed = (MC_GetMecSpeedAverageMotor1()*6);
if(MState == IDLE)
{
MC_ProgramSpeedRampMotor1(1000,2000);
MC_StartMotor1() ;
}
}
else
{
MC_StopMotor1() ;
}
}
--
Karan
2021-05-31 04:38 AM
Dear @Community member
Did you have a look on the examples with potentiometer in STM32 MC SDK ?
Best regards
Laurent Ca...
2021-05-31 04:42 AM