From 20ef2d42f15f2763a5079929fc7c375e9c94b697 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期六, 09 十一月 2019 14:16:39 +0800 Subject: [PATCH] V1.5 修改数据溢出bug --- 源码/核心板/Src/application/dw_app.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c" "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c" index 83dcf89..58345cd 100644 --- "a/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c" +++ "b/\346\272\220\347\240\201/\346\240\270\345\277\203\346\235\277/Src/application/dw_app.c" @@ -134,7 +134,7 @@ static double tof; -uint32_t anchor_dist_last_frm[TAG_NUM_IN_SYS],his_dist[TAG_NUM_IN_SYS]; ; +int32_t anchor_dist_last_frm[TAG_NUM_IN_SYS],his_dist[TAG_NUM_IN_SYS]; ; uint32_t tag_id = 0; uint32_t tag_id_recv = 0; uint8_t random_delay_tim = 0; @@ -318,6 +318,7 @@ int8_t tag_delaytime; extern uint16_t sync_timer; u16 tmp_time; +int32_t temp_dist; void Tag_App(void)//发送模式(TAG标签) { uint32_t frame_len; @@ -337,7 +338,7 @@ for(i=0;i<g_com_map[MAX_REPORT_ANC_NUM];i++) { /* Write frame data to DW1000 and prepare transmission. See NOTE 7 below. */ - tx_poll_msg[ANC_TYPE_IDX] = i-1; + tx_poll_msg[ANC_TYPE_IDX] = i; dwt_writetxdata(sizeof(tx_poll_msg), tx_poll_msg, 0);//将Poll包数据传给DW1000,将在开启发送时传出去 dwt_writetxfctrl(sizeof(tx_poll_msg), 0);//设置超宽带发送数据长度 @@ -418,14 +419,21 @@ tag_succ_times++; LED0_BLINK; - +// temp_dist=anchor_dist_last_frm[0]; +// if(anchor_dist_last_frm[0]>1000000) +// { +// temp_dist=anchor_dist_last_frm[0]-0xffffffff; +// temp_dist+=0xffff; +// anchor_dist_last_frm[0]=temp_dist; +// } + usart_send[2] = 1;//正常模式 usart_send[3] = 17;//数据段长度 usart_send[4] = frame_seq_nb;//数据段长度 memcpy(&usart_send[5],&dev_id,2); memcpy(&usart_send[7],&rx_buffer[ANCHOR_ID_IDX],2); - hex_dist = anchor_dist_last_frm[0];; + hex_dist = anchor_dist_last_frm[0]+(int16_t)g_com_map[DIST_OFFSET]; memcpy(&usart_send[9],&hex_dist,4); usart_send[13] = battary; usart_send[14] = button; @@ -602,10 +610,12 @@ // dist[TAG_ID] = LP(dis, TAG_ID); //LP 为低通滤波器,让数据更稳定 /*--------------------------以下为非测距逻辑------------------------*/ + //dist_cm=33000; + LED0_BLINK; //每成功一次通讯则闪烁一次 g_UWB_com_interval = 0; dis_after_filter=dist_cm; - hex_dist = (int16_t)(dist_cm+g_com_map[DIST_OFFSET]); + hex_dist = dist_cm+(int16_t)g_com_map[DIST_OFFSET]; if(tag_id_recv-TAG_ID_START<=TAG_NUM_IN_SYS) if(abs(hex_dist-his_dist[tag_id_recv-TAG_ID_START])<1000) { -- Gitblit v1.9.3