From e3dedf3cc3d29191937ba908d1cee233eb0adb2d Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期日, 06 九月 2020 14:31:51 +0800
Subject: [PATCH] 远距离110K代码测试完成

---
 源码/核心板/Src/application/dw_app.c |   56 ++++++++++++++++++++++++++++++--------------------------
 1 files changed, 30 insertions(+), 26 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 3d4a60d..9dc7c00 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"
@@ -46,16 +46,15 @@
 #define POLL_TX_TO_RESP_RX_DLY_UUS 150
 /* This is the delay from Frame RX timestamp to TX reply timestamp used for calculating/setting the DW1000's delayed TX function. This includes the
  * frame length of approximately 2.66 ms with above configuration. */
-#define RESP_RX_TO_FINAL_TX_DLY_UUS 400
+#define RESP_RX_TO_FINAL_TX_DLY_UUS 4100
 /* Receive response timeout. See NOTE 5 below. */
-#define RESP_RX_TIMEOUT_UUS 600
+#define RESP_RX_TIMEOUT_UUS 4700
 
-#define POLL_RX_TO_RESP_TX_DLY_UUS 420
+#define POLL_RX_TO_RESP_TX_DLY_UUS 3600
 /* This is the delay from the end of the frame transmission to the enable of the receiver, as programmed for the DW1000's wait for response feature. */
-#define RESP_TX_TO_FINAL_RX_DLY_UUS 200
+#define RESP_TX_TO_FINAL_RX_DLY_UUS 500
 /* Receive final timeout. See NOTE 5 below. */
 #define FINAL_RX_TIMEOUT_UUS 4300
-
 #define SPEED_OF_LIGHT 299702547
 
 /* Indexes to access some of the fields in the frames defined above. */
@@ -90,16 +89,16 @@
 /*------------------------------------ Variables ------------------------------------------*/
 /* Default communication configuration. We use here EVK1000's default mode (mode 3). */
 static dwt_config_t config = {
-	2,               /* Channel number. */
-	DWT_PRF_64M,     /* Pulse repetition frequency. */
-	DWT_PLEN_128,    /* Preamble length. */
-	DWT_PAC8,        /* Preamble acquisition chunk size. Used in RX only. */
-	9,               /* TX preamble code. Used in TX only. */
-	9,               /* RX preamble code. Used in RX only. */
-	1,               /* Use non-standard SFD (Boolean) */
-	DWT_BR_6M8,      /* Data rate. */
-	DWT_PHRMODE_STD, /* PHY header mode. */
-	(129 + 8 - 8)    /* SFD timeout (preamble length + 1 + SFD length - PAC size). Used in RX only. */
+    2,               /* Channel number. */
+    DWT_PRF_64M,     /* Pulse repetition frequency. */
+    DWT_PLEN_1024,   /* Preamble length. */
+    DWT_PAC32,       /* Preamble acquisition chunk size. Used in RX only. */
+    9,               /* TX preamble code. Used in TX only. */
+    9,               /* RX preamble code. Used in RX only. */
+    1,               /* Use non-standard SFD (Boolean) */
+    DWT_BR_110K,     /* Data rate. */
+    DWT_PHRMODE_STD, /* PHY header mode. */
+    (1025 + 64 - 32) /* SFD timeout (preamble length + 1 + SFD length - PAC size). Used in RX only. */
 };
 
 /* Frames used in the ranging process. See NOTE 2 below. */
@@ -237,12 +236,14 @@
 	if(clear_judge_cnt++>1000)  //设定1S分频,每秒进一次。判断标志位大于等于2,2s没收到数据就把数据变成0xffff,不触发警报。
 	{
 		clear_judge_cnt=0;
-		for(i=0;i<255;i++)
+		for(i=0;i<100;i++)
 		{
 			g_flag_Taggetdist[i]++;
 			if(g_flag_Taggetdist[i]>=2)
 			{
 				g_Tagdist[i]=0xffff;
+				Modbus_HoldReg[i*2]=1;
+				Modbus_HoldReg[i*2+1]=0xffff;
 			}
 		}
 	}
@@ -327,6 +328,7 @@
 extern uint16_t sync_timer;
 u16 tmp_time;
 extern float dw_vbat;
+extern u16 slottime,max_slotnum,current_slotpos,tyncpoll_time;
 void Tag_App(void)//发送模式(TAG标签)
 {
 	uint32_t frame_len;
@@ -491,10 +493,10 @@
 //	deca_sleep(10);
 }
 //	dwt_entersleep();
-//	if(tag_succ_times<g_com_map[MIN_REPORT_ANC_NUM])
-//	{
-//	//poll_timer +=time32_incr&0x7+3;
-//	}
+	if(tag_succ_times<1)
+	{
+		tyncpoll_time=(current_slotpos--%max_slotnum)*slottime;
+	}
 
 	/* Execute a delay between ranging exchanges. */
 	
@@ -504,11 +506,11 @@
 #define TDFILTER
 //#define CHECK_UID
 extern uint8_t UID_ERROR;
+u8 misdist_num[TAG_NUM_IN_SYS];
 void Anchor_App(void)
 {
 	uint32_t frame_len;
 	uint32_t resp_tx_time;
-	static u8 misdist_num;
 	/* Clear reception timeout to start next ranging process. */
 	dwt_setrxtimeout(0);//设定接收超时时间,0位没有超时时间
 
@@ -646,9 +648,10 @@
 					hex_dist = dist_cm+(int16_t)g_com_map[DIST_OFFSET]*10;
 					if(tag_id_recv-TAG_ID_START<=TAG_NUM_IN_SYS)
 					{
-					if(hex_dist-his_dist[tag_id_recv-TAG_ID_START]<15000||misdist_num>4)
-					{int32_t filter_dist;
-						misdist_num=0;
+					if(abs(hex_dist-his_dist[tag_id_recv-TAG_ID_START])<15000||misdist_num[tag_id_recv-TAG_ID_START]>4)
+					{
+						int32_t filter_dist;
+						misdist_num[tag_id_recv-TAG_ID_START]=0;
 					if(hex_dist<1000000&&hex_dist>-10000)
 					{		
 						#ifdef TDFILTER
@@ -683,8 +686,9 @@
 					//dis_after_filter = LP_Frac_Update(p_Dis_Filter, dist_cm);
 						}
 					
-					}else{
-						misdist_num++;
+					}
+					else{
+						misdist_num[tag_id_recv-TAG_ID_START]++;
 					}
 				}
 				}

--
Gitblit v1.9.3