Browse Source

直流DC带记忆功能

liyi 1 year ago
parent
commit
815c3100d1

+ 1 - 1
control/PDU-DC_UPGRADE/App/ADC/ADC.c

@@ -223,7 +223,7 @@ uint32_t DC_I_calfunction(uint16_t da,uint8_t channel)
 				temp_i /= 10;//去掉第3位小数
 				temp_i *= 10;
 				//temp_i += 70;
-				if(temp_i <= 80)
+				if(temp_i <= 200)
 							temp_i = 0;
 			}
 		}

+ 108 - 3
control/PDU-DC_UPGRADE/App/Main/Main.c

@@ -115,6 +115,7 @@ uint8_t RL_Now_state[RELAY_ChN_default] = {0};
 
 
 
+
 uint16_t Devid_IDChalNum = 0;//É豸ÀàÐͺÍͨµÀÊý
 
 
@@ -145,6 +146,20 @@ META_DATA_S meta_data 		= {0};
 information_t infomation;
 
 
+void switch_recode();
+
+#if SUPPORT_SWITCH_REMENBER
+	uint8_t handle_status[RELAY_ChN_default] = {0};
+	uint8_t handle_detection[2] = {1,1};
+	uint32_t input_1_ms_count = 0;
+	uint32_t input_2_ms_count = 0;
+			
+	uint8_t  input_1_en = 0;
+	uint8_t  input_2_en = 0;
+
+#endif
+
+
 
 
 extern bool Rx_Finish_flag; 
@@ -646,7 +661,78 @@ static void fault_all_state_process(void)
 		}
 	}
 }
-
+void switch_recode()
+{
+#if SUPPORT_SWITCH_REMENBER
+	if((detection_value & 1) == 0)
+	{
+		if(handle_detection[0] == 1)
+		{
+			handle_detection[0] = 0;
+			for(int i = 0;i < RELAY_ChN_default;i++)
+			{
+				handle_status[i] = (DCPDU_Modbus_Reg[Mb_Dbuff_RL_ST_Addr] >> i) & 0x1;
+				uint8_t data = DCPDU_Modbus_Reg[Mb_Dbuff_RL_ST_Addr];
+				data &= 0x00;
+				RL_Rx_state = data;
+			}
+		}
+	}else
+	{
+		if(handle_detection[0] == 0)
+		{
+			handle_detection[0] = 1;
+			uint8_t value = 0xFF;
+			for(int i = RELAY_ChN_default-1;i >=0;i--)
+			{
+				if(handle_status[i])
+				{
+					value |= (1 << i);
+				}else
+				{
+					value &= (~(1 << i));
+				}
+			}
+			RL_Rx_state = value & Active_state_bit;
+			RL_Allon_flag = true;
+		}
+	}
+//	if((detection_value & 2) == 0)
+//	{
+//		if(handle_detection[1] == 1)
+//		{
+//			handle_detection[1] = 0;
+//			for(int i = PT_SUB_COUNT;i < RELAY_ChN_default;i++)
+//			{
+//				handle_status[i] = (DCPDU_Modbus_Reg[Mb_Dbuff_RL_ST_Addr] >> i) & 0x1;
+//				uint8_t data = DCPDU_Modbus_Reg[Mb_Dbuff_RL_ST_Addr];
+//				data &= 0x0F;
+//				RL_Rx_state = data;
+//			}
+//		}
+//	}else
+//	{
+//		if(handle_detection[1] == 0)
+//		{
+//			handle_detection[1] = 1;
+//			uint8_t _data = DCPDU_Modbus_Reg[Mb_Dbuff_RL_ST_Addr];
+//			_data |= 0XF0;
+//			for(int i= PT_SUB_COUNT; i < PT_SUB_COUNT;i++)
+//			{
+//				if(handle_status[i])
+//				{
+//					_data &= (1 << i);
+//				}else
+//				{
+//					_data &= (0 << i);
+//				}
+//			}
+//			RL_Rx_state = _data;
+//			RL_Allon_flag = true;			
+//		}		
+//	}
+#endif
+}
 
 
 /*********************************************************************************************************
@@ -712,7 +798,7 @@ int main(void)
 	Init_Dev_parameter();
 	
 	RL_Rx_state = Eeprom_Rbuf[ERom_RL_ST_Addr]& Active_state_bit;
-	RL_Allon_flag = true;
+	//RL_Allon_flag = true;
 	
 	Eeprom_Rbuf[ERom_RL_ST_Addr]= 0 ;
 	DCPDU_Modbus_Reg[Mb_Dbuff_RL_ST_Addr]=0;
@@ -736,12 +822,30 @@ int main(void)
 #if SUPPORT_EIGHT_LIGHT
 	Relayx_Onoff_state(7,RELAY_ON);
 #endif
+#if SUPPORT_SWITCH_REMENBER
+	if((detection_value & 0x1) == 0)
+	{
+		if(handle_detection[0] == 1)
+		{
+			handle_detection[0] = 0;
+			for(int i = 0;i < RELAY_ChN_default;i++)
+			{
+				handle_status[i] = (RL_Rx_state>>i) & 0x1;
+				uint8_t data = DCPDU_Modbus_Reg[Mb_Dbuff_RL_ST_Addr];
+				data = 0x00;
+				RL_Rx_state = data;
+			}			
+		}
+	}
+#endif
+	//switch_recode();
+	RL_Allon_flag = true;
 
 static  uint8_t write_iic_flash = 0;
 	while(1)
 	{
 		
-#if SUPPORT_DETECTION
+#if 0
 		if((detection_value & 0x2) == 0)
 		{
 //			for(int i = 0; i <RELAY_ChN_default / 2;i++)
@@ -1050,6 +1154,7 @@ static  uint8_t write_iic_flash = 0;
 #if SURPPOT_ALL_ON_ALL_OFF
 		key_io_control();
 #endif
+		switch_recode();
 	}
 }
 

+ 6 - 4
control/PDU-DC_UPGRADE/App/Main/board_cnf.h

@@ -11,8 +11,8 @@
 #define                 PRJ_ADC_V_DC_7_1                          0
 #define                 PRJ_ADC_V_DC_4_4                          0
 #define                 PRJ_ADC_V_DC_NEW_8                        0
-#define                 PRJ_ADC_V_DC_NEW_7                        0
-#define                 PRJ_ADC_V_DC_NEW_6                        1
+#define                 PRJ_ADC_V_DC_NEW_7                        1
+#define                 PRJ_ADC_V_DC_NEW_6                        0
 #if   PRJ_BASE_DC_8
 	#define RELAY_ChN_default             		8
 	#define SUPPORT_IM1253E										1
@@ -43,13 +43,15 @@
 #elif    PRJ_ADC_V_DC_NEW_7
 	#define RELAY_ChN_default             		7
 	#define SURPPOT_ALL_ON_ALL_OFF          	1
-	#define SUPPORT_DETECTION               	1
+	#define SUPPORT_DETECTION               	0
 	#define SUPPORT_STM32_ADC                 1
+	#define SUPPORT_SWITCH_REMENBER           0
 #elif    PRJ_ADC_V_DC_NEW_6
 	#define RELAY_ChN_default             		6
 	#define SURPPOT_ALL_ON_ALL_OFF          	1
-	#define SUPPORT_DETECTION               	1
+	#define SUPPORT_DETECTION               	0
 	#define SUPPORT_STM32_ADC                 1
+	#define SUPPORT_SWITCH_REMENBER           0
 #endif