📄 powervolt.c
字号:
// V51=0;
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis47[i] != '\0') //显示字符"Test Fail "
{
lcd_wdat(dis47[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis11[i] != '\0')
{
lcd_wdat(dis11[i]); //显示结果
i++;
}
show_value(temp); //n中数据处理与显示
lcd_delay(50);
goto ERROR;
}
/**************************************************************************/
Port1C8255_write(64); //+18V关
Timer100ms=2;
while(Timer100ms);
Port1C8255_write(68); //-18V开
Timer100ms=5;
while(Timer100ms);
write_ads(0x8c);
read_ads();
temp1=adc_hi;
temp1=temp1<<8;
temp1+=adc_lo;
temp=(float)temp1/32768*2.048;
temp*=1.05;
temp*=1000;
if ((temp>=Limit[6])&&(temp<=Limit[7]))
{
// V51=1;
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis46[i] != '\0') //显示字符"Test Pass"
{
lcd_wdat(dis46[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis12[i] != '\0') //显示结果
{
lcd_wdat(dis12[i]);
i++;
}
show_value(temp); //n中数据处理与显示
lcd_delay(50);
}
else
{
// V51=0;
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis47[i] != '\0') //显示字符"Test Fail "
{
lcd_wdat(dis47[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis12[i] != '\0')
{
lcd_wdat(dis12[i]); //显示结果
i++;
}
show_value(temp); //n中数据处理与显示
lcd_delay(50);
goto ERROR;
}
/**************************************************************************/
Port1C8255_write(64); //-18V关
Timer100ms=2;
while(Timer100ms);
Port1C8255_write(72); //+24Va开
Timer100ms=5;
while(Timer100ms);
write_ads(0x8c);
read_ads();
temp1=adc_hi;
temp1=temp1<<8;
temp1+=adc_lo;
temp=(float)temp1/32768*2.048;
temp*=2.015;
temp*=1000;
if ((temp>=Limit[8])&&(temp<=Limit[9]))
{
// V51=1;
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis46[i] != '\0') //显示字符"Test Pass"
{
lcd_wdat(dis46[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis13[i] != '\0') //显示结果
{
lcd_wdat(dis13[i]);
i++;
}
show_value(temp); //n中数据处理与显示
lcd_delay(50);
}
else
{
// V51=0;
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis47[i] != '\0') //显示字符"Test Fail "
{
lcd_wdat(dis47[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis13[i] != '\0')
{
lcd_wdat(dis13[i]); //显示结果
i++;
}
show_value(temp); //n中数据处理与显示
lcd_delay(50);
goto ERROR;
}
/**************************************************************************/
Port1C8255_write(64); //+24Va关
Timer100ms=2;
while(Timer100ms);
Port1C8255_write(80); //+24Vb开
Timer100ms=5;
while(Timer100ms);
write_ads(0x8c);
read_ads();
temp1=adc_hi;
temp1=temp1<<8;
temp1+=adc_lo;
temp=(float)temp1/32768*2.048;
temp*=2.015;
temp*=1000;
if ((temp>=Limit[10])&&(temp<=Limit[11]))
{
// V51=1;
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis46[i] != '\0') //显示字符"Test Pass"
{
lcd_wdat(dis46[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis14[i] != '\0') //显示结果
{
lcd_wdat(dis14[i]);
i++;
}
show_value(temp); //n中数据处理与显示
lcd_delay(50);
}
else
{
// V51=0;
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis47[i] != '\0') //显示字符"Test Fail "
{
lcd_wdat(dis47[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis14[i] != '\0')
{
lcd_wdat(dis14[i]); //显示结果
i++;
}
show_value(temp); //n中数据处理与显示
lcd_delay(50);
goto ERROR;
}
/**************************************************************************/
Port1C8255_write(64); //+24Vb关
Timer100ms=2;
while(Timer100ms);
Port1C8255_write(96); //+Vbr开
Timer100ms=5;
while(Timer100ms);
write_ads(0x8c);
read_ads();
temp1=adc_hi;
temp1=temp1<<8;
temp1+=adc_lo;
temp=(float)temp1/32768*2.048;
temp*=1.2;
temp*=1000;
if ((temp>=Limit[12])&&(temp<=Limit[13]))
{
// V51=1;
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis46[i] != '\0') //显示字符"Test Pass"
{
lcd_wdat(dis46[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis15[i] != '\0') //显示结果
{
lcd_wdat(dis15[i]);
i++;
}
show_value(temp); //n中数据处理与显示
lcd_delay(50);
}
else
{
// V51=0;
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis47[i] != '\0') //显示字符"Test Fail "
{
lcd_wdat(dis47[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis15[i] != '\0')
{
lcd_wdat(dis15[i]); //显示结果
i++;
}
show_value(temp); //n中数据处理与显示
lcd_delay(50);
goto ERROR;
}
/*******************************************************************************/
/*
SendBuffer[0]=0x56; //V
SendBuffer[1]=0x31; //1 0x20=" " W:0x57;P:0x50;F:0x46;(CR):0x0d
SendBuffer[2]=0x3b; //;
SendBuffer[3]=0x41; //A R:0x52;E:0x45;H:0x48;z:0x7A;U:0x55;
SendBuffer[4]=0x31; //1
SendBuffer[5]=0x3b; //;
SendBuffer[6]=0x3f; //?
SendBuffer[7]=0x53; //S
SendBuffer[8]=0x3b; //;
SendBuffer[9]=0x0a; //; (LF)
Send(10);
Timer1s=2;
while(Timer1s);
if (MsgOk==0x55)
{
MsgOk=0x00;
q=ReceiveBuffer[0]; //接收返回值!
b=ReceiveBuffer[1];
s=ReceiveBuffer[2];
g=ReceiveBuffer[3];
temp =(q-0x30)*1000; //ASCII 9==HEX 0x39
temp+=(b-0x30)*100;
temp+=(s-0x30)*10;
temp+=(g-0x30);
if ((temp>=Limit[14])&&(temp<=Limit[15]))
{
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis46[i] != '\0') //显示字符"Test Pass"
{
lcd_wdat(dis46[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis44[i] != '\0') //显示结果
{
lcd_wdat(dis44[i]);
i++;
}
show_value1(q,b,s,g); //n中数据处理与显示
lcd_delay(50);
}
else
{
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis47[i] != '\0') //显示字符"Test Fail "
{
lcd_wdat(dis47[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis44[i] != '\0')
{
lcd_wdat(dis44[i]); //显示结果
i++;
}
show_value1(q,b,s,g); //n中数据处理与显示
lcd_delay(50);
goto ERROR;
}
}
else
{ //未收到信息!
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis48[i] != '\0') //显示字符"Comm No Respond "
{
lcd_wdat(dis48[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis49[i] != '\0')
{
lcd_wdat(dis49[i]); //显示"->> ->> ->> ->>"
i++;
}
goto ERROR;
}
*/
/****************************************************************************/
/* */
/* 第三组:120V输入K1,MAX24负载开K5,状态开关ON / K15 /64 */
/****************************************************************************/
Port1A8255_write(1); //110V电源开
Port1C8255_write(64); //状态开关ON
Timer100ms=10;
while(Timer100ms);
Port1A8255_write(145); //110V电源开,负载ML110开,+5V开
Timer100ms=10;
while(Timer100ms);
write_ads(0x8c);
read_ads();
temp1=adc_hi;
temp1=temp1<<8;
temp1+=adc_lo;
temp=(float)temp1/32768*2.048;
temp*=1.025;
temp*=1000;
if ((temp>=Limit[0])&&(temp<=Limit[1]))
{
// V51=1;
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis46[i] != '\0') //显示字符"Test Pass"
{
lcd_wdat(dis46[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis16[i] != '\0') //显示结果
{
lcd_wdat(dis16[i]);
i++;
}
show_value(temp); //n中数据处理与显示
lcd_delay(50);
}
else
{
// V51=0;
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis47[i] != '\0') //显示字符"Test Fail "
{
lcd_wdat(dis47[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis16[i] != '\0')
{
lcd_wdat(dis16[i]); //显示结果
i++;
}
show_value(temp); //n中数据处理与显示
lcd_delay(50);
goto ERROR;
}
/**************************************************************************/
Port1A8255_write(17); //+5V 关
Timer100ms=2;
while(Timer100ms);
Port1C8255_write(65); //+12V开
Timer100ms=5;
while(Timer100ms);
write_ads(0x8c);
read_ads();
temp1=adc_hi;
temp1=temp1<<8;
temp1+=adc_lo;
temp=(float)temp1/32768*2.048;
temp*=1.032;
temp*=1000;
if ((temp>=Limit[2])&&(temp<=Limit[3]))
{
// V51=1;
lcd_pos(0x00); //设置显示位置为第一行的第1个字符
i = 0;
while(dis46[i] != '\0') //显示字符"Test Pass"
{
lcd_wdat(dis46[i]);
i++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
i = 0;
while(dis17[i] != '\0') //显示结果
{
lcd_wdat(dis17[i]);
i++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -