51uwb.cn

 找回密码
 立即注册
查看: 3827|回复: 1

一个标签2个基站如何测距?

[复制链接]

3

主题

4

帖子

16

积分

新手上路

Rank: 1

积分
16
发表于 2019-11-30 10:55:25 | 显示全部楼层 |阅读模式
刚刚接触,不太懂,请问如何基站直接串口输出标签到本基站的距离,有参考代码吗,谢谢
回复

使用道具 举报

73

主题

249

帖子

6726

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
6726
发表于 2019-11-30 11:53:42 | 显示全部楼层

在工程中有如下代码,是基站将距离信息(distance)打包发送出去的部分。
你可以将distance 这个距离信息通过串口打印出来

  1. distance = distance - dwt_getrangebias(config.chan,(float)distance, config.prf);//距离减去矫正系数
  2.                         //将计算结果发送给TAG
  3.                         int temp = (int)(distance*100);
  4.                         distance_msg[10] = temp/100;
  5.                         // a=x;  //自动类型转换,取整数部分
  6.                         distance_msg[11] = temp%100;  //乘100后对100取余,得到2位小数点后数字
  7.                         distance_msg[12] = anthor_index;

  8.                         distance_msg[ALL_MSG_SN_IDX] = frame_seq_nb;
  9.                         distance_msg[ALL_MSG_TAG_IDX] = tag_index;
  10.                         dwt_writetxdata(sizeof(distance_msg), distance_msg, 0);
  11.                         dwt_writetxfctrl(sizeof(distance_msg), 0);

  12.                         /* Start transmission, indicating that a response is expected so that reception is enabled automatically after the frame is sent and the delay
  13.                          * set by dwt_setrxaftertxdelay() has elapsed. */
  14.                         dwt_starttx(DWT_START_TX_IMMEDIATE );
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

bphero Inc.  

GMT+8, 2024-3-28 23:56 , Processed in 0.013685 second(s), 5 queries , File On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc. Template By 【未来科技】【 www.wekei.cn 】

快速回复 返回顶部 返回列表