#include "main.h" #include "public.h" #include "led.h" #include "key.h" #include "sim_eeprom.h" #include "tim3_pwm_output.h" #include "adc_dma_multichanit.h" #include #include "uart.h" #include "pid.h" #define TEST_TEMP 180 #define TEST_TEMP_1 240 #define UP_CONTROL 1 #define DOWN_CONTROL 1 static u8 one_times = 0; unsigned short last_arrive_temp; unsigned short last_out_temp; unsigned char temp_suv ; unsigned char last_one; unsigned short get_TCR_180() { unsigned short Temp = 0; float tmp_0 = 0; float tmp_1 = 0; tmp_0 = (R_2 - (float)g_work.m_set.m_set._up_R / 1000.0f) / ((float)(g_work.m_set.m_set._up_R/1000.0f)); // 上段 tmp_1 = tmp_0 / (float)((float)g_work.temp_out_2 - 25); g_work.m_set.m_set._K_18_Value_1 = tmp_1 * 1000000; send_2_Address_Value(0xFE,0x54,0,g_work.m_set.m_set._K_18_Value,g_work.m_set.m_set._K_18_Value_1); Temp = 25 + ( R_2 - (float)g_work.m_set.m_set._up_R / 1000.0f) / ( (float)g_work.m_set.m_set._K_18_Value_1/1000000.0f * g_work.m_set.m_set._up_R/1000.0f); if( g_work.m_set.m_set._K_18_Value_1 < 3000 || g_work.m_set.m_set._K_18_Value_1 > 5000) { send_ack(0x57,0xFE,2); } g_work.temp_2 = Temp; return Temp; } unsigned short get_TCR_180_1() // 下段 { unsigned short Temp = 0; float tmp_0 = 0; float tmp_1 = 0; tmp_0 = (R_1 - (float)g_work.m_set.m_set._down_R / 1000.0f) / ((float)(g_work.m_set.m_set._down_R/1000.0f)); // 下段段 tmp_1 = tmp_0 / (float)((float)g_work.temp_out_1 - 25); g_work.m_set.m_set._K_18_Value = tmp_1 * 1000000; send_2_Address_Value(0xFE,0x54,0,g_work.m_set.m_set._K_18_Value,g_work.m_set.m_set._K_18_Value_1); Temp = 25 + ( R_1 - (float)g_work.m_set.m_set._down_R / 1000.0f) / ( (float)g_work.m_set.m_set._K_18_Value/1000000.0f * g_work.m_set.m_set._down_R/1000.0f); g_work.temp_1 = Temp; if( g_work.m_set.m_set._K_18_Value < 3000 || g_work.m_set.m_set._K_18_Value > 5000) { send_ack(0x57,0xFE,2); } return Temp; } unsigned short get_TCR_230() { unsigned short Temp = 0; float tmp_0 = 0; float tmp_1 = 0; tmp_0 = (R_2 - (float)g_work.m_set.m_set._up_R / 1000.0f) / ((float)(g_work.m_set.m_set._up_R/1000.0f)); // 上段 tmp_1 = tmp_0 / (float)((float)g_work.temp_out_2 - 25); g_work.m_set.m_set._K_24_Value_1 = tmp_1 * 1000000; send_2_Address_Value(0xFE,0x54,1,g_work.m_set.m_set._K_24_Value,g_work.m_set.m_set._K_24_Value_1); Temp = 25 + ( R_2 - (float)g_work.m_set.m_set._up_R / 1000.0f) / ( (float)g_work.m_set.m_set._K_24_Value_1/1000000.0f * g_work.m_set.m_set._up_R/1000.0f); //printf("Temp: %d\r\n",Temp); if( g_work.m_set.m_set._K_24_Value_1 < 3000 || g_work.m_set.m_set._K_24_Value_1 > 5000) { send_ack(0x57,0xFE,2); } g_work.temp_2 = Temp; return Temp; } unsigned short get_TCR_230_1() { unsigned short Temp = 0; float tmp_0 = 0; float tmp_1 = 0; tmp_0 = (R_1 - (float)g_work.m_set.m_set._down_R / 1000.0f) / ((float)(g_work.m_set.m_set._down_R/1000.0f)); // 上段 tmp_1 = tmp_0 / (float)((float)g_work.temp_out_1 - 25); g_work.m_set.m_set._K_24_Value = tmp_1 * 1000000; send_2_Address_Value(0xFE,0x54,1,g_work.m_set.m_set._K_24_Value,g_work.m_set.m_set._K_24_Value_1); Temp = 25 + ( R_1 - (float)g_work.m_set.m_set._down_R / 1000.0f) / ( (float)g_work.m_set.m_set._K_24_Value/1000000.0f * g_work.m_set.m_set._down_R/1000.0f); //printf("Temp: %d\r\n",Temp); if( g_work.m_set.m_set._K_24_Value < 3000 || g_work.m_set.m_set._K_24_Value > 5000) { send_ack(0x57,0xFE,2); } g_work.temp_1 = Temp; return Temp; } //void temp_chotrol() //{ // static unsigned short last_temp_1_1 = 0; // duty(0, 1,0); // pid.curr = g_work.temp_out_2; // pid_calc(); // // if( g_work.up_test_chose == 0 ) // { // // pid.set = 180; // if( g_work.temp_out_2 == 180 || g_work.temp_out_2 == 179 || g_work.temp_out_2 == 181 ) // { // g_work.up_keep_flag = 1; // } // else // { // g_work.up_keep_flag = 0; // } // // if( g_work.m_time._Up_arrive_keep_time > 5000 ) // { // if( last_temp_1_1 >= g_work.temp_out_1_1 - 2 && last_temp_1_1 <= g_work.temp_out_1_1 + 2 ) // { // if( last_temp_1_1 >= 165 ) // { // get_TCR_180(); // g_work.up_test_chose = 1; // } // } // else // { // last_temp_1_1 = g_work.temp_out_1_1; // } // g_work.m_time._Up_arrive_keep_time = 0; // } // } // else if (g_work.up_test_chose == 1 ) // { // pid.set = 230; // if( g_work.temp_out_2 == 230 || g_work.temp_out_2 == 229 || g_work.temp_out_2 == 231 ) // { // g_work.up_keep_flag = 1; // } // else // { // g_work.up_keep_flag = 0; // } // // if( g_work.m_time._Up_arrive_keep_time > 5000 ) // { // if( last_temp_1_1 >= g_work.temp_out_1_1 - 2 && last_temp_1_1 <= g_work.temp_out_1_1 + 2 ) // { // get_TCR_230(); // g_work.up_test_chose = 2; // flash_wite(); // } // else // { // last_temp_1_1 = g_work.temp_out_1_1; // } // g_work.m_time._Up_arrive_keep_time = 0; // // } // } // else // { // // g_work.m_time._Up_arrive_keep_time = 0; // pid.currpwm = 0; // send_ack(0x57, 0xFE,1); // } // duty(1,1,pid.currpwm ); //// if( g_work.Uart_match == 3 ) // 180 //// { //// if ( g_work.up_test_chose == 0) //// { //// if( g_work.temp_out_2 < 179 ) // 上段温度控制 //// { //// //// //// if( 179 - g_work.temp_out_2 < 70 ) //// { //// temp_suv = 70 - ( 179 - g_work.temp_out_2 ) ; //// } //// else //// { //// temp_suv = 0; //// } //// //// duty(1,1,85 - temp_suv); //// g_work.up_arrive_times = 0; //// g_work.up_test_chose = 0; //// } //// else //// { //// //// if( g_work.up_arrive_times == 0) //// { //// last_arrive_temp = get_TCR_180(); //// g_work.up_arrive_times = 1; //// } //// if( g_work.temp_2 < last_arrive_temp ) //// { //// duty(1,1,10 ); //// } //// else //// { //// duty(1, 1,0); //// } //// } //// if( g_work.temp_out_1_1 > 165 ) //// { //// if( g_work.temp_out_2 == 180 || g_work.temp_out_2 == 179 || g_work.temp_out_2 == 181) //// { //// g_work.up_test_chose = 1; //// get_TCR_180(); //// } //// } //// //// if( g_work.temp_out_1 < 140 ) //// { //// duty(0, 1,50); //// } //// else //// { //// duty(0, 1,0); //// } //// //// } //// else //// { //// if( g_work.temp_out_2 < 230 ) // 上段温度控制 //// { //// //// //// if( 230 - g_work.temp_out_2 < 70 ) //// { //// temp_suv = 70 - ( 230 - g_work.temp_out_2 ) ; //// } //// else //// { //// temp_suv = 0; //// } //// //// duty(1,1,90 - temp_suv); //// g_work.up_arrive_times = 0; //// //// } //// else if( g_work.temp_out_2 == 230 ) //// { //// if( g_work.up_arrive_times == 0) //// { //// last_arrive_temp = get_TCR_230(); //// g_work.up_arrive_times = 1; //// flash_wite(); //// send_ack(0x57, 0xFE,1); //// } //// duty(1,1,15); //// } //// else if ( g_work.temp_out_2 == 231 ) //// { //// duty(1,1,10); //// } //// else if ( g_work.temp_out_2 == 230 ) //// { //// duty(1,1,5); //// } //// else //// { //// duty(1,1,0); //// } //// if( g_work.temp_out_1 < 140 ) //// { //// duty(0, 1,50); //// } //// else //// { //// duty(0, 1,0); //// } //// } //// } //} void temp_control_1() // 下段温度控制 { static unsigned short last_temp_1_1 = 0; // duty(1,1,0); pid.curr = g_work.temp_out_1; pid_calc(); if( g_work.up_test_chose == 0 ) { pid.set = 180; if( g_work.temp_out_1 == 180 || g_work.temp_out_1 == 179 || g_work.temp_out_1 == 181) { g_work.up_keep_flag = 1; } else { g_work.up_keep_flag = 0; } if( g_work.m_time._Up_arrive_keep_time > 5000 ) { if( last_temp_1_1 >= g_work.temp_out_1_1 - 2 && last_temp_1_1 <= g_work.temp_out_1_1 + 2 ) { get_TCR_180_1(); g_work.up_test_chose = 1; } else { last_temp_1_1 = g_work.temp_out_1_1; } g_work.m_time._Up_arrive_keep_time = 0; } } else if (g_work.up_test_chose == 1 ) { pid.set = 230; if( g_work.temp_out_1 == 230 || g_work.temp_out_1 == 299 || g_work.temp_out_1 == 231) { g_work.up_keep_flag = 1; } else { g_work.up_keep_flag = 0; } if( g_work.m_time._Up_arrive_keep_time > 5000 ) { if( last_temp_1_1 >= g_work.temp_out_1_1 - 2 && last_temp_1_1 <= g_work.temp_out_1_1 + 2 ) { get_TCR_230_1(); g_work.up_test_chose = 2; } else { last_temp_1_1 = g_work.temp_out_1_1; } g_work.m_time._Up_arrive_keep_time = 0; } } else { g_work.m_time._Up_arrive_keep_time = 0; pid.currpwm = 0; send_ack(0x57, 0xFE,1); } // duty(0,1,pid.currpwm ); } unsigned char temp_pwm(u32 time, unsigned short setTemp, unsigned short currTemp) { //static u8 two_times = 0; static u8 curr_Pwm = 0; static u8 last_Pwm = 0; static u32 last_time = 0; static u16 Hight_temp = 0; static u8 pwm_C_flag = 0; if( time - last_time > 500 ) { //printf("\r\n PWM: %d T:%d \r\n",curr_Pwm,currTemp); last_time = time; } if( currTemp < setTemp - 1 ) { if( one_times == 0 ) { if( setTemp - currTemp < 60 ) { curr_Pwm = 60 - ( setTemp - currTemp ) ; } else { curr_Pwm = 0; } curr_Pwm = 85 -curr_Pwm; last_Pwm = curr_Pwm; } else { if ( pwm_C_flag == 0 ) { //printf("\r\nHight_temp: %d\r\n ",Hight_temp ); if( Hight_temp - setTemp > 7) // 如果大于 5° 取之前的半值 { curr_Pwm = last_Pwm/ 2; last_Pwm = curr_Pwm; } if( Hight_temp - setTemp > 1 ) // 大于3° 微调 { last_Pwm --; curr_Pwm = last_Pwm; } Hight_temp = currTemp; pwm_C_flag = 1; } curr_Pwm = last_Pwm; } Hight_temp = currTemp; } else if (currTemp >= setTemp - 1 && currTemp <= setTemp + 1) { if( one_times == 1) { if ( pwm_C_flag == 0 ) { //printf("\r\nHight_temp: %d\r\n ",Hight_temp ); if( Hight_temp - currTemp > 7) // 如果大于 5° 取之前的半值 { curr_Pwm = last_Pwm/ 2; last_Pwm = curr_Pwm; } else if( Hight_temp - currTemp >= 1 ) // 大于3° 微调 { last_Pwm --; curr_Pwm = last_Pwm; } Hight_temp = currTemp; pwm_C_flag = 1; } } else if ( one_times == 0 ) { curr_Pwm = 0; } if( currTemp == setTemp - 1 ) { curr_Pwm = last_Pwm - 1; } else if ( currTemp == setTemp) { curr_Pwm = last_Pwm - 4; } else { curr_Pwm = last_Pwm - 6; } } else { curr_Pwm = 0; pwm_C_flag = 0; one_times = 1; if ( currTemp >= Hight_temp ) { Hight_temp = currTemp; } } return curr_Pwm; } #if USE_2_High void Temp_control_TCR() { static unsigned short last_temp_1_1 = 0; static u32 test_Time = 0; static u16 last_temp_control =0; static u16 last_temp_tool = 0; static u8 start_flag_18 = 0; static u8 start_flag_24 = 0; u8 pwm = 0; if( g_work.uart_check_flag == 0 ) // 没有检测到数据 { if( g_work.m_time._Sleep_time - test_Time > 2500 ) { g_work.power = 0; g_work.work_conditon = STANDY; } } else { test_Time = g_work.m_time._Sleep_time ; } switch( g_work.up_test_chose ) { case 1: // 校准 上段 pwm = temp_pwm(g_work.m_time._Sleep_time ,229,g_work.temp_out_2); if( g_work.temp_out_1_1 < 160 ) { // duty(0, 1,25); } else { // duty(0, 1,0); } if( g_work.temp_out_2 == 230 || g_work.temp_out_2 == 229 || g_work.temp_out_2 == 231 ) // 检查温度是否到达温度 叨叨温度后检测 上段温度是否有没有变化 没有变化 开启上段保持计时用于查看上段有没有变化 { if( last_temp_tool != g_work.temp_2 ) { g_work.up_mid_flag = 0; g_work.up_keep_flag = 0; last_temp_tool = g_work.temp_2; } else { g_work.up_keep_flag = 1; } } else { g_work.up_mid_flag = 0; g_work.up_keep_flag = 0; } if( g_work.m_time._Up_arrive_keep_time > 1500 ) // 保持计时到了以后 查看中断温度是否改变 { if( (last_temp_1_1 >= g_work.temp_out_1_1 - 1) && ( last_temp_1_1 <= g_work.temp_out_1_1 + 1 ) ) // { if( g_work.temp_out_1_1 >= 200 ) { if( g_work.last_temp_out_1_1 == g_work.temp_out_1_1 ) // 中段温度没有改变后 开启 中段温度计时 如果在时间内变化了温度 重新计时 { g_work.up_mid_flag = 1; } else { g_work.up_mid_flag = 0; g_work.m_time._Up_arrive_Mid_time = 0; g_work.m_time._Up_arrive_keep_time = 0; g_work.last_temp_out_1_1 = g_work.temp_out_1_1; } if( g_work.m_time._Up_arrive_Mid_time > 1500 ) // 中段温度没有改变后 记录数据 { get_TCR_180(); flash_wite(); g_work.up_test_chose = 2; g_work.m_time._Up_arrive_keep_time = 0; one_times = 0; last_temp_tool = 0; last_temp_1_1 = 0; } } } else { last_temp_1_1 = g_work.temp_out_1_1; g_work.m_time._Up_arrive_keep_time = 0; } } start_flag_18 = 0; // duty(1,1,pwm ); break; case 0: // 下段 pwm = temp_pwm(g_work.m_time._Sleep_time ,179,g_work.temp_out_1); // duty(1,1,0); if( g_work.temp_out_1 == 180 || g_work.temp_out_1 == 179 || g_work.temp_out_1 == 181) { if( last_temp_tool != g_work.temp_1 ) { g_work.up_mid_flag = 0; last_temp_1_1 = g_work.temp_out_1_1; g_work.up_keep_flag = 0; last_temp_tool = g_work.temp_1; } else { g_work.up_keep_flag = 1; } } else { g_work.up_mid_flag = 0; g_work.up_keep_flag = 0; } if( start_flag_18 == 0 ) { g_work.m_time._Up_arrive_keep_time = 0; if(g_work.temp_out_1_1 > 160) // 等上段温度降下来 { // duty(0,1,0 ); } else { start_flag_18 = 1; } } else { if( g_work.m_time._Up_arrive_keep_time > 1500 ) { if( last_temp_1_1 >= g_work.temp_out_1_1 - 1 && last_temp_1_1 <= g_work.temp_out_1_1 + 1 ) { if( g_work.temp_out_1_1 > 151 ) // { if( g_work.last_temp_out_1_1 == g_work.temp_out_1_1 ) // 中段温度没有改变后 开启 中段温度计时 如果在时间内变化了温度 重新计时 { g_work.up_mid_flag = 1; } else { g_work.up_mid_flag = 0; g_work.m_time._Up_arrive_Mid_time = 0; g_work.m_time._Up_arrive_keep_time = 0; g_work.last_temp_out_1_1 = g_work.temp_out_1_1; } if( g_work.m_time._Up_arrive_Mid_time > 1500 ) { g_work.up_test_chose = 1; get_TCR_180_1(); flash_wite(); g_work.m_time._Up_arrive_keep_time = 0; one_times = 0; } } } else { last_temp_1_1 = g_work.temp_out_1_1; } g_work.m_time._Up_arrive_keep_time = 0; } // duty(0,1,pwm ); } break; case 2: if( g_work.m_time._Sleep_time % 500 == 0 ) { one_times = 0; g_work.m_time._Up_arrive_keep_time = 0; pid.currpwm = 0; send_ack(0x57, 0xFE,1); // duty(0,1,0 ); // duty(1,1,0 ); } break; default: break; } } #else void Temp_control_TCR() { static unsigned short last_temp_1_1 = 0; static u32 test_Time = 0; static u16 last_temp_control =0; static u16 last_temp_tool = 0; static u8 start_flag_18 = 0; static u8 start_flag_24 = 0; u8 pwm = 0; if( g_work.uart_check_flag == 0 ) // 没有检测到数据 { if( g_work.m_time._Sleep_time - test_Time > 2500 ) { g_work.power = 0; g_work.work_conditon = STANDY; } } else { test_Time = g_work.m_time._Sleep_time ; } switch( g_work.up_test_chose ) { case 0: pwm = temp_pwm(g_work.m_time._Sleep_time ,179,g_work.temp_out_2); if( g_work.temp_out_1_1 < 145 ) { duty(0, 1,20); } else { duty(0, 1,0); } if( g_work.temp_out_2 == 180 || g_work.temp_out_2 == 179 || g_work.temp_out_2 == 181 ) { // if( last_temp_control != g_work.temp_out_2 ) // { // last_temp_control = g_work.temp_out_2; // g_work.up_keep_flag = 0; // } // else // { if( last_temp_tool != g_work.temp_2 ) { g_work.up_keep_flag = 0; last_temp_tool = g_work.temp_2; } else { g_work.up_keep_flag = 1; } // } } else { // if( 179 - g_work.temp_out_2 < 70 ) // { // temp_suv = 70 - ( 179 - g_work.temp_out_2 ) ; // } // else // { // temp_suv = 0; // } g_work.up_keep_flag = 0; } if( g_work.m_time._Up_arrive_keep_time > 1500 ) { if( last_temp_1_1 >= g_work.temp_out_1_1 - 2 && last_temp_1_1 <= g_work.temp_out_1_1 + 2 ) { if( g_work.temp_out_1_1 >= 165 ) { get_TCR_180(); g_work.up_test_chose = 1; g_work.m_time._Up_arrive_keep_time = 0; one_times = 0; last_temp_tool = 0; last_temp_1_1 = 0; } } else { last_temp_1_1 = g_work.temp_out_1_1; } g_work.m_time._Up_arrive_keep_time = 0; } start_flag_18 = 0; duty(1,1,pwm ); break; case 1: // pwm = temp_pwm(g_work.m_time._Sleep_time ,179,g_work.temp_out_1); duty(1,1,0); if( g_work.temp_out_1 == 180 || g_work.temp_out_1 == 179 || g_work.temp_out_1 == 181) { if( last_temp_tool != g_work.temp_1 ) { last_temp_1_1 = g_work.temp_out_1_1; g_work.up_keep_flag = 0; last_temp_tool = g_work.temp_1; } else { g_work.up_keep_flag = 1; } } else { g_work.up_keep_flag = 0; } if( start_flag_18 == 0 ) { g_work.m_time._Up_arrive_keep_time = 0; if(g_work.temp_out_2 > 120) // 等上段温度降下来 { duty(0,1,0 ); } else { start_flag_18 = 1; } } else { if( g_work.m_time._Up_arrive_keep_time > 1500 ) { if( last_temp_1_1 >= g_work.temp_out_1_1 - 1 && last_temp_1_1 <= g_work.temp_out_1_1 + 1 ) { get_TCR_180_1(); g_work.up_test_chose = 2; g_work.m_time._Up_arrive_keep_time = 0; one_times = 0; } else { last_temp_1_1 = g_work.temp_out_1_1; } g_work.m_time._Up_arrive_keep_time = 0; } duty(0,1,pwm ); } break; case 2: //pid.set = 230; pwm = temp_pwm(g_work.m_time._Sleep_time ,229,g_work.temp_out_2); duty(0, 1,0); if( g_work.temp_out_2 == 230 || g_work.temp_out_2 == 229 || g_work.temp_out_2 == 231 ) { //g_work.up_keep_flag = 1; if( last_temp_tool != g_work.temp_2 ) { g_work.up_keep_flag = 0; last_temp_tool = g_work.temp_2; } else { g_work.up_keep_flag = 1; } } else { g_work.up_keep_flag = 0; } if( g_work.m_time._Up_arrive_keep_time > 1500 ) { if( last_temp_1_1 >= g_work.temp_out_1_1 - 2 && last_temp_1_1 <= g_work.temp_out_1_1 + 2 ) { if( g_work.temp_out_1_1 >= 210 ) { get_TCR_230(); g_work.up_test_chose = 3; flash_wite(); g_work.m_time._Up_arrive_keep_time = 0; one_times = 0; last_temp_tool = 0; } } else { last_temp_1_1 = g_work.temp_out_1_1; } g_work.m_time._Up_arrive_keep_time = 0; } start_flag_24 = 0; duty(1,1,pwm ); break; case 3: //pid.set = 230; pwm = temp_pwm(g_work.m_time._Sleep_time ,229,g_work.temp_out_1); duty(1,1,0); if( g_work.temp_out_1 == 230 || g_work.temp_out_1 == 299 || g_work.temp_out_1 == 231) { //g_work.up_keep_flag = 1; if( last_temp_tool != g_work.temp_1 ) { g_work.up_keep_flag = 0; last_temp_tool = g_work.temp_1; } else { g_work.up_keep_flag = 1; } } else { g_work.up_keep_flag = 0; } if( start_flag_24 == 0 ) { g_work.m_time._Up_arrive_keep_time = 0; if(g_work.temp_out_1_1 > 200) { duty(0,1,0 ); } else { start_flag_24 = 1; } } else { if( g_work.m_time._Up_arrive_keep_time > 1500 ) { if( last_temp_1_1 >= g_work.temp_out_1_1 - 1 && last_temp_1_1 <= g_work.temp_out_1_1 + 1 ) { if( last_temp_1_1 >= 180 && last_temp_1_1 < 210) { get_TCR_230_1(); g_work.up_test_chose = 4; flash_wite(); send_ack(0x57, 0xFE,1); g_work.m_time._Up_arrive_keep_time = 0; one_times = 0; } } else { last_temp_1_1 = g_work.temp_out_1_1; } g_work.m_time._Up_arrive_keep_time = 0; } duty(0,1,pwm ); } break; case 4: if( g_work.m_time._Sleep_time % 500 == 0 ) { g_work.m_time._Up_arrive_keep_time = 0; pid.currpwm = 0; send_ack(0x57, 0xFE,1); duty(0,1,0 ); duty(1,1,0 ); } break; default: break; } } #endif //void Temp_control_TCR() //{ // // static unsigned short last_temp_1_1 = 0; //// pid.set = 180; //// pid.curr = g_work.temp_out_2; //// pid_calc(); //// duty(0, 1,0); //// duty(1,1,pid.currpwm ); // // if( g_work.uart_check_flag == 0 ) // 没有检测到数据 // { // // printf("123 !!\r\n"); // if( g_work.temp_out_2 > 250 || g_work.temp_out_1 > 250 ) // { // g_work.power = 0; // g_work.work_conditon = STANDY; // } // // } // switch( g_work.up_test_chose ) // { // case 0: // pid.set = 180; // if( g_work.temp_out_1_1 < 145 ) // { // duty(0, 1,15); // } // else // { // duty(0, 1,0); // } // // pid.curr = g_work.temp_out_2; // pid_calc(); // // // if( g_work.temp_out_2 == 180 || g_work.temp_out_2 == 179 || g_work.temp_out_2 == 181 ) // { // g_work.up_keep_flag = 1; // } // else // { // // if( 179 - g_work.temp_out_2 < 70 ) // { // temp_suv = 70 - ( 179 - g_work.temp_out_2 ) ; // } // else // { // temp_suv = 0; // } // g_work.up_keep_flag = 0; // } // // if( g_work.m_time._Up_arrive_keep_time > 5000 ) // { // if( last_temp_1_1 >= g_work.temp_out_1_1 - 2 && last_temp_1_1 <= g_work.temp_out_1_1 + 2 ) // { // if( last_temp_1_1 >= 170 ) // { // get_TCR_180(); // g_work.up_test_chose = 1; // g_work.m_time._Up_arrive_keep_time = 0; // } // } // else // { // last_temp_1_1 = g_work.temp_out_1_1; // } // g_work.m_time._Up_arrive_keep_time = 0; // } // if( g_work.temp_out_2 > 181 ) // { // pid.currpwm = 0; // } // duty(1,1,pid.currpwm ); // break; // case 1: // // pid.set = 230; // // duty(0, 1,0); // pid.curr = g_work.temp_out_2; // pid_calc(); // if( g_work.temp_out_2 == 230 || g_work.temp_out_2 == 229 || g_work.temp_out_2 == 231 ) // { // g_work.up_keep_flag = 1; // } // else // { // g_work.up_keep_flag = 0; // } // // if( g_work.m_time._Up_arrive_keep_time > 5000 ) // { // if( last_temp_1_1 >= g_work.temp_out_1_1 - 2 && last_temp_1_1 <= g_work.temp_out_1_1 + 2 ) // { // get_TCR_230(); // g_work.up_test_chose = 2; // flash_wite(); // g_work.m_time._Up_arrive_keep_time = 0; // } // else // { // last_temp_1_1 = g_work.temp_out_1_1; // } // g_work.m_time._Up_arrive_keep_time = 0; // // } // duty(1,1,pid.currpwm ); // break; // case 2: // pid.set = 180; // duty(1,1,0); // pid.curr = g_work.temp_out_1; // pid_calc(); // // if( g_work.temp_out_1 == 180 || g_work.temp_out_1 == 179 || g_work.temp_out_1 == 181) // { // g_work.up_keep_flag = 1; // } // else // { // g_work.up_keep_flag = 0; // } // // if( g_work.m_time._Up_arrive_keep_time > 5000 ) // { // if( last_temp_1_1 >= g_work.temp_out_1_1 - 2 && last_temp_1_1 <= g_work.temp_out_1_1 + 2 ) // { // get_TCR_180_1(); // g_work.up_test_chose = 3; // g_work.m_time._Up_arrive_keep_time = 0; // } // else // { // last_temp_1_1 = g_work.temp_out_1_1; // } // g_work.m_time._Up_arrive_keep_time = 0; // } // // duty(0,1,pid.currpwm ); // break; // case 3: // pid.set = 230; // // duty(1,1,0); // pid.curr = g_work.temp_out_1; // pid_calc(); // if( g_work.temp_out_1 == 230 || g_work.temp_out_1 == 299 || g_work.temp_out_1 == 231) // { // g_work.up_keep_flag = 1; // } // else // { // // g_work.up_keep_flag = 0; // } // // if( g_work.m_time._Up_arrive_keep_time > 5000 ) // { // // if( last_temp_1_1 >= g_work.temp_out_1_1 - 2 && last_temp_1_1 <= g_work.temp_out_1_1 + 2 ) // { // get_TCR_230_1(); // g_work.up_test_chose = 4; // flash_wite(); // send_ack(0x57, 0xFE,1); // g_work.m_time._Up_arrive_keep_time = 0; // } // else // { // last_temp_1_1 = g_work.temp_out_1_1; // } // g_work.m_time._Up_arrive_keep_time = 0; // // } // // if( g_work.temp_out_1 > 231 ) // { // pid.currpwm = 0; // } // duty(0,1,pid.currpwm ); // break; // case 4: // if( g_work.m_time._Sleep_time % 500 == 0 ) // { // g_work.m_time._Up_arrive_keep_time = 0; // pid.currpwm = 0; // send_ack(0x57, 0xFE,1); // duty(0,1,0 ); // duty(1,1,0 ); // } // // break; // default: // break; // // } //} void adjuest_work() { static u16 last_temp = 0 ; static u16 power_times = 0; if( g_work.power == 0 ) { LED1_OFF(); LED2_OFF(); LED3_OFF(); g_work.work_conditon = STANDY; //printf("123"); // temp_control(0,0,1,0); // temp_control(0,0,0,0); if( g_work.m_time._Sleep_time < 500 ) { Beep_ON(); } else { Beep_OFF(); if(g_work.m_time._Sleep_time > 3000 ) { if( g_work.key_down == 0 ) { if( g_work.m_time._Sleep_time < 4000 ) { //printf("123"); V_Conditon(); } // OPEN_OFF(); g_work.err_fault = 0; g_work.down_H_one = 0; g_work.math_flag = 0; g_work.m_time._up_hot_time = 0; g_work.m_time._up_H_to_H_time = 0; // g_work.start_coll_flag = 0; } else { if(V_5_V == 1) { g_work.work_conditon = STANDY; g_work.power = 1; } } // V2_5V_OFF(); g_work.m_time._Sleep_time = 4000; } } } else { switch(g_work.work_conditon ) { case STANDY: g_work.down_H_one = 0; g_work.math_flag = 0; g_work.m_time._up_hot_time = 0; g_work.m_time._up_H_to_H_time = 0; // temp_control(0,0,1,0); // temp_control(0,0,0,0); g_work.up_start_temp = g_work.temp_2; if( g_work.Uart_match == 1 ) // 如果 是 串口通信 { if( g_work.m_time._Uart_match_time > 5000 ) { g_work.Uart_match = 0; } return; } if( g_work.m_time._Sleep_time > 2000 ) // 2S 后 关机 { have_key = 0;//g_work.key_down_times = 0; // 按键次数归零 if( g_work.key_down == 0 ) { g_work.m_time._Sleep_time = 0; } else { g_work.m_time._Sleep_time = 2500; } if(V_5_V == 0) // 没在充电直接关闭 { V_Conditon(); // OPEN_OFF(); WWDG_SetCounter(0x7e); DELAY_Ms(30); } else { g_work.m_time._Sleep_time = 0; } Beep_OFF(); } else { // V2_5V_ON(); // OPEN_ON(); if( g_work.m_time._Sleep_time > 500 ) // 解锁 蜂鸣器关闭 { if( g_work.m_conditon.m_conditon.lock == 0 ) { Beep_OFF(); } } } break; case ORDER_HOT: // g_work.temp_2 下端温度 1 下端控制 0 上段控制 if( g_work.m_time._Sleep_time < 500 ) { Beep_ON(); } else { Beep_OFF(); } if( g_work.Uart_match == 5 ) { // duty(1,1,0); if( g_work.temp_1 < g_work.chontrol_temp ) { // duty(0,1,100); } else { // duty(0,1,0); } } else { Temp_control_TCR();//temp_chotrol(); } if( g_work.temp_2 >= g_work.chontrol_temp && g_work.temp_1 >= g_work.chontrol_temp ) { g_work.m_time._Sleep_time = 0 ; g_work.work_conditon = HOT_1; // send_ack(0x57,0xFE,2); } break; case HOT_1: if( g_work.m_time._Sleep_time < 500 ) { Beep_ON(); } else { Beep_OFF(); } if( g_work.m_time._Sleep_time > 10000) { if ( g_work.chontrol_temp == 210) { if( g_work.temp_out_2 >= 207 && g_work.temp_out_2 < 213 ) { g_work.up_arrive_flag = 1; if( g_work.m_time._Up_arrive_time > 5000 ) { send_ack(0x67, 0xFE,1); } } else { g_work.up_arrive_flag = 0; } } } if( g_work.Uart_match == 5 ) { // duty(1,1,0); if( g_work.temp_1 < g_work.chontrol_temp ) { // duty(0,1,60); } else { // duty(0,1,0); } } else { Temp_control_TCR();//temp_chotrol(); } break; case HOT_2: break; case HOT_3: break; case FINISH: break; } } } void adjuest_work_1() { static u16 last_temp = 0 ; static u16 power_times = 0; if( g_work.power == 0 ) { LED1_OFF(); LED2_OFF(); LED3_OFF(); g_work.work_conditon = STANDY; //printf("123"); // temp_control(0,0,1,0); // temp_control(0,0,0,0); if( g_work.m_time._Sleep_time < 500 ) { Beep_ON(); } else { Beep_OFF(); if(g_work.m_time._Sleep_time > 3000 ) { if( g_work.key_down == 0 ) { if( g_work.m_time._Sleep_time < 4000 ) { //printf("123"); V_Conditon(); } // OPEN_OFF(); g_work.err_fault = 0; g_work.down_H_one = 0; g_work.math_flag = 0; g_work.m_time._up_hot_time = 0; g_work.m_time._up_H_to_H_time = 0; // g_work.start_coll_flag = 0; } else { if(V_5_V == 1) { g_work.work_conditon = STANDY; g_work.power = 1; } } // V2_5V_OFF(); g_work.m_time._Sleep_time = 4000; } } } else { switch(g_work.work_conditon ) { case STANDY: g_work.down_H_one = 0; g_work.math_flag = 0; g_work.m_time._up_hot_time = 0; g_work.m_time._up_H_to_H_time = 0; // temp_control(0,0,1,0); // temp_control(0,0,0,0); g_work.up_start_temp = g_work.temp_2; if( g_work.Uart_match == 1 ) // 如果 是 串口通信 { if( g_work.m_time._Uart_match_time > 5000 ) { g_work.Uart_match = 0; } return; } if( g_work.m_time._Sleep_time > 2000 ) // 2S 后 关机 { have_key = 0;//g_work.key_down_times = 0; // 按键次数归零 if( g_work.key_down == 0 ) { g_work.m_time._Sleep_time = 0; } else { g_work.m_time._Sleep_time = 2500; } if(V_5_V == 0) // 没在充电直接关闭 { V_Conditon(); // OPEN_OFF(); WWDG_SetCounter(0x7e); DELAY_Ms(30); } else { g_work.m_time._Sleep_time = 0; } Beep_OFF(); } else { // V2_5V_ON(); // OPEN_ON(); if( g_work.m_time._Sleep_time > 500 ) // 解锁 蜂鸣器关闭 { if( g_work.m_conditon.m_conditon.lock == 0 ) { Beep_OFF(); } } } break; case ORDER_HOT: // g_work.temp_2 下端温度 1 下端控制 0 上段控制 if( g_work.m_time._Sleep_time < 500 ) { Beep_ON(); } else { Beep_OFF(); } if( g_work.Uart_match == 6 ) { // duty(0,1,0); if( g_work.temp_2 < g_work.chontrol_temp ) { // duty(1,1,80); } else { // duty(1,1,0); } } else { temp_control_1(); } if( g_work.temp_2 >= g_work.chontrol_temp ) { g_work.m_time._Sleep_time = 0 ; g_work.work_conditon = HOT_1; //send_ack(0x57,0xFE,2); } break; case HOT_1: if( g_work.m_time._Sleep_time < 500 ) { Beep_ON(); } else { Beep_OFF(); } if( g_work.m_time._Sleep_time > 10000) { if ( g_work.chontrol_temp == 210) { if( g_work.temp_out_2 >= 207 && g_work.temp_out_2 < 213 ) { g_work.up_arrive_flag = 1; if( g_work.m_time._Up_arrive_time > 5000 ) { send_ack(0x67, 0xFE,1); } } else { g_work.up_arrive_flag = 0; } } } if( g_work.Uart_match == 6 ) { // duty(0,1,0); if( g_work.temp_2 < g_work.chontrol_temp ) { // duty(1,1,60); } else { // duty(1,1,0); } } else { temp_control_1(); } break; case HOT_2: break; case HOT_3: break; case FINISH: break; } } } void adjuest_work_2() { if( g_work.power == 0 ) { LED1_OFF(); LED2_OFF(); LED3_OFF(); g_work.work_conditon = STANDY; //printf("123"); // temp_control(0,0,1,0); // temp_control(0,0,0,0); if( g_work.m_time._Sleep_time < 500 ) { Beep_ON(); } else { Beep_OFF(); if(g_work.m_time._Sleep_time > 3000 ) { if( g_work.key_down == 0 ) { if( g_work.m_time._Sleep_time < 4000 ) { //printf("123"); V_Conditon(); } // OPEN_OFF(); g_work.err_fault = 0; g_work.down_H_one = 0; g_work.math_flag = 0; g_work.m_time._up_hot_time = 0; g_work.m_time._up_H_to_H_time = 0; // g_work.start_coll_flag = 0; } else { if(V_5_V == 1) { g_work.work_conditon = STANDY; g_work.power = 1; } } // V2_5V_OFF(); g_work.m_time._Sleep_time = 4000; } } } else { switch(g_work.work_conditon ) { case STANDY: g_work.down_H_one = 0; g_work.math_flag = 0; g_work.m_time._up_hot_time = 0; g_work.m_time._up_H_to_H_time = 0; g_work.up_start_temp = g_work.temp_2; if( g_work.Uart_match == 1 ) // 如果 是 串口通信 { if( g_work.m_time._Uart_match_time > 5000 ) { g_work.Uart_match = 0; } return; } if( g_work.m_time._Sleep_time > 2000 ) // 2S 后 关机 { have_key = 0;//g_work.key_down_times = 0; // 按键次数归零 if( g_work.key_down == 0 ) { g_work.m_time._Sleep_time = 0; } else { g_work.m_time._Sleep_time = 2500; } if(V_5_V == 0) // 没在充电直接关闭 { V_Conditon(); // OPEN_OFF(); WWDG_SetCounter(0x7e); DELAY_Ms(30); } else { g_work.m_time._Sleep_time = 0; } Beep_OFF(); } else { // V2_5V_ON(); // OPEN_ON(); if( g_work.m_time._Sleep_time > 500 ) // 解锁 蜂鸣器关闭 { if( g_work.m_conditon.m_conditon.lock == 0 ) { Beep_OFF(); } } } break; case ORDER_HOT: // g_work.temp_2 下端温度 1 下端控制 0 上段控制 break; case HOT_1: break; } } }