Hi, when I run the program below, there are a couple problems with the calibration. The RX calibration turns on the DC bias removal, even though I explicitly turned it off beforehand. It doesn’t appear to calibrate the RX DC zero offset. The TX calibration fails completely.
import sys
import math
import SoapySDR
from SoapySDR import * #SOAPY_SDR_ constants
import numpy #use numpy for buffers
frequency = 2.45e9
frequencyOffset = 0.
amplitude = 0.5
#enumerate devices
results = SoapySDR.Device.enumerate()
print("Devices: ")
for result in results: print(result)
#create device instance
#args can be user defined or from the enumeration result
#args = dict(driver="lime")
args = results[0]
print("Instantiating device: ")
sdr = SoapySDR.Device(args)
#apply settings
#RX
rxSampleRate = 1.0e5
print("Setting RX sample rate to %g" % rxSampleRate)
sdr.setSampleRate(SOAPY_SDR_RX, 0, rxSampleRate)
rxFrequency = frequency
print("Setting RX frequency to %g" % (rxFrequency))
sdr.setFrequency(SOAPY_SDR_RX, 0, rxFrequency)
rxAntenna = "LNAH"
print("Setting RX antenna to " + str(rxAntenna))
sdr.setAntenna(SOAPY_SDR_RX, 0, rxAntenna)
rxGain = 20.0
print("Setting RX gain to " + str(rxGain))
sdr.setGain(SOAPY_SDR_RX, 0, rxGain)
#set dc offset mode to False to disable automatic DC bias removal
sdr.setDCOffsetMode(SOAPY_SDR_RX, 0, False)
print("Getting RX DC offset mode: " + str(sdr.getDCOffsetMode(SOAPY_SDR_RX, 0)))
print("Getting RX DC offset: " + str(sdr.getDCOffset(SOAPY_SDR_RX, 0)))
sdr.setBandwidth(SOAPY_SDR_RX, 0, 5e6)
print("Getting RX bandwidth: " + str(sdr.getBandwidth(SOAPY_SDR_RX, 0)))
#setup a stream (complex floats)
print("Setting up RX stream")
#args = dict(skipCal="true")
args = dict(skipCal="false")
rxStream = sdr.setupStream(SOAPY_SDR_RX, SOAPY_SDR_CF32, [0], args)
#TX
txSampleRate = 1.0e5
print("Setting TX sample rate to %g" % txSampleRate)
sdr.setSampleRate(SOAPY_SDR_TX, 0, txSampleRate)
txFrequency = frequency + frequencyOffset
print("Setting TX frequency to %g" % (txFrequency))
sdr.setFrequency(SOAPY_SDR_TX, 0, txFrequency)
txAntenna = "BAND1"
print("Setting TX antenna to " + str(txAntenna))
sdr.setAntenna(SOAPY_SDR_TX, 0, txAntenna)
txGain = 20.0
print("Setting TX gain to " + str(txGain))
sdr.setGain(SOAPY_SDR_TX, 0, txGain)
print("Getting TX DC offset: " + str(sdr.getDCOffset(SOAPY_SDR_TX, 0)))
sdr.setBandwidth(SOAPY_SDR_TX, 0, 5e6)
print("Getting TX bandwidth: " + str(sdr.getBandwidth(SOAPY_SDR_TX, 0)))
print("Setting up TX stream")
args = dict(skipCal="true")
#args = dict(skipCal="false")
txStream = sdr.setupStream(SOAPY_SDR_TX, SOAPY_SDR_CF32, [0], args)
rxBuffer = numpy.array([0]*0x20000, numpy.complex64)
txBuffer = numpy.array([0]*0x20000, numpy.complex64)
for i in range(len(txBuffer)):
txBuffer[i] = numpy.complex64(amplitude)
print("Activating RX stream")
sdr.activateStream(rxStream) #start streaming
print("Getting RX DC offset mode: " + str(sdr.getDCOffsetMode(SOAPY_SDR_RX, 0)))
print("Getting RX DC offset: " + str(sdr.getDCOffset(SOAPY_SDR_RX, 0)))
print("Activating TX stream")
sdr.activateStream(txStream) #start streaming
for i in range(4):
#load tx
print("Loading TX stream")
writeResult = sdr.writeStream(txStream, [txBuffer], len(txBuffer))
print("Write return value: " + str(writeResult.ret))
print
#receive some samples
print("Reading RX stream")
readResult = sdr.readStream(rxStream, [rxBuffer], len(rxBuffer))
print("Read return value: " + str(readResult.ret)) #num samples or error code
print("flags: " + str(readResult.flags)) #flags set by receive operation
print("Timestamp: " + str(readResult.timeNs)) #timestamp for receive buffer
for i in range(4):
print("Value[%d]: " % i)
print(str(rxBuffer[i]) + " magnitude: " + str(abs(rxBuffer[i])))
print
print
#shutdown the stream
print("Deactivating TX stream")
sdr.deactivateStream(txStream) #stop streaming
print("Closing TX stream")
sdr.closeStream(txStream)
print("Deactivating RX stream")
sdr.deactivateStream(rxStream) #stop streaming
print("Closing RX stream")
sdr.closeStream(rxStream)
It produces the following output when run:
Devices:
{addr=24607:1027, driver=lime, label=LimeSDR Mini [USB 2.0] 1D40ECE6B10A17, media=USB 2.0, module=FT601, name=LimeSDR Mini, serial=1D40ECE6B10A17}
Instantiating device:
[INFO] Make connection: 'LimeSDR Mini [USB 2.0] 1D40ECE6B10A17'
[INFO] Reference clock 40.00 MHz
[INFO] Device name: LimeSDR-Mini
[INFO] Reference: 40 MHz
[INFO] LMS7002M calibration values caching Disable
Setting RX sample rate to 100000
Setting RX frequency to 2.45e+09
Setting RX antenna to LNAH
Setting RX gain to 20.0
Getting RX DC offset mode: False
Getting RX DC offset: 0j
[INFO] RX LPF configured
Getting RX bandwidth: 5000000.0
Setting up RX stream
Setting TX sample rate to 100000
Setting TX frequency to 2.45e+09
Setting TX antenna to BAND1
Setting TX gain to 20.0
Getting TX DC offset: 0j
[INFO] Filter calibrated. Filter order-4th, filter bandwidth set to 5 MHz.Real pole 1st order filter set to 2.5 MHz. Preemphasis filter not active
[INFO] TX LPF configured
Getting TX bandwidth: 5000000.0
Setting up TX stream
Activating RX stream
e[1me[31m[ERROR] Tx Calibration: MCU error 5 (Loopback signal weak: not connected/insufficient gain?)e[0m
[INFO] Rx calibration finished
Getting RX DC offset mode: True
Getting RX DC offset: 0j
Activating TX stream
Loading TX stream
Write return value: 131072
Reading RX stream
Read return value: 131072
flags: 4
Timestamp: 0
Value[0]:
(0.196783-0.143559j) magnitude: 0.243583
Value[1]:
(0.196783-0.143071j) magnitude: 0.243296
Value[2]:
(0.196783-0.143071j) magnitude: 0.243296
Value[3]:
(0.196783-0.143559j) magnitude: 0.243583
Loading TX stream
Write return value: 131072
Reading RX stream
Read return value: 131072
flags: 4
Timestamp: 1310720000
Value[0]:
-0.000488296j magnitude: 0.000488296
Value[1]:
(-0.000488296-0.000488296j) magnitude: 0.000690555
Value[2]:
(-0.000488296+0j) magnitude: 0.000488296
Value[3]:
0j magnitude: 0.0
Loading TX stream
Write return value: 131072
Reading RX stream
Read return value: 131072
flags: 4
Timestamp: 2621440000
Value[0]:
-0.000488296j magnitude: 0.000488296
Value[1]:
-0.000488296j magnitude: 0.000488296
Value[2]:
-0.000488296j magnitude: 0.000488296
Value[3]:
0j magnitude: 0.0
Loading TX stream
Write return value: 131072
Reading RX stream
Read return value: 131072
flags: 4
Timestamp: 3932160000
Value[0]:
-0.000488296j magnitude: 0.000488296
Value[1]:
-0.000488296j magnitude: 0.000488296
Value[2]:
(-0.000488296-0.000488296j) magnitude: 0.000690555
Value[3]:
-0.000488296j magnitude: 0.000488296
Deactivating TX stream
e[1me[33m[WARNING] popping from TX, samples popped 8/1020e[0m
Closing TX stream
Deactivating RX stream
Closing RX stream
You can see getDCOffsetMode() returns True after the RX calibration runs even though I set it False earlier.
I tried increasing the gain to make the TX calibration work, but it didn’t help.