Design of electric fan simulation control system 1. Functional description: The electric fan simulation control system can simulate the operation of electric fans, and is mainly composed of motor control circuit, motor overheat detection and protection circuit, timing and status display circuit, etc. 2. Design tasks: 1. Use 4-digit digital tube to display the working status of electric fans in real time, and the highest digit displays the wind type: \"natural wind\" displays \"1\", \"normal wind\" displays \"2\", and \"sleep wind\" displays \"3\". The last 3 digits display the timing time: the dynamic countdown displays the remaining timing time, and \"000\" is displayed when there is no timing. 2. Design three wind type keys of \"natural wind\", \"normal wind\" and \"sleep wind\" to set the wind type; design a \"timing\" key for setting the timing time; design a \"shaking head\" key to control the motor shaking head. 3. Design overheat detection and protection circuit. If the electric fan motor is overheated, the motor stops rotating, and the motor resumes rotating after cooling. 3. Design requirements 1. The given set components (attached components, bill of materials) must be fully utilized for design. 2. Use a small DC motor to simulate the electric fan motor. Press the corresponding wind type key and the motor will work in the corresponding state: when the \"natural wind\" is running, the PWM duty cycle is 1:3; when the \"sleep wind\" is running, the PWM duty cycle is 1:5; when the \"normal wind\" is running, the PWM duty cycle is 3:1. 3. Each time the \"timing\" key is pressed, the timing time increases by 10 seconds. The working process is as follows: (Figure omitted) 4. Use another small DC motor to simulate the fan shaking mechanism. Press the \"shaking\" key. The \"shaking\" motor first rotates forward for 30ms, then reverses for 30ms, and so on. 6. The overheat detection and protection circuit does not use a sensor. The sine wave signal generated by the signal source replaces the signal \"sensed\" by the sensor. If the signal amplitude is greater than 10mV, the motor stops rotating. IV. Submit electronic documents 1. Schematic diagram of the electric fan simulation control system; 2. Schematic diagram of the electric fan simulation control system circuit (using PROTEL software); 3. Flow chart of the electric fan simulation control system program; 4. Source program of the electric fan simulation control system. ▲ The submitted electronic documents must be named after the contestant\'s competition number. Real names must not be used, otherwise the competition results will be recorded as 0 points. If the competition number is 200917234, the four electronic documents are named in sequence: 200917234 schematic diagram.BMP; 200917234 principle diagram; 200917234 flow chart.BMP; 200917234 source program.TXT Reference circuit === ... 2. There is a 1413 driver on the actual board, which can be used as a bit driver for the LED digital tube display, so there is no problem with brightness. 3. In the code, try to ensure that the first 128B of RAM (direct addressing) are all used for user variables, put the stack in the last 128B of space, and define the array of fixed data in the FLASH space (see the array variable definition declared in the CODE in the code) 4. The peripheral motor drive circuit, motor, relay, and temperature input detection are not connected, and are verified and debugged through simulation 5. The output of PWM directly controls an LED on the board. When the duty cycle is different, the brightness change of the LED represents the different speed. If there is actually a motor, just change the frequency of PWM according to the actual situation. 6. The swing motor control can also use 2 LEDs to display the output of the control I/O 7. Use an I/O input \"1\" or \"0\" to indicate that the temperature is exceeded or normal. Reference code//=============================================================== #include #include //************************************************ // I/O port design //************************************************ //Input definition #define Key_null 0xff #define Key_f 0xfe #define Key_m 0xfd #define Key_t 0xfb //Control output/input sbit m_out = P3^6; sbit pwm_out = P3^7; sbit err_in = P1^3; //Function declaration void led_display(void); //====== //PWM motor output control (timer0 interrupt) code unsigned int pwm_m1[3] = {62536,56536,63536}; code unsigned int pwm_m2[3] = {56536,62536,55536}; unsigned char th01_new,tl01_new; unsigned char th02_new,tl02_new; bit pwm_state; void timer1(void) interrupt 1 //Timing 0 interrupt { if(pwm_state) { TL0 = tl01_new; TH0 = th01_new; pwm_out = 0; } else { TL0 = tl02_new; TH0 = th02_new; pwm_out = 1; } pwm_state = ~pwm_state; } bit key_time_ok,time_1s_ok; unsigned char key_time,time_1s; void timer0(void) interrupt 3 //Timer 1 interrupt { TL1 = 0x78; // THTL=0xec78 = 65536 - 5000(5ms) TH1 = 0xec; led_display(); // LED dynamic scan if (++key_time >= 4) { key_time = 0; key_time_ok = 1; //10ms to if(++time_1s >= 50) { time_1s = 0; time_1s_ok = 1; //1 second to } } } //====== //LED digital tube scan display driver unsigned char dis_buff[4]; code unsigned char led_7[13]= {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x40,0x79}; code unsigned char position[4]= {0xfe,0xfd,0xfb,0xf7}; void led_display(void) // 4-digit LED digital tube dynamic scanning function, executed once every 5ms{ static unsigned char posit; P0 = 0xff; // Turn off all displays P2 = led_7[dis_buff[posit]]; // Output a segment code P0 = position[posit]; // Display one of themif(++posit >= 4) posit = 0; } //======================== //Key scanning underlying interfaceunsigned char read_key(void) { static unsigned char key_press_old = Key_null,key_state = 0 ; unsigned char key_value= Key_null,key_press; key_press = P1; switch (key_state) { case 0: if(key_press != Key_null) key_state = 1; break; case 1: if (key_press != key_press_old) { key_state = 0; } else { if (key_press == Key_f) key _value = Key_f; if (key_press == Key_m) key_value = Key_m; if (key_press == Key_t) key_value = Key_t; key_state = 2; } break; case 2: if (key_press == Key_null) key_state = 0; break; } key_press_old = key_press; return key_value; } //================================================================================ // Main program//============================================================================================================ void main(void) { bit delay_time_ok = 0,m_type_ok = 0, move_on = 0; unsigned char f_type = 1,time_type = 0,delay_time = 0,move_time = 0,key; EA = 0; // Turn off global interrupt SP = 0x80; //Define the stack space to the 128B space after RAM, and give up the first 128B to the variable P2 = 0x00; P3 = 0x00; P0 = 0xff; P1 = 0xff; //Configure Timer0, Mode = 1, Interrupt = ENABLED, Clock Source = INTERNAL,Enable Gating Control=DISABLED TMOD &= 0XF0; /* clear Timer 0 */ TMOD |= 0X01; TL0 = 0x78; TH0 = 0xec; ET0 = 1; /* IE.1*/ TR0 = 1; /* TCON.4 start timer */ //Configure Timer1, Mode=1, Interrupt=ENABLED, Clock Source=INTERNAL, Enable Gating Control=DISABLED TMOD &= 0X0F; /* clear Timer 1 control */ TMOD |= 0X10; TL1 = 0X78; / / THTL=0xec78 = 65536 - 5000(5ms) TH1 = 0Xec; ET1 = 1; /* ET0 is IE.3 */ TR1 = 1; /* TCON.6 start timer */ dis_buff[3] = f_type; dis_buff[2] = 10; dis_buff[1] = 0; dis_buff[0] = 0; th01_new = pwm_m1[f_type-1] >> 8; tl01_new = pwm_m1[f_type-1]; th02_new = pwm_m2[f_type-1] >> 8; tl02_new = pwm_m2[f_type-1]; EA = 1; //Turn on global interrupt while(1) { if (err_in) { if(key_time_ok) { key_time_ok = 0; key = read_key(); if (key != Key_null) { if (key == Key_f) { if (++f_type >= 4) f_type = 1; th01_new = pwm_m1[f_type-1] >> 8; tl01_new = pwm_m1[f_type-1]; th02_new = pwm_m2[ f_type-1] >> 8; tl02_new = pwm_m2[f_type-1]; dis_buff[3] = f_type; } else if(key == Key_t) { if (++time_type >= 7) { time_type = 0; delay_time_ok = 0; delay_time = 0; } else { delay_time_ok = 1; delay_time = time_type * 10; } } else if(key == Key_m) { m_type_ok = ~m_type_ok; } } } if (time_1s_ok) { time_1s_ok = 0; if(delay_time) delay_time-- ; dis_buff[1] = delay_time / 10; dis_buff[0] = delay_time % 10; if (m_type_ok) { if (++move_time >= 3) { move_time = 0; move_on = ~move_on; } } } if (delay_time_ok) dis_buff[2] = 11; else dis_buff[2] = 10; if (delay_time_ok && (delay_time == 0)) { ET0 = 0; pwm_out = 1; }else { ET0 = 1; } if (m_type_ok) m_out = move_on; } else { ET0 = 0; pwm_out = 1; dis_buff[2] = 12; } } }