新手入门
- 积分
- 26
- 金钱
- 26
- 注册时间
- 2013-8-10
- 在线时间
- 0 小时
|

楼主 |
发表于 2013-8-10 15:22:31
|
显示全部楼层
回复【楼主位】bitter:
---------------------------------
这个是步进电机管脚定义,后面那个Opt是光耦开关管脚定义:
BjMonitor[0].EnaGpio = GPIOE; BjMonitor[0].EnaPin = GPIO_Pin_4;
BjMonitor[0].DirGpio = GPIOE; BjMonitor[0].DirPin = GPIO_Pin_3;
BjMonitor[0].PulGpio = GPIOE; BjMonitor[0].PulPin = GPIO_Pin_2;
// BjMonitor[0].OptGpio = GPIOG; BjMonitor[0].OptPin = GPIO_Pin_15;
BjMonitor[1].EnaGpio = GPIOF; BjMonitor[1].EnaPin = GPIO_Pin_0;
BjMonitor[1].DirGpio = GPIOE; BjMonitor[1].DirPin = GPIO_Pin_6;
BjMonitor[1].PulGpio = GPIOE; BjMonitor[1].PulPin = GPIO_Pin_5;
// BjMonitor[1].OptGpio = GPIOG; BjMonitor[1].OptPin = GPIO_Pin_14;
BjMonitor[2].EnaGpio = GPIOF; BjMonitor[2].EnaPin = GPIO_Pin_3;
BjMonitor[2].DirGpio = GPIOF; BjMonitor[2].DirPin = GPIO_Pin_2;
BjMonitor[2].PulGpio = GPIOF; BjMonitor[2].PulPin = GPIO_Pin_1;
// BjMonitor[2].OptGpio = GPIOG; BjMonitor[2].OptPin = GPIO_Pin_13;
BjMonitor[3].EnaGpio = GPIOF; BjMonitor[3].EnaPin = GPIO_Pin_6;
BjMonitor[3].DirGpio = GPIOF; BjMonitor[3].DirPin = GPIO_Pin_5;
BjMonitor[3].PulGpio = GPIOF; BjMonitor[3].PulPin = GPIO_Pin_4;
// BjMonitor[3].OptGpio = GPIOG; BjMonitor[3].OptPin = GPIO_Pin_12;
BjMonitor[4].EnaGpio = GPIOF; BjMonitor[4].EnaPin = GPIO_Pin_9;
BjMonitor[4].DirGpio= GPIOF; BjMonitor[4].DirPin = GPIO_Pin_8;
BjMonitor[4].PulGpio= GPIOF; BjMonitor[4].PulPin = GPIO_Pin_7;
// BjMonitor[4].OptGpio= GPIOG; BjMonitor[4].OptPin = GPIO_Pin_11;
BjMonitor[5].EnaGpio = GPIOC; BjMonitor[5].EnaPin = GPIO_Pin_1;
BjMonitor[5].DirGpio = GPIOC; BjMonitor[5].DirPin = GPIO_Pin_0;
BjMonitor[5].PulGpio = GPIOF; BjMonitor[5].PulPin = GPIO_Pin_10;
// BjMonitor[5].OptGpio = GPIOG; BjMonitor[5].OptPin = GPIO_Pin_10;
BjMonitor[6].EnaGpio = GPIOA; BjMonitor[6].EnaPin = GPIO_Pin_1;
BjMonitor[6].DirGpio = GPIOC; BjMonitor[6].DirPin = GPIO_Pin_3;
BjMonitor[6].PulGpio = GPIOC; BjMonitor[6].PulPin = GPIO_Pin_2;
// BjMonitor[6].OptGpio = GPIOG; BjMonitor[6].OptPin = GPIO_Pin_9;
BjMonitor[7].EnaGpio = GPIOA; BjMonitor[7].EnaPin = GPIO_Pin_6;
BjMonitor[7].DirGpio = GPIOA; BjMonitor[7].DirPin = GPIO_Pin_5;
BjMonitor[7].PulGpio = GPIOA; BjMonitor[7].PulPin = GPIO_Pin_4;
// BjMonitor[7].OptGpio = GPIOD; BjMonitor[7].OptPin = GPIO_Pin_7;
BjMonitor[8].EnaGpio = GPIOC; BjMonitor[8].EnaPin = GPIO_Pin_5;
BjMonitor[8].DirGpio = GPIOC; BjMonitor[8].DirPin = GPIO_Pin_4;
BjMonitor[8].PulGpio = GPIOA; BjMonitor[8].PulPin = GPIO_Pin_7;
// BjMonitor[8].OptGpio = GPIOD; BjMonitor[8].OptPin = GPIO_Pin_6;
BjMonitor[9].EnaGpio = GPIOC; BjMonitor[9].EnaPin = GPIO_Pin_13;
BjMonitor[9].DirGpio = GPIOB; BjMonitor[9].DirPin = GPIO_Pin_1;
BjMonitor[9].PulGpio = GPIOB; BjMonitor[9].PulPin = GPIO_Pin_0;
// BjMonitor[9].OptGpio = GPIOD; BjMonitor[9].OptPin = GPIO_Pin_5;
BjMonitor[10].EnaGpio = GPIOF; BjMonitor[10].EnaPin = GPIO_Pin_13;
BjMonitor[10].DirGpio = GPIOF; BjMonitor[10].DirPin = GPIO_Pin_12;
BjMonitor[10].PulGpio = GPIOF; BjMonitor[10].PulPin = GPIO_Pin_11;
// BjMonitor[10].OptGpio = GPIOD; BjMonitor[10].OptPin = GPIO_Pin_4;
BjMonitor[11].EnaGpio = GPIOG; BjMonitor[11].EnaPin = GPIO_Pin_0;
BjMonitor[11].DirGpio = GPIOF; BjMonitor[11].DirPin = GPIO_Pin_15;
BjMonitor[11].PulGpio = GPIOF; BjMonitor[11].PulPin = GPIO_Pin_14;
// BjMonitor[11].OptGpio = GPIOD; BjMonitor[11].OptPin = GPIO_Pin_3;
BjMonitor[12].EnaGpio = GPIOE; BjMonitor[12].EnaPin = GPIO_Pin_8;
BjMonitor[12].DirGpio = GPIOE; BjMonitor[12].DirPin = GPIO_Pin_7;
BjMonitor[12].PulGpio = GPIOG; BjMonitor[12].PulPin = GPIO_Pin_1;
// BjMonitor[12].OptGpio = GPIOD; BjMonitor[12].OptPin = GPIO_Pin_2;
BjMonitor[13].EnaGpio = GPIOE; BjMonitor[13].EnaPin = GPIO_Pin_11;
BjMonitor[13].DirGpio = GPIOE; BjMonitor[13].DirPin = GPIO_Pin_10;
BjMonitor[13].PulGpio = GPIOE; BjMonitor[13].PulPin = GPIO_Pin_9;
// BjMonitor[13].OptGpio = GPIOD; BjMonitor[13].OptPin = GPIO_Pin_1;
BjMonitor[14].EnaGpio = GPIOE; BjMonitor[14].EnaPin = GPIO_Pin_14;
BjMonitor[14].DirGpio = GPIOE; BjMonitor[14].DirPin = GPIO_Pin_13;
BjMonitor[14].PulGpio = GPIOE; BjMonitor[14].PulPin = GPIO_Pin_12;
// BjMonitor[14].OptGpio = GPIOD; BjMonitor[14].OptPin = GPIO_Pin_0;
BjMonitor[15].EnaGpio = GPIOB; BjMonitor[15].EnaPin = GPIO_Pin_11;
BjMonitor[15].DirGpio = GPIOB; BjMonitor[15].DirPin = GPIO_Pin_10;
BjMonitor[15].PulGpio = GPIOE; BjMonitor[15].PulPin = GPIO_Pin_15;
// BjMonitor[15].OptGpio = GPIOC; BjMonitor[15].OptPin = GPIO_Pin_12;
void Monitor_GPIO_Init(void)
{
u8 i;
GPIO_InitTypeDef GPIO_InitStructure;
Bj_Init();
for(i=0; i< BJMONITOR_NUMBER;i++)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);
GPIO_InitStructure.GPIO_Pin = BjMonitor.PulPin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(BjMonitor.PulGpio, &GPIO_InitStructure);
GPIO_SetBits(BjMonitor.PulGpio,BjMonitor.PulPin);
//设置dir 引脚
GPIO_InitStructure.GPIO_Pin = BjMonitor.DirPin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(BjMonitor.DirGpio, &GPIO_InitStructure);
GPIO_SetBits(BjMonitor.DirGpio,BjMonitor.DirPin);
//设置Ena 引脚
GPIO_InitStructure.GPIO_Pin = BjMonitor.EnaPin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(BjMonitor.EnaGpio, &GPIO_InitStructure);
GPIO_SetBits(BjMonitor.EnaGpio,BjMonitor.EnaPin);
//设置光电开关检测引脚
GPIO_InitStructure.GPIO_Pin = BjMonitor.OptPin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //浮空输入
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_Init(BjMonitor.OptGpio, &GPIO_InitStructure);
}
}
为什么光耦用不了,但是控制电机部分的输出有用,谢谢原子哥 啊 |
|