# The External Loopback does not seems to work

**URL:** <https://discourse.myriadrf.org/t/the-external-loopback-does-not-seems-to-work/8867>\
**Category:** LimeSDR\
**Created:** [16 June 2025 18:49 UTC](https://discourse.myriadrf.org/t/the-external-loopback-does-not-seems-to-work/8867 "2025-06-16T18:49:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Petren](https://avatars.discourse-cdn.com/v4/letter/p/a587f6/32.png) [@Petren](https://discourse.myriadrf.org/u/Petren)\
**Post date:** [16 June 2025 18:49 UTC](https://discourse.myriadrf.org/t/the-external-loopback-does-not-seems-to-work/8867/1 "2025-06-16T18:49:23Z")

</div>

Hello.  
I trying to use the ch.A external loopback. However, I not receiving anything. I also tried to activate it with the LimeSuite GUI and transmitted with GNU Radio. In none of these tries I got something on the RX. What am I doing wrong?  
My code is below:

import SoapySDR  
from SoapySDR import Device  
import time  
import numpy as np  
import threading

def Modify\_SPI\_Reg(sdr, addr , msb, lsb, value):  
spiDataReg = sdr.readRegister(“BBIC”, addr)  
spiMask = (~(~0 \<\< (msb - lsb + 1))) \<\< (lsb)  
spiDataReg = (spiDataReg & (~spiMask)) | ((value \<\< lsb) & spiMask)  
return sdr.writeRegister(“BBIC”, addr, spiDataReg)

def LoopBack(sdr):

```
Modify_SPI_Reg(sdr, 0x17, 0 , 0 , 1)
Modify_SPI_Reg(sdr, 0x17, 1 , 1 , 1)
Modify_SPI_Reg(sdr, 0x17, 2 , 2 , 0)

```

def tx():

```
i = 0
global tx_time_0
LimeSDR1.activateStream(txStream1)
tx_time_0 = int(LimeSDR1.getHardwareTime() + 0.1e9)
while i < 100:
    status = LimeSDR1.writeStream(txStream1, [iq0], len(iq0), tx_flags, tx_time_0)
    if status.ret != len(iq0):
        raise Exception('transmit failed %s' % str(status))
    i= i+1
LimeSDR1.deactivateStream(txStream1)
LimeSDR1.closeStream(txStream1)

```

def rx():  
i = 0  
receive\_time = int(tx\_time\_0 - (num\_rx\_samps/samp\_rate) \* 1e9/2)  
LimeSDR1.activateStream(rxStream1, rx\_flags, receive\_time, num\_rx\_samps)  
rx\_buff = np.array([0]\*1024, np.complex64)  
timeout\_us = int(5e5) #500 ms \>\> stream time

```
while i < 100:
    status = LimeSDR1.readStream(rxStream1, [rx_buff], len(rx_buff), timeoutUs=timeout_us)
    i = i +1

LimeSDR1.deactivateStream(rxStream1)
LimeSDR1.closeStream(rxStream1)
np.savetxt('IQ rx.txt', rx_buff)

```

######################################################  
#Variables  
samp\_rate = 20e6  
bandwidth = 5e6  
rx\_lo = 2e9  
gain = 30  
burstSize = 1024

ts = 1/samp\_rate  
N = 2 \*\* 16  
t = np.arange(0, N\*ts, ts)  
i0 = np.cos(2 \* np.pi \* t \* 200e3) \* 2 \*\* 14  
q0 = np.sin(2 \* np.pi \* t \* 200e3) \* 2 \*\* 14  
iq0 = i0 +1j \* q0

iq0 = iq0.astype(np.complex64)

np.savetxt(‘IQ.txt’, iq0)

devices = Device.enumerate()  
print(devices)

LimeSDR1 = Device(devices[0])  
LimeSDR1.boardName = “LimeSDR”

LimeSDR1.setMasterClockRate(30.72e6)

LimeSDR1.setSampleRate(SoapySDR.SOAPY\_SDR\_TX, 0, int(samp\_rate))  
LimeSDR1.setAntenna(SoapySDR.SOAPY\_SDR\_TX, 0,‘BAND2’)  
LimeSDR1.setGain(SoapySDR.SOAPY\_SDR\_TX, 0, gain)  
LimeSDR1.setFrequency(SoapySDR.SOAPY\_SDR\_TX, 0,int(rx\_lo))  
LimeSDR1.setBandwidth(SoapySDR.SOAPY\_SDR\_TX, 0, int(bandwidth))

time.sleep(1)

LimeSDR1.setSampleRate(SoapySDR.SOAPY\_SDR\_RX, 0, int(samp\_rate))  
LimeSDR1.setAntenna(SoapySDR.SOAPY\_SDR\_RX, 0,‘LNAH’)  
LimeSDR1.setGain(SoapySDR.SOAPY\_SDR\_RX, 0, gain)  
LimeSDR1.setFrequency(SoapySDR.SOAPY\_SDR\_RX, 0,int(rx\_lo))  
LimeSDR1.setBandwidth(SoapySDR.SOAPY\_SDR\_RX, 0, int(bandwidth))

time.sleep(1)

rxStream1 = LimeSDR1.setupStream(SoapySDR.SOAPY\_SDR\_RX, SoapySDR.SOAPY\_SDR\_CF32, [0])  
txStream1 = LimeSDR1.setupStream(SoapySDR.SOAPY\_SDR\_TX, SoapySDR.SOAPY\_SDR\_CF32, [0])

time.sleep(1)

LoopBack(LimeSDR1)  
time.sleep(1)

num\_rx\_samps = len(iq0)

tx\_time\_0 = int(LimeSDR1.getHardwareTime() + 0.1e9)  
receive\_time = int(tx\_time\_0 - (num\_rx\_samps/samp\_rate) \* 1e9/2)

tx\_flags = SoapySDR.SOAPY\_SDR\_HAS\_TIME | SoapySDR.SOAPY\_SDR\_END\_BURST

rx\_buffs = np.array(, np.complex64)  
rx\_flags = SoapySDR.SOAPY\_SDR\_HAS\_TIME | SoapySDR.SOAPY\_SDR\_END\_BURST

t1 = threading.Thread(target=tx)  
t2 = threading.Thread(target=rx)

t2.start()  
t1.start()

t1.join()  
t2.join()

---

<div class="post-metadata">

**Author:** ![RightHalfPlane](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@RightHalfPlane](https://discourse.myriadrf.org/u/RightHalfPlane)\
**Post date:** [17 June 2025 04:30 UTC](https://discourse.myriadrf.org/t/the-external-loopback-does-not-seems-to-work/8867/2 "2025-06-17T04:30:50Z")

</div>

If you look at this video -

A Software Defined Radio Python Starter Kit

[![](https://img.youtube.com/vi/NH-8Sx8qM68/maxresdefault.jpg "A Software Defined Radio Python Starter Kit") ](https://www.youtube.com/watch?v=NH-8Sx8qM68)

it points out some problems that may affect your program.

Another things is that “threads” in python are not actually threads - the processes run one at a time. You have to use shared memory like gnuradio does to actually get more than one process to run at the same time.

---

<div class="post-metadata">

**Author:** ![ricardas](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/ricardas/32/86_2.png) [@ricardas](https://discourse.myriadrf.org/u/ricardas)\
**Post date:** [17 June 2025 06:13 UTC](https://discourse.myriadrf.org/t/the-external-loopback-does-not-seems-to-work/8867/3 "2025-06-17T06:13:42Z")

</div>

> [@Petren](#):
>
> rx\_lo = 2e9  
> LimeSDR1.setAntenna(SoapySDR.SOAPY\_SDR\_TX, 0,‘BAND2’)

BAND2 will be weak at that LO frequency.  
BAND2 is for around 30 MHz - 1.9 GHz  
BAND1 is for around 2 GHz - 2.6 GHz

I suggest checking if you’re getting anything while continuously transmitting, instead of transmitting one burst.
