From 9f117ad80a25735b7ee4e54c2fdc375a828a899c Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期二, 15 六月 2021 10:52:57 +0800 Subject: [PATCH] 增加信号轻度,去掉滤波 --- 源码/核心板/Src/application/dw_app.c | 71 ++++++++++++++++++++++++++--------- 1 files changed, 52 insertions(+), 19 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 767770f..a03c04c 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" @@ -1,6 +1,6 @@ #include "dw_app.h" #include "ADC.h" -#define TDFILTER +//#define TDFILTER enum enumtagstate { DISCPOLL, @@ -115,6 +115,14 @@ } } } +void SetNLOSNTMSettings(void) +{ + uint8_t temp; + temp = 7; + dwt_writetodevice(LDE_IF_ID,LDE_CFG1_OFFSET,1,&temp); + dwt_write16bitoffsetreg(LDE_IF_ID,LDE_CFG2_OFFSET,3); + // NTM = dwt_read32bitoffsetreg(LDE_IF_ID,LDE_CFG1_OFFSET) & LDE_CFG1_NSTDEV_MASK; +} void Dw1000_Init(void) { /* Reset and initialise DW1000. @@ -127,7 +135,7 @@ /* Configure DW1000. See NOTE 6 below. */ dwt_configure(&config);//配置DW1000 - + // SetNLOSNTMSettings(); /* Apply default antenna delay value. See NOTE 1 below. */ dwt_setrxantennadelay(RX_ANT_DLY); //设置接收天线延迟 @@ -449,6 +457,7 @@ memcpy(&rec_tagpos_binary,&rx_buffer[NEARMSG_EMPTYSLOTPOS_INDEX],4); if(temp_dist!=0x1ffff) { + g_Resttimer=0; #ifndef USART_INTEGRATE_OUTPUT usart_send[2] = 1;//正常模式 usart_send[3] = 17;//数据段长度 @@ -695,12 +704,30 @@ UART_PushFrame(usart_send,6+report_num*6); #endif } + double firstpath_power, rx_power,rec_firstpath_power; + double f1, f2, r1, r2; +uint16_t F1,F2,F3,N,C; +double B = 131072; +double A = 121.74; +double min_power; + dwt_rxdiag_t d1; +double LOS(dwt_rxdiag_t *dia) { + F1 = dia->firstPathAmp1; + F2 = dia->firstPathAmp2; + F3 = dia->firstPathAmp3; + N = dia->rxPreamCount; + C = dia->maxGrowthCIR; + + firstpath_power=10* log10((F1*F1+F2*F2+F3*F3)/(N*N))-A; + rx_power=10*log10(C*B/(N*N))-A; + // min_power = - 10 * log10((F1 *F1 + F2 * F2 + F3 * F3) / (C *B)); + return min_power; + } void Tag_App(void)//发送模式(TAG标签) { //LED0_ON; dwt_forcetrxoff(); - g_Resttimer=0; GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_SET); switch(tag_state) { @@ -918,18 +945,22 @@ tof = tof_dtu * DWT_TIME_UNITS; distance = tof * SPEED_OF_LIGHT;//距离=光速*飞行时间 dist_no_bias = distance - dwt_getrangebias(config.chan, (float)distance, config.prf); //距离减去矫正系数 - dist_cm = dist_no_bias * 1000; //dis 为单位为cm的距离 + dist_cm = dist_no_bias * 1000; //dis 为单位为cm的距离 + + dwt_readdiagnostics(&d1); + LOS(&d1); /*--------------------------以下为非测距逻辑------------------------*/ //dist_cm=33000; getrange_success = 1; + g_Resttimer=0; LED0_BLINK; //每成功一次通讯则闪烁一次 dis_after_filter=dist_cm; - hex_dist = dist_cm+(int16_t)g_com_map[DIST_OFFSET]; + hex_dist = dist_cm+(int16_t)g_com_map[DIST_OFFSET]*10; g_flag_Taggetdist[taglist_pos]=0; - if(hex_dist>-10000&&hex_dist<2000000) - { - if(abs(hex_dist-his_dist[taglist_pos])<15000||misdist_num[taglist_pos]>3) - { + // if(hex_dist>0&&hex_dist<2000000) + //{ + //if(abs(hex_dist-his_dist[taglist_pos])<10000||misdist_num[taglist_pos]>3) + //{ int32_t filter_dist; #ifdef TDFILTER NewTrackingDiffUpdate(taglist_pos, (float)hex_dist); @@ -941,7 +972,7 @@ tagdist_list[taglist_pos] = filter_dist; his_dist[taglist_pos]=hex_dist; g_Tagdist[taglist_pos]=filter_dist; - #ifndef USART_INTEGRATE_OUTPUT + #ifndef USART_INTEGRATE_OUTPUT usart_send[2] = 1;//正常模式 usart_send[3] = 17;//数据段长度 usart_send[4] = frame_seq_nb2;//数据段长度 @@ -950,6 +981,8 @@ memcpy(&usart_send[9],&tagdist_list[taglist_pos],4); usart_send[13] = battary; usart_send[14] = button; + usart_send[15] = firstpath_power; + usart_send[16] = rx_power; checksum = Checksum_u16(&usart_send[2],17); memcpy(&usart_send[19],&checksum,2); UART_PushFrame(usart_send,21); @@ -958,11 +991,11 @@ memcpy(&usart_send_anc[6+6*anc_report_num],&tagdist_list[taglist_pos],4); anc_report_num++; #endif - }else{ - // printf("%d",hex_dist); - misdist_num[taglist_pos]++; - } - } +// }else{ +// // printf("%d",hex_dist); +// misdist_num[taglist_pos]++; +// } +// } } }else{ //printf("%x/n",status_reg); @@ -1009,8 +1042,7 @@ // if (anchor_type == rx_buffer[ANC_TYPE_IDX]) // Anchor_RecPoll(); // break; - case SYNC: - g_Resttimer=0; + case SYNC: memcpy(&rec_syncid,&rx_buffer[ANCHOR_ID_IDX],4); if(rec_syncid<current_syncid) { @@ -1051,9 +1083,10 @@ } break; - case NEAR_POLL: - g_Resttimer=0; + case NEAR_POLL: memcpy(&tag_id_recv,&rx_buffer[TAG_ID_IDX],2); + if(tag_id_recv>=g_com_map[WHITELIST1_START]&&tag_id_recv<=g_com_map[WHITELIST1_END]) + {break;} taglist_pos=CmpTagInList(tag_id_recv); if(taglist_pos==taglist_num) { -- Gitblit v1.9.3