Design of Smart Window System Based on Single Chip Computer (#0479)

Function description

1. Perpetual calendar time display: year/month/week/day/hour/minute/second, memory when power off/no need to adjust time when power on again;

2. Temperature display/over-standard alarm: you can set the temperature alarm threshold yourself;

3. Smoke alarm: the smoke alarm threshold can be adjusted by itself;

4. Manual control: the window can be switched on and off by pressing the button according to personal needs, this function can make the opening and closing of the window in any state;

5. Timing control: the window can be opened and closed at one time according to the set time;

6. Light intensity control: According to the set light intensity value, the light can be collected through the photoreceptor to automatically open and close the window. At the same time, when the monitored light intensity value is less than the set light intensity value, the LED will be automatically turned on for lighting;

circuit design

Altium Designer is used as a circuit design tool. Altium Designer provides designers with a new design solution through the perfect integration of schematic design, PCB drawing and editing, topology logic automatic routing, signal integrity analysis and design output, so that designers can easily design, skilled The use of this software will certainly greatly improve the quality and efficiency of circuit design.

MCU pin description:

Port P0 (P0.0-P0.7): Port P0 is an 8-bit open-drain bidirectional I/O port, each pin can absorb 8TTL gate current. When the pin of port P1 writes 1 for the first time, it is defined as a high-impedance input. P0 can be used for external program data memory, it can be defined as the eighth bit of data/address. During FIASH programming, the P0 port is used as the original code input port. When FIASH is verifying, P0 outputs the original code. At this time, the external P0 must be pulled high.

P1 port (P1.0-P1.7): P1 port is an 8-bit bidirectional I/O port with internal pull-up resistor, and the P1 port buffer can receive and output 4TTL gate current. After the P1 port pin is written to 1, it is internally pulled up to a high level and can be used as an input. When the P1 port is externally pulled down to a low level, it will output current, which is due to the internal pull-up. During FLASH programming and verification, the P1 port is received as the eighth address.

P2 port (P2.0-P2.7): P2 port is an 8-bit bidirectional I/O port with an internal pull-up resistor. The P2 port buffer can receive and output 4 TTL gate currents. When the P2 port is written "1" ”, its pin is pulled high by the internal pull-up resistor and used as an input. Therefore, when it is used as an input, the pin of the P2 port is externally pulled low, and the current will be output. This is due to the internal pull-up. Port P2 is used for accessing the external program memory or external data memory with a 16-bit address, and the upper eight bits of the output address of the P2 port. When the address "1" is given, it takes advantage of the internal pull-up. When reading and writing to the external eight-bit address data memory, the P2 port outputs the contents of its special function register. The P2 port receives the high-order eight-bit address signal and control signal during FLASH programming and verification.

P3 port (P3.0-P3.7): The P3 port pin is an 8-bit bidirectional I/O port with an internal pull-up resistor, which can receive and output 4 TTL gate currents. When "1" is written to the P3 port, they are internally pulled high and used as input. When used as an input terminal, since the external pull-down is low, the P3 port will output current (ILL). Port 3 receives some control signals for flash programming and programming verification at the same time.

Simulation design

Proteus is used as a simulation design tool. Proteus is a well-known EDA tool (simulation software), from schematic layout, code debugging to co-simulation of microcontroller and peripheral circuits, one-click switching to PCB design, truly realizing the complete design from concept to product.

 

main program design

void main()
{	
	init_eepom();		 //Initialize EEPROM
	init_1602();		 //lcd1602 initialization
	init_1602_dis_csf(); //lcd1602 initialization display
	init_ds1302_io();	 //Initialize ds1302Io
	init_time0();		 //Initialize the timer
	menu_1_break();	     //menu initial interface
	init_ds1302();		 //ds1302 initialization
	temperature1 = read1_temp();  //read temperature 1
	delay_1ms(650);
	while(1)
	{
		key();			 //key program
		if(key_can < 10)
		{
			key_with();	
		}
		shoudong_kaiguan();	  //Manual switch curtain
		if(flag_200ms == 1)
		{		
			flag_200ms = 0;
			temperature1 = read1_temp();  //read temperature1 ambient temperature
			if(temperature1 >= 99)
				temperature1 = 99;
			zinengchuanglian_dis();	  //Smart Curtain Processing Function
			guanxian = ad0832read(1,0) * 9.0 / 255;
			if((menu_1 == 0))
			{
				read_time();		  //reading time
				init_1602_ds1302();   //show clock
				write_sfm_18b20(2,13,temperature1);	//Display temperature
				write_sfm1(2,0,guanxian);	//Display temperature
				  	if(guanxian <= guanxian_set)
			 LED=0;
			else
			 LED=1;
				if((temperature1 >= t_high)||(yw==0))
					beep =	~beep;   //Buzzer temperature smoke alarm
				else 
					beep = 1;        
			}
		}
		bujindj();	 //Stepper Motor Function
	}
}

source file acquisition

Pay attention to the official account - electronic development circle, and send the "smart window" on the home page to get it;

Tags: Embedded system Single-Chip Microcomputer

Posted by Izzy1979 on Mon, 11 Jul 2022 23:52:34 +0530