From 07691209317d73ebe7b89bce522cd43fa4bcadc0 Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期五, 11 六月 2021 17:25:47 +0800
Subject: [PATCH] V1.47 增加NLOS模式

---
 源码/核心板/Src/application/dw_app.c |   41 +++++++++++++++++++++++++++++------------
 1 files changed, 29 insertions(+), 12 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 bbdefa4..5ab8cdc 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,5 +1,6 @@
 #include "dw_app.h"
 #include "ADC.h"
+//#define TDFILTER
 enum enumtagstate
 {
 	DISCPOLL,
@@ -114,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.
@@ -126,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);		//设置接收天线延迟
@@ -448,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;//数据段长度
@@ -699,7 +709,6 @@
 {
 	//LED0_ON;
 	dwt_forcetrxoff();
-	g_Resttimer=0;
 		GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_SET);	
 	switch(tag_state)
 	{
@@ -917,22 +926,30 @@
 					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 * 100; //dis 为单位为cm的距离				
+					dist_cm = dist_no_bias * 1000; //dis 为单位为cm的距离				
 					/*--------------------------以下为非测距逻辑------------------------*/
 					//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>-1000&&hex_dist<200000)
+					if(hex_dist>0&&hex_dist<2000000)
 					{
-					if(abs(hex_dist-his_dist[taglist_pos])<1500||misdist_num[taglist_pos]>3)
+					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);
+						filter_dist=pos_predict[taglist_pos]/10;
+						#else
+						filter_dist=hex_dist/10;
+						#endif
 						misdist_num[taglist_pos]=0;
-					tagdist_list[taglist_pos] = hex_dist;	
+					tagdist_list[taglist_pos] = filter_dist;	
 					his_dist[taglist_pos]=hex_dist;	
-						g_Tagdist[taglist_pos]=hex_dist;	
+						g_Tagdist[taglist_pos]=filter_dist;	
 				#ifndef USART_INTEGRATE_OUTPUT
 					usart_send[2] = 1;//正常模式 
 					usart_send[3] = 17;//数据段长度
@@ -1001,8 +1018,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)
 				{
@@ -1043,9 +1059,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