[USRP-users] Fwd: Rapid Frequency Hopping Problem

liu Jong jongliu1987 at gmail.com
Tue Mar 22 02:09:49 EDT 2016


Hi,Michael,
          Where can i find it?or just update my UHD?
best regards
Jon

2016-02-05 11:12 GMT+08:00 Michael West <michael.west at ettus.com>:

> FYI... A patch has been posted to the thread titled "Retuning time
> explodes over time".
>
> Regards,
> Michael
>
> On Sun, Jan 31, 2016 at 6:07 PM, liu Jong via USRP-users <
> usrp-users at lists.ettus.com> wrote:
>
>> Hi David,
>>        got it!
>> thank you.
>> best regards
>> Jon
>>
>> 2016-01-29 22:07 GMT+08:00 David Protzman <davidp at department13.com>:
>>
>>> Check out the thread "Retuning time explodes over time"  A solution is
>>> currently being worked on :)
>>> On Jan 29, 2016 2:46 AM, "liu Jong" <jongliu1987 at gmail.com> wrote:
>>>
>>>> Dear all,
>>>> I  met the same problem.I used VS2010+B210.And  As time becomes longer,
>>>> the frequency hopping becomes more and more slow.Here is my test code:
>>>>
>>>>
>>>> #include <uhd/utils/thread_priority.hpp>
>>>> #include <uhd/utils/safe_main.hpp>
>>>> #include <uhd/usrp/multi_usrp.hpp>
>>>> #include "ascii_art_dft.hpp" //implementation
>>>> #include <boost/program_options.hpp>
>>>> #include <boost/thread/thread.hpp> //gets time
>>>> #include <boost/format.hpp>
>>>> #include <iostream>
>>>> #include <complex>
>>>> #include <cstdlib>
>>>> #include <fstream>
>>>> #include <string>
>>>> using namespace std;
>>>> #include "Common.h"
>>>>
>>>> int main(){
>>>>
>>>> unsigned long nStartFreq = 30000000;
>>>> unsigned long nStopFreq = 1000000000;
>>>> unsigned long nBandWidth = 25000000;
>>>> unsigned long nRate = 32000000;
>>>> signed long nGain = 20;
>>>>
>>>> unsigned long nStepFreq = 62500;
>>>> unsigned long nFreqNum = 15520;
>>>> unsigned int nFirstWorkPos = 56;
>>>> unsigned int nWorkNum = 400;
>>>> unsigned long nBinsNum = 512;
>>>>
>>>> string sDeviceName = "";
>>>> string sSubdev = "A:A";
>>>>
>>>> std::cout << boost::format("startfreq: %ld, stopfreq: %ld, bw: %ld,
>>>> rate: %ld, gain: %d, step: %ld, freqNum: %ld, Bins-num: %ld, device: %s,
>>>> subdev: %s, first: %d, workCount: %d\n") % nStartFreq % nStopFreq %
>>>> nBandWidth % nRate % nGain % nStepFreq % nFreqNum % nBinsNum %
>>>> sDeviceName.c_str() % sSubdev.c_str() % nFirstWorkPos %nWorkNum <<
>>>> std::endl;
>>>>
>>>> boost::this_thread::sleep(boost::posix_time::seconds(1));
>>>>
>>>> const int nTotalTimes = (nStopFreq - nStartFreq)%nBandWidth == 0 ?
>>>> (nStopFreq - nStartFreq)/nBandWidth : (nStopFreq - nStartFreq)/nBandWidth +
>>>> 1;
>>>>
>>>> while (true)
>>>> {
>>>> try {
>>>> uhd::set_thread_priority_safe();
>>>>
>>>> std::cout << boost::format("Creating the usrp device with: %s...") %
>>>> sDeviceName << std::endl;
>>>> uhd::usrp::multi_usrp::sptr usrp =
>>>> uhd::usrp::multi_usrp::make(sDeviceName);
>>>>
>>>> std::string ref("internal");
>>>> //std::cout << boost::format("Setting clock: %s") % ref << std::endl;
>>>> usrp->set_clock_source(ref);
>>>>
>>>> //std::cout << boost::format("Setting subdev: %s") % sSubdev <<
>>>> std::endl;
>>>> usrp->set_rx_subdev_spec(sSubdev);
>>>>
>>>> std::string sAntenna("RX2");
>>>> usrp->set_rx_antenna(sAntenna);
>>>>
>>>> //std::cout << boost::format("Using Device: %s") %
>>>> usrp->get_pp_string() << std::endl;
>>>>
>>>> //std::cout << boost::format("Setting RX Bandwidth: %f MHz...") %
>>>> (nBandWidth/1e6) << std::endl;
>>>> usrp->set_rx_bandwidth(nBandWidth);
>>>> //std::cout << boost::format("Actual RX Bandwidth: %f MHz...") %
>>>> (usrp->get_rx_bandwidth()/1e6) << std::endl << std::endl;
>>>>
>>>> //std::cout << boost::format("Setting RX Rate: %f Msps...") %
>>>> (nRate/1e6) << std::endl;
>>>> usrp->set_rx_rate(nRate);
>>>> //std::cout << boost::format("Actual RX Rate: %f Msps...") %
>>>> (usrp->get_rx_rate()/1e6) << std::endl << std::endl;
>>>>
>>>> //std::cout << boost::format("Setting RX Gain: %f dB...") % nGain <<
>>>> std::endl;
>>>> usrp->set_rx_gain(nGain);
>>>> //std::cout << boost::format("Actual RX Gain: %f dB...") %
>>>> usrp->get_rx_gain() << std::endl << std::endl;
>>>>
>>>>
>>>> vector<short> vecTotalDft(nFreqNum);
>>>> vector<short> vecFreqDft(nBinsNum);
>>>> while (true)
>>>> {
>>>> unsigned long nStartFreqTemp;
>>>> unsigned long nCenterFreqTemp;
>>>> unsigned long nThisBinsNum;
>>>>
>>>> {
>>>> struct timeval tv;
>>>> struct tm t;
>>>> gettimeofday(&tv,&t);
>>>> std::cout << "Start: " << (LONG64)tv.tv_sec*1000 + tv.tv_usec <<
>>>> std::endl;
>>>> }
>>>>
>>>> //µ÷Ƶ£¬ÊµÏÖɨÃè
>>>> for (int nTime = 0; nTime < nTotalTimes; nTime++)
>>>> {
>>>> nStartFreqTemp = nStartFreq + nBandWidth * nTime;
>>>> nCenterFreqTemp = nStartFreqTemp + nBandWidth/2;
>>>>
>>>> if ((nTime == nTotalTimes - 1) && (nStartFreqTemp + nBandWidth >
>>>> nStopFreq))
>>>> {
>>>> nThisBinsNum = (LONG64)(nStopFreq - nStartFreqTemp) * nBinsNum / nRate;
>>>> }
>>>> else
>>>> {
>>>> nThisBinsNum = nWorkNum;
>>>> }
>>>>
>>>> //std::cout << boost::format("Setting RX Freq: %f MHz...") %
>>>> (nCenterFreqTemp/1e6) << std::endl;
>>>> uhd::tune_request_t tune_request(nCenterFreqTemp);
>>>> usrp->set_rx_freq(tune_request);
>>>> //std::cout << boost::format("Actual RX Freq: %f MHz...") %
>>>> (usrp->get_rx_freq()/1e6) << std::endl << std::endl;
>>>>
>>>> boost::this_thread::sleep(boost::posix_time::millisec(1)); //allow for
>>>> some setup time
>>>>
>>>> //Check Ref and LO Lock detect
>>>> std::vector<std::string> sensor_names(usrp->get_rx_sensor_names(0));
>>>> if (std::find(sensor_names.begin(), sensor_names.end(), "lo_locked") !=
>>>> sensor_names.end()) {
>>>> uhd::sensor_value_t lo_locked = usrp->get_rx_sensor("lo_locked",0);
>>>> //std::cout << boost::format("Checking RX: %s ...") %
>>>> lo_locked.to_pp_string() << std::endl;
>>>> UHD_ASSERT_THROW(lo_locked.to_bool());
>>>> }
>>>>
>>>> //create a receive streamer
>>>> uhd::stream_args_t stream_args("fc32"); //complex floats
>>>> uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
>>>>
>>>> //allocate recv buffer and metatdata
>>>> uhd::rx_metadata_t md;
>>>> std::vector<std::complex<float> > buff(nBinsNum);
>>>>
>>>> uhd::stream_cmd_t
>>>> stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
>>>> stream_cmd.num_samps = nBinsNum;
>>>> stream_cmd.stream_now = true;
>>>> stream_cmd.time_spec = uhd::time_spec_t();
>>>> rx_stream->issue_stream_cmd(stream_cmd);
>>>>
>>>> while (true){
>>>> size_t num_rx_samps = rx_stream->recv(&buff.front(), buff.size(), md);
>>>> if (num_rx_samps != buff.size()) continue;
>>>>
>>>> //calculate the dft and create the ascii art frame
>>>> //ת»»
>>>> acsii_art_dft::log_pwr_dft_type lpdft(
>>>> acsii_art_dft::log_pwr_dft(&buff.front(), num_rx_samps)
>>>> );
>>>>
>>>> const size_t num_bins = lpdft.size() - 1 + lpdft.size()%2; //make it odd
>>>> for (size_t n = 0; n < nBinsNum; n++){
>>>> //У׼£¬+100
>>>> vecFreqDft[n] = (short)(lpdft[(n + num_bins/2)%num_bins] * 10 + 1000);
>>>> }
>>>> break;
>>>> }
>>>>
>>>>
>>>> rx_stream->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
>>>>
>>>> //È¡ÖмäÓÐЧ²¿·Ö£¬Ð´Èëbuffer
>>>> }
>>>>
>>>> //Ò»´ÎɨÃèÍê³É
>>>> {
>>>> gettimeofday(&tv,&t);
>>>> std::cout << "End: " << (LONG64)tv.tv_sec*1000 + tv.tv_usec <<
>>>> std::endl << std::endl << std::endl;
>>>> }
>>>> }
>>>> }
>>>> catch (const uhd::exception &e)
>>>> {
>>>> cout << "ÑÏÖØÒì³££º" << e.what() << endl;
>>>> }
>>>> catch (...)
>>>> {
>>>> cout << "ÑÏÖØÒì³££ºÆäËû" << endl;
>>>> }
>>>> }
>>>>
>>>> return 0;
>>>> }
>>>>
>>>> best regards
>>>> Jon
>>>> ---------- Forwarded message ----------
>>>> From: David Protzman via USRP-users <usrp-users at lists.ettus.com>
>>>> Date: 2016-01-27 11:31 GMT+08:00
>>>> Subject: [USRP-users] Rapid Frequency Hopping Problem
>>>> To: usrp-users at lists.ettus.com
>>>>
>>>>
>>>> I am using GNU Radio to continually change between a set of frequencies
>>>> every 10ms.  I know that the B200 can do this as it only takes ~ 3ms to
>>>> change freq and there is less than 1ms of data to transmit.  Even with the
>>>> cost of getting through the GNU Radio flow graph I've still got several ms
>>>> to spare.  The trouble is, the whole thing comes crumbling down after about
>>>> a minute or two.  I did some testing and found that after the 3600th
>>>> frequency change, tuning stops working.  The B200 responds back and all
>>>> seems well, but it's actually not changing frequency.  In GNU Radio this
>>>> manifests itself as a whole lot of L's being output.  To eliminate the
>>>> possiblity that my flow graph and custom GNU Radio modules were to blame, I
>>>> created the C++ code below.  One other thing that I noticed was that over
>>>> time (up to the 3600th change), freq changes take longer and longer.  You
>>>> can see this pretty easily by just running top and watching the CPU usage
>>>> slowly go up.  I also tried adding a 10 second sleep after the 1800th
>>>> iteration to see if it was just a buffer that needed to flush out.  Still
>>>> borked out after 3600.
>>>>
>>>>
>>>>
>>>> Anyone know why this is happening?  I assumed there might be a buffer
>>>> somewhere that I am overflowing, but I couldn't find anything definitive.
>>>>
>>>>
>>>>
>>>> I am using UHD from GitHub as of about a month ago.  My version of GNU
>>>> Radio is 3.7.10git-31-gb17bcb88
>>>>
>>>>
>>>>
>>>> My output looks like this (cut to show the 3600 mark):
>>>>
>>>>
>>>>
>>>> count:3596
>>>> time:0.00634687
>>>> count:3597
>>>> time:0.00626769
>>>> count:3598
>>>> time:0.00692431
>>>> count:3599
>>>> time:0.00590456
>>>> count:3600
>>>> time:0.00129256
>>>> count:3601
>>>> time:0.00105713
>>>> count:3602
>>>> time:0.00112481
>>>> count:3603
>>>> time:0.00101894
>>>> count:3604
>>>> time:0.0010365
>>>>
>>>>
>>>>
>>>>
>>>> [source_code]
>>>>
>>>> #include <iostream>
>>>>
>>>> #include <uhd/usrp/multi_usrp.hpp>
>>>>
>>>> #include <unistd.h>
>>>>
>>>>
>>>> int main(){
>>>>
>>>>
>>>>     std::string args;
>>>>
>>>>     uhd::usrp::multi_usrp::sptr usrp =
>>>> uhd::usrp::multi_usrp::make(args);
>>>>
>>>>
>>>>     for(int a = 0; a < 4000; a++){
>>>>
>>>>         uhd::tune_request_t tune_req = uhd::tune_request_t(800e6 + (a *
>>>> 1e6), 0);
>>>>
>>>>         tune_req.dsp_freq_policy = uhd::tune_request_t::POLICY_NONE;
>>>>
>>>>         tune_req.rf_freq_policy = uhd::tune_request_t::POLICY_AUTO;
>>>>
>>>>         double start = usrp->get_time_now().get_real_secs();
>>>>
>>>>         usrp->set_tx_freq(tune_req, 0);
>>>>
>>>>         std::cout << "time:" << (usrp->get_time_now().get_real_secs() -
>>>> start) << std::endl;
>>>>
>>>>         std::cout << "count:" << a << std::endl;
>>>>
>>>>         usleep(20000);
>>>>
>>>>     }
>>>>
>>>>
>>>>
>>>>     return 1;
>>>>
>>>> }
>>>>
>>>> [/source_code]
>>>>
>>>>
>>>>
>>>> --
>>>> David Protzman
>>>> Department 13
>>>>
>>>> _______________________________________________
>>>> USRP-users mailing list
>>>> USRP-users at lists.ettus.com
>>>> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
>>>>
>>>>
>>>>
>>
>> _______________________________________________
>> USRP-users mailing list
>> USRP-users at lists.ettus.com
>> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ettus.com/pipermail/usrp-users_lists.ettus.com/attachments/20160322/9c09625f/attachment-0002.html>


More information about the USRP-users mailing list