周六日测试

check
Zeng wei (曾威) 2 years ago
parent a61b9dfd5f
commit 2e1fab80a6

@ -42,7 +42,7 @@ void PID_Init()
pid.hd_l = 0; pid.hd_l = 0;
pid.h_base_l = 53; pid.h_base_l = 53;
pid.cp = 4.8; pid.cp = 3.6;
pid.ci = 0; pid.ci = 0;
pid.cd = 0; pid.cd = 0;
pid.c_base = 37; pid.c_base = 37;

@ -515,7 +515,7 @@ void RS485_1_Upload_Params(void)
/** /**
* sync environment params * sync environment params
*/ */
void RS485_1_Send_Data_3(void) void RS485_1_sync_env_params(void)
{ {
u8 batchbuf[10] = {0xEE, 0xB5, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFF}; u8 batchbuf[10] = {0xEE, 0xB5, 0x01, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFF};
u8 t; u8 t;

@ -22,7 +22,7 @@ void RS485_1_Send_Data(u8 *buf,u8 len);
void RS485_1_Send_Data_1(u8 *buf,u8 len); void RS485_1_Send_Data_1(u8 *buf,u8 len);
//void RS485_3_Send_Data_1(void); //void RS485_3_Send_Data_1(void);
void RS485_1_Upload_Params(void); void RS485_1_Upload_Params(void);
void RS485_1_Send_Data_3(void); void RS485_1_sync_env_params(void);
void RS485_3_Send_Data(u8 *buf,u8 len); void RS485_3_Send_Data(u8 *buf,u8 len);
void RS485_Receive_Data(u8 *buf,u8 *len); void RS485_Receive_Data(u8 *buf,u8 *len);
void SN74CB3Q3253_Init(void); void SN74CB3Q3253_Init(void);

@ -138,7 +138,7 @@ void USART2_Init(u32 bound)
* : * :
* : * :
*******************************************************************************/ *******************************************************************************/
void USART2_IRQHandler(void) // 串口1中断服务程序 void USART2_IRQHandler(void) // 串口2中断服务程序
{ {
u8 r; u8 r;
if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) // 接收中断 if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) // 接收中断

File diff suppressed because one or more lines are too long

@ -692,7 +692,7 @@
<Group> <Group>
<GroupName>DNS</GroupName> <GroupName>DNS</GroupName>
<tvExp>1</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>

@ -9,8 +9,8 @@ extern u8 gpio_state;
// int c_value=20; // int c_value=20;
int main(void) int main(void)
{ {
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); // FreeRTOS推荐使用 中断优先级分组4
SysTick_Init(72); SysTick_Init(72);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); // FreeRTOS推荐使用 中断优先级分组4
USART2_Init(2400); USART2_Init(2400);
PID_Init(); PID_Init();
// printf("复位\r\n"); // printf("复位\r\n");

@ -195,6 +195,7 @@ void start_task(void *pvParameters)
(void *)NULL, (void *)NULL,
(UBaseType_t)tskIDLE_PRIORITY + 3, (UBaseType_t)tskIDLE_PRIORITY + 3,
(TaskHandle_t* )&SyncEnvironmentDataRequestTask_Handler); (TaskHandle_t* )&SyncEnvironmentDataRequestTask_Handler);
xTaskCreate( xTaskCreate(
(TaskFunction_t)HotTestRequestTask, (TaskFunction_t)HotTestRequestTask,
(const char *)"HotTestRequestTask", (const char *)"HotTestRequestTask",
@ -226,7 +227,7 @@ void SensorDataRequestTask(void *pvParameters) {
void SyncEnvironmentDataRequestTask(void *pvParameters) { void SyncEnvironmentDataRequestTask(void *pvParameters) {
while (1) { while (1) {
RS485_1_Send_Data_3(); RS485_1_sync_env_params();
vTaskDelay(SYNC_ENVIRONMENT_DATA_REQUEST_PERIOD); vTaskDelay(SYNC_ENVIRONMENT_DATA_REQUEST_PERIOD);
} }
@ -245,24 +246,11 @@ void HotTestRequestTask(void *pvParameters) {
} }
} }
u8 temp[4] = {0xaa,0xbb,0xcc,0xdd};
u8 times = 0;
void Sensor_Communication_task(void *pvParameters) void Sensor_Communication_task(void *pvParameters)
{ {
while (1) while (1)
{ {
// RS485_3_Init(9600);
// // temp[2] = (int)pid.Ki / 256;
// // temp[3] = (int)pid.Ki % 256;
// temp[2] = 4800 / 256;
// temp[3] = 4800 % 256;
// RS485_3_Send_Data(temp, 4);
// // RS485_1_Send_Data(temp_data, 8);
// delay_xms(30);
// RS485_1_Init(9600);
// RS485_1_Send_Data(temp, 4);
// HC595_Send_Byte(0x00); // HC595_Send_Byte(0x00);
// cnt_flag=do_mqtt(MQTT_SOCK,NET_CONFIG.rip,1883,5500); // cnt_flag=do_mqtt(MQTT_SOCK,NET_CONFIG.rip,1883,5500);
@ -317,49 +305,42 @@ void Sensor_Communication_task(void *pvParameters)
{ {
// batch update params in a stage // batch update params in a stage
// total length: 18 // total length: 18
// if (CRC16_check(RS485_RX_BUF_COPY, 16) == 1) { Batch_synchronization(&n, RS485_RX_BUF_COPY);
Batch_synchronization(&n, RS485_RX_BUF_COPY); Array(&now_stage, &hour, &min, &tem, &hum, &red, &blue, &white); // update param correspond to current stage
Array(&now_stage, &hour, &min, &tem, &hum, &red, &blue, &white); // update param correspond to current stage bufcut_Init(RS485_DATA_TMP, RS485_RX_BUF_COPY, 0, 18);
bufcut_Init(RS485_DATA_TMP, RS485_RX_BUF_COPY, 0, 18); RS485_DATA_TMP[18] = 0xFF;
RS485_DATA_TMP[18] = 0xFF; RS485_DATA_TMP[19] = 0xFC;
RS485_DATA_TMP[19] = 0xFC; RS485_DATA_TMP[20] = 0xFF;
RS485_DATA_TMP[20] = 0xFF; RS485_DATA_TMP[21] = 0xFF;
RS485_DATA_TMP[21] = 0xFF; RS485_1_Send_Data_1(RS485_DATA_TMP, 22);
// bufcut_Init(RS485_DATA_TMP + 8, RS485_SUFFIX, 18, 22);
RS485_1_Send_Data_1(RS485_DATA_TMP, 22);
// }
RX_BUF_Transfer(0, 18); RX_BUF_Transfer(0, 18);
} }
else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB6 && RS485_RX_BUF_COPY[2] == 0x03 && CRC16_check(RS485_RX_BUF_COPY, 7) == 1) else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB6 && RS485_RX_BUF_COPY[2] == 0x03 && CRC16_check(RS485_RX_BUF_COPY, 7) == 1)
{ {
// update single environment param // update single environment param
// total length: 9 // total length: 9
// if (CRC16_check(RS485_RX_BUF_COPY, 7) == 1) { Analysis(&n, &i, RS485_RX_BUF_COPY);
Analysis(&n, &i, RS485_RX_BUF_COPY); Array(&now_stage, &hour, &min, &tem, &hum, &red, &blue, &white); // update param correspond to current stage
Array(&now_stage, &hour, &min, &tem, &hum, &red, &blue, &white); // update param correspond to current stage Write_Init();
Write_Init(); bufcut_Init(RS485_DATA_TMP, RS485_RX_BUF_COPY, 0, 9);
bufcut_Init(RS485_DATA_TMP, RS485_RX_BUF_COPY, 0, 9); bufcut_Init(RS485_DATA_TMP + 8, RS485_SUFFIX, 9, 13);
bufcut_Init(RS485_DATA_TMP + 8, RS485_SUFFIX, 9, 13); RS485_1_Send_Data_1(RS485_DATA_TMP, 13);
RS485_1_Send_Data_1(RS485_DATA_TMP, 13);
// }
RX_BUF_Transfer(0, 9); RX_BUF_Transfer(0, 9);
} }
else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB6 && RS485_RX_BUF_COPY[2] == 0x04 && CRC16_check(RS485_RX_BUF_COPY, 4) == 1) else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB6 && RS485_RX_BUF_COPY[2] == 0x04 && CRC16_check(RS485_RX_BUF_COPY, 4) == 1)
{ {
// change running stage // change running stage
// total length: 6 // total length: 6
// if (CRC16_check(RS485_RX_BUF_COPY, 4) == 1) { int target_stage = RS485_RX_BUF_COPY[3];
int target_stage = RS485_RX_BUF_COPY[3]; RTC_synchronization_ins(2023, 9, 1, 0, 00, 00);
RTC_synchronization_ins(2023, 9, 1, 0, 00, 00); now_stage = target_stage;
now_stage = target_stage; store_stage = target_stage;
store_stage = target_stage; Write_Init();
Write_Init(); bufcut_Init(RS485_DATA_TMP, RS485_RX_BUF_COPY, 0, 6);
bufcut_Init(RS485_DATA_TMP, RS485_RX_BUF_COPY, 0, 6); bufcut_Init(RS485_DATA_TMP + 8, RS485_SUFFIX, 6, 10);
bufcut_Init(RS485_DATA_TMP + 8, RS485_SUFFIX, 6, 10); RS485_1_Send_Data_1(RS485_DATA_TMP, 10);
RS485_1_Send_Data_1(RS485_DATA_TMP, 10); // delay_ms(10);
// delay_ms(10); RS485_1_Upload_Params(); // ÉÏ´«²ÎÊý
RS485_1_Upload_Params(); // 上传参数
// }
RX_BUF_Transfer(0, 6); RX_BUF_Transfer(0, 6);
} }
else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB6 && RS485_RX_BUF_COPY[2] == 0x05) else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB6 && RS485_RX_BUF_COPY[2] == 0x05)
@ -402,7 +383,6 @@ void Sensor_Communication_task(void *pvParameters)
} }
Write_Init(); Write_Init();
bufcut_Init(RS485_DATA_TMP, RS485_RX_BUF_COPY, 0, 8); bufcut_Init(RS485_DATA_TMP, RS485_RX_BUF_COPY, 0, 8);
// bufcut_Init(RS485_DATA_TMP + 8, RS485_SUFFIX, 8, 12);
RS485_DATA_TMP[8] = 0xFF; RS485_DATA_TMP[8] = 0xFF;
RS485_DATA_TMP[9] = 0xFC; RS485_DATA_TMP[9] = 0xFC;
RS485_DATA_TMP[10] = 0xFF; RS485_DATA_TMP[10] = 0xFF;
@ -420,7 +400,6 @@ void Sensor_Communication_task(void *pvParameters)
} }
else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB1 && RS485_RX_BUF_COPY[2] == 0x11 && RS485_RX_BUF_COPY[12] == 0xFF && RS485_RX_BUF[13] == 0xFF) else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB1 && RS485_RX_BUF_COPY[2] == 0x11 && RS485_RX_BUF_COPY[12] == 0xFF && RS485_RX_BUF[13] == 0xFF)
{ {
// btn down or up
process_hmi_btn_event(RS485_RX_BUF_COPY[3] * 256 + RS485_RX_BUF_COPY[4], RS485_RX_BUF_COPY[5] * 256 + RS485_RX_BUF_COPY[6], RS485_RX_BUF_COPY[9]); process_hmi_btn_event(RS485_RX_BUF_COPY[3] * 256 + RS485_RX_BUF_COPY[4], RS485_RX_BUF_COPY[5] * 256 + RS485_RX_BUF_COPY[6], RS485_RX_BUF_COPY[9]);
RX_BUF_Transfer(0, 14); RX_BUF_Transfer(0, 14);
} }
@ -489,21 +468,6 @@ void process_inner_sensor_data(u8 *data) {
gpio_state &= 0xFE; gpio_state &= 0xFE;
ALARM = 0; ALARM = 0;
} }
// if (T < 800 && T > -400)
// {
// diff = current_T - T;
// if (diff < 0)
// diff = -diff;
// // if (diff < 100 || current_T == 0) // 最近两次温差相差10℃,消除传感器感应出错的影响
// // {
// pid.set_tem = tem / 10.0;
// pid.now_tem = T / 10.0;
// PID_Calc();
// // send sign to 485
// // out: 0-200
// current_T = T;
// // }
// }
pid.set_tem = tem / 10.0; pid.set_tem = tem / 10.0;
pid.now_tem = T / 10.0; pid.now_tem = T / 10.0;

Loading…
Cancel
Save