????????该仿真以Atmega128单片机作为核心,利用Proteus仿真软件搭建售水机仿真。该仿真设置有两个独立按键,功能分别是出水和停止;利用LGM12641BS1R作为显示装置,对售水机的出水量和售水价格进行显示。运行仿真后按下出水按钮,利用单片机内部的定时器产生基准时间,模拟出水控制,每秒钟出水100mL,在出水的同时单片机控制继电器吸合,当按下停止按键后,显示器会显示最终的价格。
????????按下出水按键后,单片机会模拟售水机出水,同时控制继电器吸合。出水量为100mL/秒。
???????按下停止出水按键后,售水机会停止出水,并根据当前的出水量和费率计算最终的售价。该仿真费率为固定式。
???????部分程序如下。
void main()
{
DDRA=0XFF;
PORTA=0xff;
DDRB=0XFF;
PORTB=0x00;
DDRC=0XFC;
PORTC=0xF3;
DDRD=0XFF;
PORTD=0XFF;
DDRE=0XFF;
PORTE=0XFF;
DDRF=0XFF;
PORTF=0XF0;
//LCD初始化
LCDchushihua();
LCDQingPing();
//显示字
LCD_display16161(0,20,6,(uchar *) word1);
LCD_display16161(2,0,3,(uchar *) word2);
LCD_display16161(4,0,2,(uchar *) word3);
LCD_display16161(4,100,1,(uchar *) word4);
LCD_display16161(2,100,1,(uchar *) word5);
//定时器1配置
//TCCR1B按键中配置
timer1_init();
TIMSK = 0x04; //timer interrupt sources
SEI();
while(1)
{
scan_key();
LCD_display816(2,48,(uchar*) (number+water_cnt/1000%10*10%100/10*16));
LCD_display816(2,56,(uchar*) (number+water_cnt/100%10*10%100/10*16));
LCD_display816(2,64,(uchar*) (number+water_cnt/10%10*10%100/10*16));
LCD_display816(2,72,(uchar*) (word6));
LCD_display816(2,80,(uchar*) (number+water_cnt%10*10%100/10*16));
LCD_display816(2,88,(uchar*) (number+water_cnt%10%100/10*16));
//LCD_display816(6,20,(uchar*) (number+140%100/10*16));
//LCD_display816(6,20,(uchar*) (number+140%100/10*16));
//LCD_display816(6,20,(uchar*) (number+140%100/10*16));
delay();
}
}
Atmega128售水机Proteus仿真-单片机文档类资源-CSDN文库https://download.csdn.net/download/xitianqu/85274231
|