这是我最近刚完成的蓝桥杯嵌入式模拟题--模拟升降器设计,所有功能在实验板上都已实现。附件里包含程序源码。
部分STM32代码如下:
void Key_Chuli(void)
{
if(UP_Plate_Flag
{
if(Now2_Plate == 1 && Now_Plate < 2)
{
if(Door_State_Flag == 1
{
Door_State_Flag = 0;
PWM_Init(Door_Close)
GPIO_ResetBits(GPIOA,GPIO_Pin_5);
Door_Close_Time = 4000;
}
if(Door_Close_Finish_Flag == 1)//关门完毕
{
Door_Close_Finish_Flag = 0;
PWM_Init(Lift_Up);
GPIO_SetBits(GPIOA,GPIO_Pin_4);
Lift_Motor_Time = (2-Now_Plate)*6000;//电梯运行时间
LED_Flow_UP_Flag = 1; //流水灯标记,在电梯上升过程有用
LED_Flow_UP_Time = 200;//流水灯时间
}
if(Lift_Arrive_Flag == 1)//电梯到达楼层
{
Lift_Arrive_Flag = 0;
LED_Flow_UP_Flag = 0;//流水灯关闭
LED_Ctorl(0,LEDAOALL);
LED2_Ctorl_Flag = 0;
LCD__Shan_Flag = 1; //LCD闪烁
PWM_Init(Door_Open);
GPIO_SetBits(GPIOA,GPIO_Pin_5);
Door_Open_Time = 4000;//门打开时间等待4s
}
if(Door_Open_Finish_Flag == 1)
{
Door_Open_Finish_Flag = 0;
PWM_Init(All_Stop);
Door_Wait_Time = 2000;
}
if(Door_Wait_Flag == 1)
{
Door_Wait_Flag = 0;
Door_State_Flag = 1;
Now_Plate = 2;
Now2_Plate = 0;
}
}
else if(Now3_Plate == 1 && Now_Plate < 3)
{
if(Door_State_Flag == 1) //门处于打开状态
{
Door_State_Flag = 0;
PWM_Init(Door_Close); //关门
GPIO_ResetBits(GPIOA,GPIO_Pin_5);
Door_Close_Time = 4000;//关门时间5s
}
if(Door_Close_Finish_Flag == 1)//关门完毕
{
Door_Close_Finish_Flag = 0;
PWM_Init(Lift_Up);
GPIO_SetBits(GPIOA,GPIO_Pin_4);
Lift_Motor_Time = (3-Now_Plate)*6000;//电梯运行时间
LED_Flow_UP_Flag = 1
LED_Flow_UP_Time = 200;
}
if(Lift_Arrive_Flag == 1)//电梯到达楼层
{
Lift_Arrive_Flag = 0;
LED_Flow_UP_Flag = 0;//流水灯关闭
LED_Ctorl(0,LEDAOALL);
LED3_Ctorl_Flag = 0;
LCD__Shan_Flag = 1;
PWM_Init(Door_Open);
GPIO_SetBits(GPIOA,GPIO_Pin_5);
Door_Open_Time = 4000;//门打开时间4s
}
if(Door_Open_Finish_Flag == 1)
{
Door_Open_Finish_Flag = 0;
PWM_Init(All_Stop);
Door_Wait_Time = 2000;
}
if(Door_Wait_Flag == 1)
{
Door_Wait_Flag = 0;
Door_State_Flag = 1;
Now_Plate = 3;
Now3_Plate = 0;
}
}
else if(Now4_Plate == 1 && Now_Plate < 4)
{
if(Door_State_Flag == 1) //门处于打开状态
{
Door_State_Flag = 0;
PWM_Init(Door_Close); //关门
GPIO_ResetBits(GPIOA,GPIO_Pin_5);
Door_Close_Time = 4000;//关门时间5s
}
if(Door_Close_Finish_Flag == 1)//关门完毕
{
Door_Close_Finish_Flag = 0;
PWM_Init(Lift_Up);
GPIO_SetBits(GPIOA,GPIO_Pin_4);
Lift_Motor_Time = (4-Now_Plate)*6000;//电梯运行时间
LED_Flow_UP_Flag = 1; //流水灯标记,在电梯上升过程有用
LED_Flow_UP_Time = 200;//流水灯时间
}
if(Lift_Arrive_Flag == 1)//电梯到达楼层
{
Lift_Arrive_Flag = 0;
LED_Flow_UP_Flag = 0;//流水灯关闭
LED_Ctorl(0,LEDAOALL);
LED4_Ctorl_Flag = 0;
LCD__Shan_Flag = 1;
PWM_Init(Door_Open);
GPIO_SetBits(GPIOA,GPIO_Pin_5);
Door_Open_Time = 4000;//门打开时间4s
}
if(Door_Open_Finish_Flag == 1)
{
Door_Open_Finish_Flag = 0;
PWM_Init(All_Stop);
Door_Wait_Time = 2000;
}
if(Door_Wait_Flag == 1)
{
Door_Wait_Flag = 0;
Door_State_Flag = 1;
Now_Plate = 4;
Now4_Plate = 0;
}
}
}
}
全部资料51hei下载地址:
模拟升降器.7z
(275.14 KB, 下载次数: 20)
|