Skip to content

Commit ea25c90

Browse files
committed
New library v1.33.2106.3:
- Added RFE Generator combo support - Added all PLUS, W5G and AudioPro SA models support - Added input stage performance - Added wideband performance - Added EEOT support for partial sweeps - Added generator (Standard and Combo) examples - Added wifi commands - Fixed first range issue in RFE_Example_USB_2 and RFE_Example_IOT_2 - Fixed 2 first sweeps bug in 4G+, 6G+ and MW5G - Fixed print functions bug - Fixed steps/points bug - Fixed RFE_Example_control.py - Supported C2-f, C5-, Cd, Cj commands - Improved RFE_Example_USB_2.py to make it available for all RFE models
1 parent 5b20c16 commit ea25c90

14 files changed

+734
-258
lines changed

Examples_IOT/RFE_Example_IoT_1.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import time
1515
from datetime import datetime, timedelta
1616
import RFExplorer
17+
from RFExplorer import RFE_Common
18+
import math
1719

1820
#---------------------------------------------------------
1921
# Helper functions
@@ -24,9 +26,10 @@ def PrintPeak(objAnalazyer):
2426
"""
2527
nIndex = objAnalazyer.SweepData.Count-1
2628
objSweepTemp = objAnalazyer.SweepData.GetData(nIndex)
27-
nStep = objSweepTemp.GetPeakStep() #Get index of the peak
29+
nStep = objSweepTemp.GetPeakDataPoint() #Get index of the peak
2830
fAmplitudeDBM = objSweepTemp.GetAmplitude_DBM(nStep) #Get amplitude of the peak
2931
fCenterFreq = objSweepTemp.GetFrequencyMHZ(nStep) #Get frequency of the peak
32+
fCenterFreq = math.floor(fCenterFreq * 10 ** 3) / 10 ** 3 #truncate to 3 decimals
3033

3134
print("Sweep[" + str(nIndex)+"]: Peak: " + "{0:.3f}".format(fCenterFreq) + "MHz " + str(fAmplitudeDBM) + "dBm")
3235

Examples_IOT/RFE_Example_IoT_2.py

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import time
1414
import RFExplorer
15+
from RFExplorer import RFE_Common
16+
import math
1517

1618
#---------------------------------------------------------
1719
# Helper functions
@@ -22,11 +24,12 @@ def PrintPeak(objAnalazyer):
2224
"""
2325
nIndex = objAnalazyer.SweepData.Count-1
2426
objSweepTemp = objAnalazyer.SweepData.GetData(nIndex)
25-
nStep = objSweepTemp.GetPeakStep() #Get index of the peak
27+
nStep = objSweepTemp.GetPeakDataPoint() #Get index of the peak
2628
fAmplitudeDBM = objSweepTemp.GetAmplitude_DBM(nStep) #Get amplitude of the peak
2729
fCenterFreq = objSweepTemp.GetFrequencyMHZ(nStep) #Get frequency of the peak
30+
fCenterFreq = math.floor(fCenterFreq * 10 ** 3) / 10 ** 3 #truncate to 3 decimals
2831

29-
print("Peak: " + "{0:.3f}".format(fCenterFreq) + "MHz " + str(fAmplitudeDBM) + "dBm")
32+
print(" Peak: " + "{0:.3f}".format(fCenterFreq) + "MHz " + str(fAmplitudeDBM) + "dBm")
3033

3134
def ControlSettings(objAnalazyer):
3235
"""This functions check user settings
@@ -106,39 +109,32 @@ def ControlSettings(objAnalazyer):
106109
#Control settings
107110
SpanSize, StartFreq, StopFreq = ControlSettings(objRFE)
108111
if(SpanSize and StartFreq and StopFreq):
109-
#set new frequency range
110-
objRFE.UpdateDeviceConfig(StartFreq, StopFreq)
111-
112-
LastStartFreq = 0
113112
nInd = 0
114-
while (StopFreq<=STOP_SCAN_MHZ and StartFreq < StopFreq):
115-
#Process all received data from device
116-
while (objRFE.SweepData.Count<1):
117-
objRFE.ProcessReceivedString(True)
118-
119-
#Print data if received new sweep and a different start frequency
120-
if(StartFreq != LastStartFreq):
121-
nInd += 1
122-
print("Freq range["+ str(nInd) + "]: " + str(StartFreq) +" - "+ str(StopFreq) + "MHz" )
123-
PrintPeak(objRFE)
124-
LastFreqStart = StartFreq
125-
113+
while (True):
114+
#Set new configuration into device
115+
objRFE.UpdateDeviceConfig(StartFreq, StopFreq)
116+
117+
objSweep=None
118+
#Wait for new configuration to arrive (as it will clean up old sweep data)
119+
while(True):
120+
objRFE.ProcessReceivedString(True);
121+
if (objRFE.SweepData.Count>0):
122+
objSweep=objRFE.SweepData.GetData(objRFE.SweepData.Count-1)
123+
124+
nInd += 1
125+
print("Freq range["+ str(nInd) + "]: " + str(StartFreq) +" - "+ str(StopFreq) + "MHz" )
126+
PrintPeak(objRFE)
127+
if(math.fabs(objRFE.StartFrequencyMHZ - StartFreq) <= 0.001):
128+
break
129+
126130
#set new frequency range
127131
StartFreq = StopFreq
128132
StopFreq = StartFreq + SpanSize
129-
130-
#Maximum stop/start frequency control
131133
if (StopFreq > STOP_SCAN_MHZ):
132134
StopFreq = STOP_SCAN_MHZ
133-
if (StartFreq < StopFreq):
134-
objRFE.UpdateDeviceConfig(StartFreq, StopFreq)
135-
136-
#Wait for new configuration to arrive (as it will clean up old sweep data)
137-
objSweep=None
138-
while ((objSweep is None) or objSweep.StartFrequencyMHZ!=StartFreq):
139-
objRFE.ProcessReceivedString(True)
140-
if (objRFE.SweepData.Count>0):
141-
objSweep=objRFE.SweepData.GetData(objRFE.SweepData.Count-1)
135+
136+
if (StartFreq >= StopFreq):
137+
break
142138
else:
143139
print("Error: settings are wrong.\nPlease, change and try again")
144140
else:

Examples_USB/RFE_Example_USB_1.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import time
1515
from datetime import datetime, timedelta
1616
import RFExplorer
17+
from RFExplorer import RFE_Common
18+
import math
1719

1820
#---------------------------------------------------------
1921
# Helper functions
@@ -24,9 +26,10 @@ def PrintPeak(objAnalazyer):
2426
"""
2527
nIndex = objAnalazyer.SweepData.Count-1
2628
objSweepTemp = objAnalazyer.SweepData.GetData(nIndex)
27-
nStep = objSweepTemp.GetPeakStep() #Get index of the peak
29+
nStep = objSweepTemp.GetPeakDataPoint() #Get index of the peak
2830
fAmplitudeDBM = objSweepTemp.GetAmplitude_DBM(nStep) #Get amplitude of the peak
2931
fCenterFreq = objSweepTemp.GetFrequencyMHZ(nStep) #Get frequency of the peak
32+
fCenterFreq = math.floor(fCenterFreq * 10 ** 3) / 10 ** 3 #truncate to 3 decimals
3033

3134
print("Sweep[" + str(nIndex)+"]: Peak: " + "{0:.3f}".format(fCenterFreq) + "MHz " + str(fAmplitudeDBM) + "dBm")
3235

@@ -50,13 +53,14 @@ def PrintPeak(objAnalazyer):
5053

5154
#Connect to available port
5255
if (objRFE.ConnectPort(SERIALPORT, BAUDRATE)):
56+
print("Reseting device...")
5357
#Reset the unit to start fresh
5458
objRFE.SendCommand("r")
5559
#Wait for unit to notify reset completed
5660
while(objRFE.IsResetEvent):
5761
pass
5862
#Wait for unit to stabilize
59-
time.sleep(3)
63+
time.sleep(8)
6064

6165
#Request RF Explorer configuration
6266
objRFE.SendCommand_RequestConfigData()
@@ -65,8 +69,10 @@ def PrintPeak(objAnalazyer):
6569
objRFE.ProcessReceivedString(True) #Process the received configuration
6670

6771
#If object is an analyzer, we can scan for received sweeps
68-
if (objRFE.IsAnalyzer()):
72+
if (objRFE.IsAnalyzer()):
73+
print("---- Spectrum Analyzer Example ----")
6974
print("Receiving data...")
75+
objRFE.SweepData.CleanAll()
7076
#Process until we complete scan time
7177
nLastDisplayIndex=0
7278
startTime=datetime.now()
@@ -78,7 +84,21 @@ def PrintPeak(objAnalazyer):
7884
PrintPeak(objRFE)
7985
nLastDisplayIndex=objRFE.SweepData.Count
8086
else:
81-
print("Error: Device connected is a Signal Generator. \nPlease, connect a Spectrum Analyzer")
87+
print("---- Signal Generator Example ----")
88+
objRFE.RFGenCWFrequencyMHZ = 500;
89+
if(objRFE.ExpansionBoardActive):
90+
objRFE.RFGenExpansionPowerDBM = -40
91+
print("CW setting: " + str(objRFE.RFGenExpansionPowerDBM) + " dBm at " + str(objRFE.RFGenCWFrequencyMHZ) + " MHz")
92+
else:
93+
objRFE.RFGenPowerLevel = 0 #low power setting
94+
objRFE.RFGenHighPowerSwitch = False
95+
print("CW setting: " + str(objRFE.GetSignalGeneratorEstimatedAmplitude(objRFE.RFGenCWFrequencyMHZ)) + "dBm" + " at " + str(objRFE.RFGenCWFrequencyMHZ) + " MHz")
96+
97+
print("CW power ON")
98+
objRFE.SendCommand_GeneratorCW()
99+
time.sleep(5)
100+
print("CW power OFF")
101+
objRFE.SendCommand_GeneratorRFPowerOFF()
82102
else:
83103
print("Not Connected")
84104
except Exception as obEx:

Examples_USB/RFE_Example_USB_2.py

Lines changed: 105 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import time
1414
import RFExplorer
15+
from RFExplorer import RFE_Common
16+
import math
1517

1618
#---------------------------------------------------------
1719
# Helper functions
@@ -22,11 +24,12 @@ def PrintPeak(objAnalazyer):
2224
"""
2325
nIndex = objAnalazyer.SweepData.Count-1
2426
objSweepTemp = objAnalazyer.SweepData.GetData(nIndex)
25-
nStep = objSweepTemp.GetPeakStep() #Get index of the peak
27+
nStep = objSweepTemp.GetPeakDataPoint() #Get index of the peak
2628
fAmplitudeDBM = objSweepTemp.GetAmplitude_DBM(nStep) #Get amplitude of the peak
2729
fCenterFreq = objSweepTemp.GetFrequencyMHZ(nStep) #Get frequency of the peak
30+
fCenterFreq = math.floor(fCenterFreq * 10 ** 3) / 10 ** 3 #truncate to 3 decimals
2831

29-
print("Peak: " + "{0:.3f}".format(fCenterFreq) + "MHz " + str(fAmplitudeDBM) + "dBm")
32+
print(" Peak: " + "{0:.3f}".format(fCenterFreq) + "MHz " + str(fAmplitudeDBM) + "dBm")
3033

3134
def ControlSettings(objAnalazyer):
3235
"""This functions check user settings
@@ -72,7 +75,12 @@ def ControlSettings(objAnalazyer):
7275

7376
objRFE = RFExplorer.RFECommunicator() #Initialize object and thread
7477
objRFE.AutoConfigure = False
75-
SPAN_SIZE_MHZ = 100 #Initialize settings
78+
79+
#These values can be limited by specific RF Explorer Spectrum Analyzer model.
80+
#Check RFE SA Comparation chart from www.rf-explorer.com\models to know what
81+
#frequency setting are available for your model
82+
#These freq settings will be updated later in SA condition.
83+
SPAN_SIZE_MHZ = 50 #Initialize settings
7684
START_SCAN_MHZ = 500
7785
STOP_SCAN_MHZ = 900
7886

@@ -86,62 +94,126 @@ def ControlSettings(objAnalazyer):
8694

8795
#Connect to available port
8896
if (objRFE.ConnectPort(SERIALPORT, BAUDRATE)):
97+
print("Reseting device...")
8998
#Reset the unit to start fresh
9099
objRFE.SendCommand("r")
91100
#Wait for unit to notify reset completed
92101
while(objRFE.IsResetEvent):
93102
pass
94103
#Wait for unit to stabilize
95-
time.sleep(3)
104+
time.sleep(8)
96105

97106
#Request RF Explorer configuration
98107
objRFE.SendCommand_RequestConfigData()
108+
99109
#Wait to receive configuration and model details
100110
while(objRFE.ActiveModel == RFExplorer.RFE_Common.eModel.MODEL_NONE):
101111
objRFE.ProcessReceivedString(True) #Process the received configuration
102-
112+
103113
#If object is an analyzer, we can scan for received sweeps
104114
if(objRFE.IsAnalyzer()):
115+
print("---- Spectrum Analyzer Example ----")
116+
#update frequency setting. This was added to be compatible with all RFE SA models
117+
START_SCAN_MHZ = objRFE.MinFreqMHZ
118+
STOP_SCAN_MHZ = START_SCAN_MHZ + 200
119+
#SPAN_SIZE_MHZ = 50 is the minimum span available for RF Explorer SA models
120+
105121
#Control settings
106122
SpanSize, StartFreq, StopFreq = ControlSettings(objRFE)
107123
if(SpanSize and StartFreq and StopFreq):
108-
#set new frequency range
109-
objRFE.UpdateDeviceConfig(StartFreq, StopFreq)
110-
111-
LastStartFreq = 0
112124
nInd = 0
113-
while (StopFreq<=STOP_SCAN_MHZ and StartFreq < StopFreq):
114-
#Process all received data from device
115-
while (objRFE.SweepData.Count<1):
116-
objRFE.ProcessReceivedString(True)
117-
118-
#Print data if received new sweep and a different start frequency
119-
if(StartFreq != LastStartFreq):
120-
nInd += 1
121-
print("Freq range["+ str(nInd) + "]: " + str(StartFreq) +" - "+ str(StopFreq) + "MHz" )
122-
PrintPeak(objRFE)
123-
LastFreqStart = StartFreq
124-
125+
while (True):
126+
#Set new configuration into device
127+
objRFE.UpdateDeviceConfig(StartFreq, StopFreq)
128+
129+
objSweep=None
130+
#Wait for new configuration to arrive (as it will clean up old sweep data)
131+
while(True):
132+
objRFE.ProcessReceivedString(True);
133+
if (objRFE.SweepData.Count>0):
134+
objSweep=objRFE.SweepData.GetData(objRFE.SweepData.Count-1)
135+
136+
nInd += 1
137+
print("Freq range["+ str(nInd) + "]: " + str(StartFreq) +" - "+ str(StopFreq) + "MHz" )
138+
PrintPeak(objRFE)
139+
if(math.fabs(objRFE.StartFrequencyMHZ - StartFreq) <= 0.001):
140+
break
141+
125142
#set new frequency range
126143
StartFreq = StopFreq
127144
StopFreq = StartFreq + SpanSize
128-
129-
#Maximum stop/start frequency control
130145
if (StopFreq > STOP_SCAN_MHZ):
131146
StopFreq = STOP_SCAN_MHZ
132-
if (StartFreq < StopFreq):
133-
objRFE.UpdateDeviceConfig(StartFreq, StopFreq)
134-
135-
#Wait for new configuration to arrive (as it will clean up old sweep data)
136-
objSweep=None
137-
while ((objSweep is None) or objSweep.StartFrequencyMHZ!=StartFreq):
138-
objRFE.ProcessReceivedString(True)
139-
if (objRFE.SweepData.Count>0):
140-
objSweep=objRFE.SweepData.GetData(objRFE.SweepData.Count-1)
147+
148+
if (StartFreq >= StopFreq):
149+
break
141150
else:
142151
print("Error: settings are wrong.\nPlease, change and try again")
143152
else:
144-
print("Error: Device connected is a Signal Generator. \nPlease, connect a Spectrum Analyzer")
153+
print("---- Signal Generator Example ----")
154+
#request internal calibration data, if available
155+
objRFE.SendCommand("Cq")
156+
objRFE6GENCal = objRFE.GetRFE6GENCal() #Object to manage the calibration data from generator
157+
while (objRFE6GENCal.GetCalSize() < 0):
158+
objRFE.ProcessReceivedString(True) #Process the received configuration
159+
160+
objRFE.RFGenCWFrequencyMHZ = 500;
161+
if(objRFE.ExpansionBoardActive):
162+
#Amplitude sweep
163+
objRFE.RFGenExpansionPowerDBM = -40
164+
objRFE.RFGenExpansionPowerStartDBM = -40
165+
objRFE.RFGenExpansionPowerStepDB = 5
166+
objRFE.RFGenExpansionPowerStopDBM = -20
167+
objRFE.RFGenStepWaitMS = 500
168+
sStartDBM = str(objRFE.RFGenExpansionPowerStartDBM)
169+
sStopDBM = str(objRFE.RFGenExpansionPowerStopDBM)
170+
sSteps = str(objRFE.RFGenExpansionPowerStepDB)
171+
else:
172+
objRFE.RFGenStartHighPowerSwitch = False
173+
objRFE.RFGenStopHighPowerSwitch = True
174+
objRFE.RFGenStartPowerLevel = 0
175+
objRFE.RFGenStopPowerLevel = 3
176+
objRFE.RFGenSweepSteps = 5
177+
objRFE.RFGenStepWaitMS = 500
178+
arrAmplitudeDBM = objRFE6GENCal.GetEstimatedAmplitudeArray(objRFE.RFGenCWFrequencyMHZ)
179+
sStartDBM = str(arrAmplitudeDBM[0]) #min
180+
sStopDBM = str(arrAmplitudeDBM[len(arrAmplitudeDBM) - 1]) #max
181+
sSteps = str(objRFE.RFGenSweepSteps)
182+
183+
184+
print("Amplitude Sweep Settings = Start:" + sStartDBM + "dBm" + " - Stop:" + sStopDBM + "dBm" +
185+
" - Steps:" + sSteps + " - Delay:" + str(objRFE.RFGenStepWaitMS) + "ms" + " - CW:" + str(objRFE.RFGenCWFrequencyMHZ) + "MHz")
186+
187+
print("Amplitude sweep ON")
188+
objRFE.SendCommand_GeneratorSweepAmplitude()
189+
time.sleep(5)
190+
objRFE.SendCommand_GeneratorRFPowerOFF()
191+
print("Amplitude sweep OFF")
192+
193+
time.sleep(2)
194+
195+
#Frequency sweep
196+
if(objRFE.ExpansionBoardActive):
197+
objRFE.RFGenExpansionPowerDBM = -40
198+
sPowerDBM = " - Power:" + str(objRFE.RFGenExpansionPowerDBM) + "dBm"
199+
else:
200+
objRFE.RFGenHighPowerSwitch = False
201+
objRFE.RFGenPowerLevel = 0
202+
sPowerDBM = " - Power:" + str(objRFE.GetSignalGeneratorEstimatedAmplitude(objRFE.RFGenCWFrequencyMHZ)) + "dBm"
203+
objRFE.RFGenStartFrequencyMHZ = 495.0
204+
objRFE.RFGenStopFrequencyMHZ = 505.0
205+
objRFE.RFGenExpansionPowerDBM = -40.0
206+
objRFE.RFGenSweepSteps = 11
207+
objRFE.RFGenStepWaitMS = 500
208+
209+
print("Frequency Sweep Settings = Start:" + str(objRFE.StartFrequencyMHZ) + "MHz" + " - Stop:" + str(objRFE.StopFrequencyMHZ) + "MHz" +
210+
" - Steps:" + str(objRFE.RFGenSweepSteps) + " - Delay:" + str(objRFE.RFGenStepWaitMS) + "ms" + sPowerDBM)
211+
212+
print("Frequency sweep ON")
213+
objRFE.SendCommand_GeneratorSweepFreq()
214+
time.sleep(5)
215+
objRFE.SendCommand_GeneratorRFPowerOFF()
216+
print("Frequency sweep OFF")
145217
else:
146218
print("Not Connected")
147219
except Exception as obEx:

Examples_USB/RFE_Example_control.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def PrintPeak(objAnalazyer):
3131
"""
3232
nIndex = objAnalazyer.SweepData.Count-1
3333
objSweepTemp = objAnalazyer.SweepData.GetData(nIndex)
34-
nStep = objSweepTemp.GetPeakStep() #Get index of the peak
34+
nStep = objSweepTemp.GetPeakDataPoint() #Get index of the peak
3535
fAmplitudeDBM = objSweepTemp.GetAmplitude_DBM(nStep) #Get amplitude of the peak
3636
fCenterFreq = objSweepTemp.GetFrequencyMHZ(nStep) #Get frequency of the peak
3737

RFExplorer/RFE6GEN_CalibrationData.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#============================================================================
77
#RF Explorer Python Libraries - A Spectrum Analyzer for everyone!
8-
#Copyright © 2010-20 Ariel Rocholl, www.rf-explorer.com
8+
#Copyright © 2010-21 RF Explorer Technologies SL, www.rf-explorer.com
99
#
1010
#This application is free software; you can redistribute it and/or
1111
#modify it under the terms of the GNU Lesser General Public
@@ -417,7 +417,7 @@ def InitializeCal(self, nSize, sLine):
417417
#therefore a -32 value.
418418

419419
for nInd in range(nSize):
420-
self.m_arrSignalGeneratorEmbeddedCalibrationActual30DBM[nInd] = -30.0 + ord(sLine[nInd + 3]) / 10.0
420+
self.m_arrSignalGeneratorEmbeddedCalibrationActual30DBM[nInd] = -30.0 + int(ord(sLine[nInd + 3])) / 10.0
421421
if ((nInd % 16) == 0):
422422
sReport += '\n'
423423
sReport += '{:04.1f}'.format(self.m_arrSignalGeneratorEmbeddedCalibrationActual30DBM[nInd])

0 commit comments

Comments
 (0)