Nuand / bladeRF

bladeRF USB 3.0 Superspeed Software Defined Radio Source Code
http://nuand.com
Other
1.15k stars 459 forks source link

bladeRF micro (AD9361) set/get_correction of phase and gain #788

Open hemanthmab opened 4 years ago

hemanthmab commented 4 years ago

I am looking to pre-calculate the i/q phase and gain corrections for specific frequencies and load them before acquiring samples. Do the set_correction and get_correction functions work properly for the bladeRF micro? Reading the values using the python wrapper gives values like: -1408(phase), -4992(gain), but the API documentation mentions the values should be [-4096, 4096] (I am guessing that's for the older bladeRF?). I would really appreciate some examples for usage of this functionality, specific to micro.

In python, I am using the functions as below:

device.get_correction( ch.channel, _bladerf.Correction['PHASE'])
device.set_correction( ch.channel, _bladerf.Correction['PHASE'], value)

Issues:

hemanthmab commented 4 years ago

One correction and two hacky fixes that seem to get it working (all in bladerf2.c):

AD936X_REG_RX1_INPUT_BC_PHASE_CORR -> AD936X_REG_RX1_INPUT_BC_GAIN_CORR
AD936X_REG_RX2_INPUT_BC_PHASE_CORR -> AD936X_REG_RX2_INPUT_BC_GAIN_CORR
/* Disable RX_QUAD Tracking*/
ad9361_set_rx_quad_track_en_dis(phy, 0);
data = val << shift; -> data = val; //L1763
data = (value >> shift) & 0xff; -> data = value  & 0xff; //L1902

The 8-bit calibration values seem to range from [-128, 127] with 0 as the starting point. I could try creating a pull request for the corrections but disabling the quadrature tracking might need to be more explicit as it needs an enable/disable function. Please let me know if there is a better way to do this.

_One odd thing I observed: get/set_correction functions seem to target the wrong/opposite RX port after enabling the channel (RX_A instead of RXB/C or vice-versa). Setting them before channel enable seems to work fine. Maybe it's an issue with the way I am using the python statement?

Abraham403 commented 4 years ago

Can you please elaborate why or what is the advantage of precorrection feature? are you using it with GNCradio? Thanks