有段C语言程序看不太懂,单片机方面,可能是和步进电机有关。
时间:10-02
整理:3721RD
点击:
如题,程序如下,是无线输液警报器设计方面的:
void Time1() interrupt 3 //定时器1服务函数
{
uchar m; //定义定时变量
TH1=0x63; //10ms
TL1=0xc0; //重新赋初值
m++; //变量加1是50ms
if(m==5) //加到5时
{
m=0; //清零
if(flag==1) //报警开关打开时
{
buzz=!buzz; //蜂鸣器取反,闪烁响
if(huixue==0) //有检测到回血时
BJ_LED=!BJ_LED; //回血指示灯闪烁
}
if(Mode!=0) //设置时
{
shanshuo=!shanshuo;//闪烁
}
}
if(flag1==1&&stop==0)
{
switch(num1)
{
case 0:a = 1;b = 0;c = 0;d = 0;break;
case 1:a = 1;b = 1;c = 0;d = 0;break;
case 2:a = 0;b = 1;c = 0;d = 0;break;
case 3:a = 0;b = 1;c = 1;d = 0;break;
case 4:a = 0;b = 0;c = 1;d = 0;break;
case 5:a = 0;b = 0;c = 1;d = 1;break;
case 6:a = 0;b = 0;c = 0;d = 1;break;
case 7:a = 1;b = 0;c = 0;d = 1;break;
}
num1++;
if(num1 == 8)
{
num1 = 0;
angle++;
if(angle>=130)
{
angle=0;
stop=1;
}
}
}
void Time1() interrupt 3 //定时器1服务函数
{
uchar m; //定义定时变量
TH1=0x63; //10ms
TL1=0xc0; //重新赋初值
m++; //变量加1是50ms
if(m==5) //加到5时
{
m=0; //清零
if(flag==1) //报警开关打开时
{
buzz=!buzz; //蜂鸣器取反,闪烁响
if(huixue==0) //有检测到回血时
BJ_LED=!BJ_LED; //回血指示灯闪烁
}
if(Mode!=0) //设置时
{
shanshuo=!shanshuo;//闪烁
}
}
if(flag1==1&&stop==0)
{
switch(num1)
{
case 0:a = 1;b = 0;c = 0;d = 0;break;
case 1:a = 1;b = 1;c = 0;d = 0;break;
case 2:a = 0;b = 1;c = 0;d = 0;break;
case 3:a = 0;b = 1;c = 1;d = 0;break;
case 4:a = 0;b = 0;c = 1;d = 0;break;
case 5:a = 0;b = 0;c = 1;d = 1;break;
case 6:a = 0;b = 0;c = 0;d = 1;break;
case 7:a = 1;b = 0;c = 0;d = 1;break;
}
num1++;
if(num1 == 8)
{
num1 = 0;
angle++;
if(angle>=130)
{
angle=0;
stop=1;
}
}
}
是步进电机的控制,是四相八拍的驱动方式,可以查查这方面的资料