Hi, sadly, your approach can't be used to measure tuning time: querying the sensor is much slower than the tuning is. You're sampling the speed at which you can *ask* the device whether its LO is locked, not the actual tuning time.
If you want to measure the tuning times, I'd recommend doing something like: 1. set a command time, say 2 s in the future 2. issue a gain command 3. set a command time, say 2.05 s in the future 4. issue a tune command and observe the output of your USRP, or observe a constant-amplitude single-tone input. Best regards, Marcus DISCLAIMER: Any attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system, or for use in hazardous environments. You assume all risks for use of the Code. Use of the Code is subject to terms of the licenses to the UHD or RFNoC code with which the Code is used. Standard licenses to UHD and RFNoC can be found at https://www.ettus.com/sdr-software/licenses/. NI will only perform services based on its understanding and condition that the goods or services (i) are not for the use in the production or development of any item produced, purchased, or ordered by any entity with a footnote 1 designation in the license requirement column of Supplement No. 4 to Part 744, U.S. Export Administration Regulations and (ii) such a company is not a party to the transaction. If our understanding is incorrect, please notify us immediately because a specific authorization may be required from the U.S. Commerce Department before the transaction may proceed further. On 25.05.21 14:31, Андрей А via USRP-users wrote: > #include <stdio.h> > #include <time.h> > #include <uhd.h> > > #define SR 25 > #define BW 20 > #define MHzToHz 1e+6 > > uint64_t get_posix_clock_time () > { > struct timespec ts; > > if (clock_gettime (CLOCK_MONOTONIC, &ts) == 0) > return (uint64_t) (ts.tv_sec * 1000000 + ts.tv_nsec / 1000); > else > return 0; > } > > uhd_error createLockedSensor(uhd_usrp_handle hDevice,uhd_sensor_value_handle > *hSensor) > { > uhd_error r; > > r = > uhd_sensor_value_make_from_bool(hSensor,"lo_locked",false,"true","false"); > if (r) return r; > > r = uhd_usrp_get_rx_sensor(hDevice,"lo_locked",0,hSensor); > if (r) > uhd_sensor_value_free(hSensor); > return r; > } > > uhd_error setFreq(uhd_usrp_handle hDevice,uhd_sensor_value_handle > hSensor,double f) > { > uhd_tune_request_t tune_request = > { > .target_freq = f, > .rf_freq_policy = UHD_TUNE_REQUEST_POLICY_AUTO, > .dsp_freq_policy = UHD_TUNE_REQUEST_POLICY_AUTO, > }; > uhd_tune_result_t tune_result; > > uhd_error r; > bool lo_locked; > > r = uhd_usrp_set_rx_freq(hDevice,&tune_request,0,&tune_result); > if(r==UHD_ERROR_NONE && hSensor) > do > { > uhd_sensor_value_to_bool(hSensor,&lo_locked); > } > while (!lo_locked); > > return r; > } > > int main() > { > uhd_error r; > > uhd_usrp_handle hDevice = 0; > uhd_sensor_value_handle hSensor=0; > > r = uhd_usrp_make(&hDevice,""); > if (r) goto free_device; > > r = createLockedSensor(hDevice,&hSensor); > if (r) goto free_device; > > if (hDevice) > { > int f_start,f_count; > > printf ("Enter start freq [MHz]: "); > scanf ("%d",&f_start); > > printf ("Enter freq count: "); > scanf ("%d",&f_count); > if (f_count < 1) goto free_device; > > uint64_t t0,t; > > bool reverse = false; > > for(int k=3;k>0;--k) > { > int f; > > if (reverse) > f = f_start+BW*(f_count-1); > else > f = f_start; > > t=get_posix_clock_time(); > for(int i=0;i<f_count;i++) > { > t0 = get_posix_clock_time(); > setFreq(hDevice,hSensor,f*MHzToHz); > t0 = get_posix_clock_time() - t0; > printf ("f: %d t: %2.1f \n",f,t0*1e-3); > f = (reverse) ? f-BW:f+BW; > } > t = get_posix_clock_time() - t; > > reverse=!reverse; > > printf (">> scan time: %2.1f \n",t*1e-3); > } > } > > free_device: > if (hDevice) > uhd_usrp_free(&hDevice); > if (hSensor) > uhd_sensor_value_free(&hSensor); > > return 0; > } > > _______________________________________________ > USRP-users mailing list -- [email protected] > To unsubscribe send an email to [email protected] _______________________________________________ USRP-users mailing list -- [email protected] To unsubscribe send an email to [email protected]
