|
(1)哪些代码可以控制UWB模块发射和接受信号
UWB发送和接收信号都是通过调用deca提供的API实现的,不论哪个版本的代码都是一样的
A. 发送信号,步骤为将数据写入到UWB寄存器中,告知发送offset,启动发送,等待发送完毕
- dwt_writetxdata(sizeof(angle_msg), angle_msg, 0);
- dwt_writetxfctrl(sizeof(angle_msg), 0);
- /* Start transmission, indicating that a response is expected so that reception is enabled automatically after the frame is sent and the delay
- * set by dwt_setrxaftertxdelay() has elapsed. */
- dwt_starttx(DWT_START_TX_IMMEDIATE );
- while (!(dwt_read32bitreg(SYS_STATUS_ID) & SYS_STATUS_TXFRS))
- { };
复制代码
B. 接收信号,在BP50中一般会先设置接收超时,0表示一直等。然后调用dwt_rxenable 启动发送。
- dwt_setrxtimeout(0);
- /* Activate reception immediately. */
- dwt_rxenable(0);
复制代码
(2)基站接收到标签的信号后,过一段时间会向标签发送信号,基站等待的时间是自动的还是靠代码控制
你说的这个时间,需要手动控制,尽量收到信号立马发出去,这样可以减少误差。
可以参考博文:cnblogs.com/tuzhuke/p/9948520.html
(3)哪些代码是将基站1和基站2的距离信息发送到基站0中
基站收到final 信息后,会在基站端解算距离,然后把距离汇总给标签,具体代码如下
- Da = (double)(final_tx_ts - resp_rx_ts);
- Db = (double)(resp_tx_ts_32 - poll_rx_ts_32);
- tof_dtu = (int64)((Ra * Rb - Da * Db) / (Ra + Rb + Da + Db));
- tof = tof_dtu * DWT_TIME_UNITS;
- distance = tof * SPEED_OF_LIGHT;
- distance = distance - dwt_getrangebias(config.chan,(float)distance, config.prf);
-
- int temp = (int)(distance*100);
- distance_msg[10] = temp/100;
- distance_msg[11] = temp%100;
- distance_msg[12] = anthor_index;
- distance_msg[ALL_MSG_SN_IDX] = frame_seq_nb;
- distance_msg[ALL_MSG_TAG_IDX] = tag_index;
- dwt_writetxdata(sizeof(distance_msg), distance_msg, 0);
- dwt_writetxfctrl(sizeof(distance_msg), 0);
复制代码
(4)上位机的哪些代码实现根据距离计算实际位置
上位机部分,目前有个帖子会梳理上位机流程,可以参考:
http://51uwb.cn/forum.php?mod=viewthread&tid=355&extra=page%3D1
|
|