新手上路
- 积分
- 27
- 金钱
- 27
- 注册时间
- 2021-10-27
- 在线时间
- 10 小时
|
1金钱
本帖最后由 ds6768 于 2021-11-29 16:24 编辑
stm32f103精英版测试步进电机,转速很慢,然后扭距很小
大佬帮我看看,时序是不是对的,驱动我手上的是mx1508,不知道我手上的这个能不能用于步进电机控制,电机是42的2相4线
u16 phasecw1[4] ={0x0008,0x0002,0x0004,0x0001};//
void Motor_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//????
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
//
GPIO_ResetBits(GPIOC,GPIO_Pin_0);
GPIO_ResetBits(GPIOC,GPIO_Pin_1);
GPIO_ResetBits(GPIOC,GPIO_Pin_2);
GPIO_ResetBits(GPIOC,GPIO_Pin_3);
}
void Motorcw1(void)
{
{
uint8_t i;
for(i=0;i<4;i++)
{
GPIO_Write(GPIOC,phasecw1);
delay_ms(50);
}
}
}
int main(void)
{
delay_init();
Motor_Init();
while(1)
{
Motorcw1();
}
}
|
|