#include<reg52.h>
#include<ee.h>
#include<eprom.h>
#include<lcdfuncs.h>
sbit relay1=P3^1;
sbit relay2=P3^5;
sbit relay3=P3^6;
//sbit relay4=P3^7;
sbit i1=P1^5;
sbit i2=P1^6;
sbit i3=P1^4;
char char_sel=1,screen_no,ccc1,ccc2,ccc3;
unsigned int on_time_rl1,on_time_rl2,on_time_rl3;
unsigned int off_time_rl1,off_time_rl2,off_time_rl3;
unsigned int t_i1_on=0,t_i2_on=0,t_i3_on=0;
unsigned int t_i1_off=0,t_i2_off=0,t_i3_off=0;
char on_time1_rl1,on_time2_rl1,on_time3_rl1;
char on_time1_rl2,on_time2_rl2,on_time3_rl2;
char on_time1_rl3,on_time2_rl3,on_time3_rl3;
char off_time1_rl1,off_time2_rl1,off_time3_rl1;
char off_time1_rl2,off_time2_rl2,off_time3_rl2;
char off_time1_rl3,off_time2_rl3,off_time3_rl3;
bit in_1_on_flag=0,in_2_on_flag=0,in_3_on_flag=0;
bit in_1_off_flag=0,in_2_off_flag=0,in_3_off_flag=0;
int k;
unsigned int temp_time=0;
char *x;
key_pressed();
void delay(unsigned int del)
{
unsigned long int j;
for(j=0;j<del*2;j++);
}
display_count (unsigned char c3,unsigned char c2,unsigned char c1)
{
write_LCD_byte(LCD_CONTROL,LINE_2 + 8);
write_LCD_byte(LCD_DATA,c3 + 0x30);
write_LCD_byte(LCD_CONTROL,LINE_2 + 9);
write_LCD_byte(LCD_DATA,'.');
write_LCD_byte(LCD_CONTROL,LINE_2 + 10);
write_LCD_byte(LCD_DATA,c2 + 0x30);
write_LCD_byte(LCD_CONTROL,LINE_2 + 11);
write_LCD_byte(LCD_DATA,c1 + 0x30);
write_LCD_byte(LCD_CONTROL,LINE_2 + 13);
write_LCD_byte(LCD_DATA,'S');
write_LCD_byte(LCD_CONTROL,LINE_2 + 14);
write_LCD_byte(LCD_DATA,'e');
write_LCD_byte(LCD_CONTROL,LINE_2 + 15);
write_LCD_byte(LCD_DATA,'c');
switch(char_sel)
{
case 1: write_LCD_byte(LCD_CONTROL,0x0E);
write_LCD_byte(LCD_CONTROL,LINE_2 + 11);
break;
case 2: write_LCD_byte(LCD_CONTROL,0x0E);
write_LCD_byte(LCD_CONTROL,LINE_2 + 10);
break;
case 3: write_LCD_byte(LCD_CONTROL,0x0E);
write_LCD_byte(LCD_CONTROL,LINE_2 + 8);
break;
default: write_LCD_byte(LCD_CONTROL,0x0C);
break;
}
}
main()
{
delay(100);
// P0=0xff;
P2=0XFF;
P1=0xff;
P3=0xff;
SP=0x7f;
TL1=0x2f;
TH1=0xf8;
TMOD=(TMOD & 0x0f) | 0x10;
ET1=1;
IT1=1;
EA=1;
WP=0;
sda=1;
scl=1;
delay(100);
init_2_line_LCD();
delay(10);
ee_byte_from_ee(0x0b,&on_time1_rl1);delay(10);
ee_byte_from_ee(0x1b,&on_time2_rl1);delay(10);
ee_byte_from_ee(0x2b,&on_time3_rl1);delay(10);
ee_byte_from_ee(0x4b,&on_time1_rl2);delay(10);
ee_byte_from_ee(0x5b,&on_time2_rl2);delay(10);
ee_byte_from_ee(0x6b,&on_time3_rl2);delay(10);
ee_byte_from_ee(0x7b,&on_time1_rl3);delay(10);
ee_byte_from_ee(0x8b,&on_time2_rl3);delay(10);
ee_byte_from_ee(0x9b,&on_time3_rl3);delay(10);
ee_byte_from_ee(0xab,&off_time1_rl1);delay(10);
ee_byte_from_ee(0xbb,&off_time2_rl1);delay(10);
ee_byte_from_ee(0xcb,&off_time3_rl1);delay(10);
ee_byte_from_ee(0xdb,&off_time1_rl2);delay(10);
ee_byte_from_ee(0xeb,&off_time2_rl2);delay(10);
ee_byte_from_ee(0x43,&off_time3_rl2);delay(10);
ee_byte_from_ee(0x53,&off_time1_rl3);delay(10);
ee_byte_from_ee(0x63,&off_time2_rl3);delay(10);
ee_byte_from_ee(0x73,&off_time3_rl3);delay(10);
on_time_rl1=on_time1_rl1+(10*on_time2_rl1)+(100*on_time3_rl1);
on_time_rl2=on_time1_rl2+(10*on_time2_rl2)+(100*on_time3_rl2);
on_time_rl3=on_time1_rl3+(10*on_time2_rl3)+(100*on_time3_rl3);
off_time_rl1=off_time1_rl1+(10*off_time2_rl1)+(100*off_time3_rl1);
off_time_rl1=off_time1_rl2+(10*off_time2_rl2)+(100*off_time3_rl2);
off_time_rl1=off_time1_rl3+(10*off_time2_rl3)+(100*off_time3_rl3);
delay(10);
screen_no=0;
clear_lcd();
write_LCD_line(LINE_1+2,"WELCOME TO");
write_LCD_line(LINE_2+4,"ALLIED ENGG.");
delay(150);
TR1=1;
while(1)
{
if(i1==0 & relay1==1 & relay2==1 & relay3==1) in_1_on_flag=1; else in_1_on_flag=0;
if(i2==0 & relay1==1 & relay2==1 & relay3==1) in_2_on_flag=1; else in_2_on_flag=0;
if(i3==0 & relay1==1 & relay2==1 & relay3==1) in_3_on_flag=1; else in_3_on_flag=0;
if(i1==1)
{
in_1_off_flag=1;
in_1_on_flag=0;
t_i1_on=0;
} else{ in_1_off_flag=0; t_i1_off=0; }
if(i2==1)
{
in_2_off_flag=1;
in_2_on_flag=0;
t_i2_on=0;
} else{ in_2_off_flag=0; t_i2_off=0;}
if(i3==1)
{
in_3_off_flag=1;
in_3_on_flag=0;
t_i3_on=0;
} else{ in_3_off_flag=0; t_i3_off=0;}
if(t_i1_on>=on_time_rl1)
{
relay1=0;
in_1_on_flag=0;
t_i1_on=0;
in_1_off_flag=0;
t_i1_off=0;
}
if(t_i2_on>=on_time_rl2)
{
relay2=0;
in_2_on_flag=0;
t_i2_on=0;
in_2_off_flag=0;
t_i2_off=0;
}
if(t_i3_on>=on_time_rl3)
{
relay3=0;
in_3_on_flag=0;
t_i3_on=0;
in_3_off_flag=0;
t_i3_off=0;
}
if(t_i1_off>=off_time_rl1 & i1==1)
{
relay1=1;
in_1_off_flag=0;
t_i1_off=0;
}
if(t_i2_off>=off_time_rl2 & i2==1)
{
relay2=1;
in_2_off_flag=0;
t_i2_off=0;
}
if(t_i3_off>=off_time_rl3 & i3==1)
{
relay3=1;
in_3_off_flag=0;
t_i3_off=0;
}
if(P2!=0xff)
key_pressed();
}
} // End of Main routine.
key_pressed()
{
delay(1500);
switch(P2)
{
case 0x7f : // SET key
clear_lcd();
if(screen_no==0)
{
screen_no=1;
write_LCD_line(LINE_1,"I/P 1 ON TIME:");
char_sel=1;
ccc1=on_time1_rl1;
ccc2=on_time2_rl1;
ccc3=on_time3_rl1;
}
else if(screen_no==1)
{
on_time1_rl1=ccc1;
on_time2_rl1=ccc2;
on_time3_rl1=ccc3;
on_time_rl1=on_time1_rl1+(10*on_time2_rl1)+(100*on_time3_rl1);
ee_byte_to_ee(0x0b,on_time1_rl1);delay(10);
ee_byte_to_ee(0x1b,on_time2_rl1);delay(10);
ee_byte_to_ee(0x2b,on_time3_rl1);delay(10);
screen_no=2;
write_LCD_line(LINE_1,"I/P 2 ON TIME:");
char_sel=1;
ccc1=on_time1_rl2;
ccc2=on_time2_rl2;
ccc3=on_time3_rl2;
}
else if(screen_no==2)
{
on_time1_rl2=ccc1;
on_time2_rl2=ccc2;
on_time3_rl2=ccc3;
on_time_rl2=on_time1_rl2+(10*on_time2_rl2)+(100*on_time3_rl2);
ee_byte_to_ee(0x4b,on_time1_rl2); delay(10);
ee_byte_to_ee(0x5b,on_time2_rl2); delay(10);
ee_byte_to_ee(0x6b,on_time3_rl2);delay(10);
screen_no=3;
write_LCD_line(LINE_1,"I/P 3 ON TIME:");
char_sel=1;
ccc1=on_time1_rl3;
ccc2=on_time2_rl3;
ccc3=on_time3_rl3;
}
else if(screen_no==3)
{
on_time1_rl3=ccc1;
on_time2_rl3=ccc2;
on_time3_rl3=ccc3;
on_time_rl3=on_time1_rl3+(10*on_time2_rl3)+(100*on_time3_rl3);
ee_byte_to_ee(0x7b,on_time1_rl3); delay(10);
ee_byte_to_ee(0x8b,on_time2_rl3); delay(10);
ee_byte_to_ee(0x9b,on_time3_rl3); delay(10);
screen_no=4;
write_LCD_line(LINE_1,"I/P 1 OFF TIME:");
char_sel=1;
ccc1=off_time1_rl1;
ccc2=off_time2_rl1;
ccc3=off_time3_rl1;
}
else if(screen_no==4)
{
off_time1_rl1=ccc1;
off_time2_rl1=ccc2;
off_time3_rl1=ccc3;
off_time_rl1=off_time1_rl1+(10*off_time2_rl1)+(100*off_time3_rl1);
ee_byte_to_ee(0xab,off_time1_rl1); delay(10);
ee_byte_to_ee(0xbb,off_time2_rl1); delay(10);
ee_byte_to_ee(0xcb,off_time3_rl1); delay(10);
screen_no=5;
write_LCD_line(LINE_1,"I/P 2 OFF TIME:");
char_sel=1;
ccc1=off_time1_rl2;
ccc2=off_time2_rl2;
ccc3=off_time3_rl2;
}
else if(screen_no==5)
{
off_time1_rl2=ccc1;
off_time2_rl2=ccc2;
off_time3_rl2=ccc3;
off_time_rl2=off_time1_rl2+(10*off_time2_rl2)+(100*off_time3_rl2);
ee_byte_to_ee(0xdb,off_time1_rl2); delay(10);
ee_byte_to_ee(0xeb,off_time2_rl2); delay(10);
ee_byte_to_ee(0x43,off_time3_rl2); delay(10);
screen_no=6;
write_LCD_line(LINE_1,"I/P 3 OFF TIME:");
char_sel=1;
ccc1=off_time1_rl3;
ccc
小波思基
- 粉丝: 89
- 资源: 1万+
最新资源
- OfficeVBA宏使用宏实现表格中根据一列分类拆分到对应的sheet表中V2
- 大作业课设基于java swing实现的酒店管理系统源码+数据库+文档说明
- 全驱动船舶轨迹跟踪自适应动态面滑模控制;带有扰动观测器;圆轨迹和直线轨迹;自适应滑模;动态面控制
- 光储直流微电网能量管理 系统主要由光伏发电模块、mppt控制模块、混合储能系统模块、直流负载模块、改进前的soc限值管理控制模块、改进后的SOC限值管理控制模块和hess能量管理控制模块 光伏发电
- Java毕业设计基于Springboot+Vue的校园二手商城系统源码+数据库
- 最新全工具版本Qt+OpenCV通用视觉框架全套源码 工具可扩展 除了opencv和相机sdk的dll,其它所有算法均无封装,可以根据自己需要补充自己的工具 基于 Qt5.12.12 + VS2
- 基于springboot的校园市场平台源码+数据库(Java毕业设计项目)
- 格子玻尔兹曼 LBM 液滴撞击液膜
- 两种基于滑模观测器的PMSM无感矢量控制仿真(开关设置区分): 1. PLL+滑模(降低高频开关噪声); 2. arctan+滑模; 有配套算法原理资料 软件类产品,纯手工搭建,仅供学习参考
- 永磁同步电机的MTPA最大转矩电流比控制算法的仿真模型,有详细的算法设计文档 1. 永磁同步电机的数学模型; 2. 永磁同步电机的矢量控制原理; 3. 最大转矩电流比控制; 4. 前馈补偿提高抗负载
- MATLAB代码:基于二阶锥优化的电气综合能源系统多目标无功优化 关键词:配电网 无功优化 二阶锥 电气综合能源系统 仿真平台:MATLAB+CPLEX 平台 主要内容:代码主要做的是主动配电网的
- MATLAB代码:基于多目标遗传算法的分布式电源选址定容研究 关键词:分布式电源 选址定容 多目标遗传算法 参考文档:《店主自写文档》基本复现; 仿真平台:MATLAB 主要内容:代码主要做的
- 基于springboot的校园市场平台源码+数据库(Java毕业设计项目)
- 基于非对称纳什谈判的多微网电能共享运行优化策略 关键词:纳什谈判 合作博弈 微网 电转气-碳捕集 P2P电能交易交易 参考文档:《基于非对称纳什谈判的多微网电能共享运行优化策略》完美复现
- kettle - spoon 9.4 集成Elasticsearch 8.3插件 支持Elasticsearch7,8
- stm32电机控制器,嵌入式单片机仿真,keil+proteus,带报告 1、keil源文件 2、proteus仿真 3、报告(26页详细报告,含ad原理图,pcb等) 设计一个直流电机控制系统,可控
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈