| | |
| | | memcpy(&anc_id_recv,&rx_buffer[ANCHOR_ID_IDX],2); |
| | | // g_Tagdist[anc_id_recv]= hex_dist; |
| | | // g_flag_Taggetdist[anc_id_recv]=0; |
| | | if(!g_com_map[MODBUS_MODE]) |
| | | |
| | | if(!g_com_map[MODBUS_MODE]&&hex_dist2!=0xffff) |
| | | { |
| | | hex_dist2 = hex_dist2+(int16_t)g_com_map[DIST_OFFSET]; |
| | | usart_send[2] = 1;//æ£å¸¸æ¨¡å¼ |
| | | usart_send[3] = 17;//æ°æ®æ®µé¿åº¦ |
| | | usart_send[4] = frame_seq_nb;//æ°æ®æ®µé¿åº¦ |
| | |
| | | int8_t correction_time; |
| | | extern uint8_t sync_seq; |
| | | #define TDFILTER |
| | | |
| | | //#define CHECK_UID |
| | | extern uint8_t UID_ERROR; |
| | | void Anchor_App(void) |
| | | { |
| | | uint32_t frame_len; |
| | |
| | | |
| | | /* Write and send the response message. See NOTE 9 below.*/ |
| | | if(tag_id_recv-TAG_ID_START<=TAG_NUM_IN_SYS) |
| | | memcpy(&tx_resp_msg[DIST_IDX], &anchor_dist_last_frm[tag_id_recv-TAG_ID_START], 4); |
| | | memcpy(&tx_resp_msg[DIST_IDX], &g_Tagdist[tag_id_recv], 4); |
| | | |
| | | dwt_writetxdata(sizeof(tx_resp_msg), tx_resp_msg, 0);//åå
¥åéæ°æ® |
| | | dwt_writetxfctrl(sizeof(tx_resp_msg), 0);//设å®åéé¿åº¦ |
| | |
| | | final_msg_get_ts(&rx_buffer[FINAL_MSG_RESP_RX_TS_IDX], &resp_rx_ts); |
| | | final_msg_get_ts(&rx_buffer[FINAL_MSG_FINAL_TX_TS_IDX], &final_tx_ts); |
| | | |
| | | #ifdef CHECK_UID |
| | | if(UID_ERROR==1) |
| | | poll_rx_ts=0; |
| | | #endif |
| | | /* Compute time of flight. 32-bit subtractions give correct answers even if clock has wrapped. See NOTE 10 below. */ |
| | | poll_rx_ts_32 = (uint32_t)poll_rx_ts;//使ç¨32使°æ®è®¡ç® |
| | | resp_tx_ts_32 = (uint32_t)resp_tx_ts; |
| | |
| | | /*--------------------------以ä¸ä¸ºéæµè·é»è¾------------------------*/ |
| | | LED0_BLINK; //æ¯æå䏿¬¡é讯åéªç䏿¬¡ |
| | | g_UWB_com_interval = 0; |
| | | dis_after_filter=dist_cm; |
| | | hex_dist = dist_cm+(int16_t)g_com_map[DIST_OFFSET]; |
| | | if(hex_dist-anchor_dist_last_frm[tag_id_recv-TAG_ID_START]<15000||misdist_num>4) |
| | | |
| | | 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(hex_dist<1000000&&hex_dist>-10000) |
| | | { |
| | | if(tag_id_recv-TAG_ID_START<=TAG_NUM_IN_SYS) |
| | | { |
| | | if(abs(hex_dist-his_dist[tag_id_recv-TAG_ID_START])<10000) |
| | | { |
| | | g_Tagdist[tag_id_recv-TAG_ID_START] = hex_dist; |
| | | anchor_dist_last_frm[tag_id_recv-TAG_ID_START] = hex_dist; |
| | | |
| | | { |
| | | #ifdef TDFILTER |
| | | TrackingDiffUpdate(pUWBDistanceTrackingDiff, (float)hex_dist); |
| | | filter_dist=pUWBDistanceTrackingDiff->pos_predict/10; |
| | | NewTrackingDiffUpdate(tag_id_recv-TAG_ID_START, (float)hex_dist); |
| | | filter_dist=pos_predict[tag_id_recv-TAG_ID_START]/10; |
| | | #else |
| | | filter_dist=hex_dist/10; |
| | | #endif |
| | | anchor_dist_last_frm[tag_id_recv-TAG_ID_START]=filter_dist; |
| | | g_Tagdist[tag_id_recv]= anchor_dist_last_frm[tag_id_recv-TAG_ID_START]; |
| | | } |
| | | g_Tagdist[tag_id_recv]= filter_dist; |
| | | |
| | | his_dist[tag_id_recv-TAG_ID_START]=hex_dist; |
| | | g_flag_Taggetdist[tag_id_recv]=0; |
| | | if(!g_com_map[MODBUS_MODE]) |
| | |
| | | UART_PushFrame(usart_send,21); |
| | | } |
| | | // memcpy(&Modbus_HoldReg[tag_id_recv*2],&anchor_dist_last_frm[tag_id_recv-TAG_ID_START],4); |
| | | Modbus_HoldReg[tag_id_recv*2]=anchor_dist_last_frm[tag_id_recv-TAG_ID_START]>>16; |
| | | Modbus_HoldReg[tag_id_recv*2+1]=anchor_dist_last_frm[tag_id_recv-TAG_ID_START]; |
| | | Modbus_HoldReg[tag_id_recv*2]=g_Tagdist[tag_id_recv-TAG_ID_START]>>16; |
| | | Modbus_HoldReg[tag_id_recv*2+1]=g_Tagdist[tag_id_recv-TAG_ID_START]; |
| | | //dis_after_filter = LP_Frac_Update(p_Dis_Filter, dist_cm); |
| | | } |
| | | } |
| | | |
| | | }else{ |
| | | misdist_num++; |
| | | } |
| | | if(anchor_dist_last_frm[tag_id_recv-TAG_ID_START]>1000) |
| | | {anchor_dist_last_frm[tag_id_recv-TAG_ID_START]=anchor_dist_last_frm[tag_id_recv-TAG_ID_START];} |
| | | } |
| | | } |
| | | }else{ |
| | | /* Clear RX error events in the DW1000 status register. */ |