周六日测试

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

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

@ -515,7 +515,7 @@ void RS485_1_Upload_Params(void)
/**
* 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 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_3_Send_Data_1(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_Receive_Data(u8 *buf,u8 *len);
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;
if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) // 接收中断

File diff suppressed because one or more lines are too long

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

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

@ -195,6 +195,7 @@ void start_task(void *pvParameters)
(void *)NULL,
(UBaseType_t)tskIDLE_PRIORITY + 3,
(TaskHandle_t* )&SyncEnvironmentDataRequestTask_Handler);
xTaskCreate(
(TaskFunction_t)HotTestRequestTask,
(const char *)"HotTestRequestTask",
@ -226,7 +227,7 @@ void SensorDataRequestTask(void *pvParameters) {
void SyncEnvironmentDataRequestTask(void *pvParameters) {
while (1) {
RS485_1_Send_Data_3();
RS485_1_sync_env_params();
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)
{
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);
// cnt_flag=do_mqtt(MQTT_SOCK,NET_CONFIG.rip,1883,5500);
@ -317,7 +305,6 @@ void Sensor_Communication_task(void *pvParameters)
{
// batch update params in a stage
// total length: 18
// if (CRC16_check(RS485_RX_BUF_COPY, 16) == 1) {
Batch_synchronization(&n, RS485_RX_BUF_COPY);
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);
@ -325,30 +312,25 @@ void Sensor_Communication_task(void *pvParameters)
RS485_DATA_TMP[19] = 0xFC;
RS485_DATA_TMP[20] = 0xFF;
RS485_DATA_TMP[21] = 0xFF;
// bufcut_Init(RS485_DATA_TMP + 8, RS485_SUFFIX, 18, 22);
RS485_1_Send_Data_1(RS485_DATA_TMP, 22);
// }
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)
{
// update single environment param
// total length: 9
// if (CRC16_check(RS485_RX_BUF_COPY, 7) == 1) {
Analysis(&n, &i, RS485_RX_BUF_COPY);
Array(&now_stage, &hour, &min, &tem, &hum, &red, &blue, &white); // update param correspond to current stage
Write_Init();
bufcut_Init(RS485_DATA_TMP, RS485_RX_BUF_COPY, 0, 9);
bufcut_Init(RS485_DATA_TMP + 8, RS485_SUFFIX, 9, 13);
RS485_1_Send_Data_1(RS485_DATA_TMP, 13);
// }
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)
{
// change running stage
// total length: 6
// if (CRC16_check(RS485_RX_BUF_COPY, 4) == 1) {
int target_stage = RS485_RX_BUF_COPY[3];
RTC_synchronization_ins(2023, 9, 1, 0, 00, 00);
now_stage = target_stage;
@ -359,7 +341,6 @@ void Sensor_Communication_task(void *pvParameters)
RS485_1_Send_Data_1(RS485_DATA_TMP, 10);
// delay_ms(10);
RS485_1_Upload_Params(); // ÉÏ´«²ÎÊý
// }
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)
@ -402,7 +383,6 @@ void Sensor_Communication_task(void *pvParameters)
}
Write_Init();
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[9] = 0xFC;
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)
{
// 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]);
RX_BUF_Transfer(0, 14);
}
@ -489,21 +468,6 @@ void process_inner_sensor_data(u8 *data) {
gpio_state &= 0xFE;
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.now_tem = T / 10.0;

Loading…
Cancel
Save