lk396784054 发表于 2019-11-30 10:55:25

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

刚刚接触,不太懂,请问如何基站直接串口输出标签到本基站的距离,有参考代码吗,谢谢

tuzhuke 发表于 2019-11-30 11:53:42


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

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

                        distance_msg = frame_seq_nb;
                        distance_msg = tag_index;
                        dwt_writetxdata(sizeof(distance_msg), distance_msg, 0);
                        dwt_writetxfctrl(sizeof(distance_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 );

页: [1]
查看完整版本: 一个标签2个基站如何测距?