Skip to content

Python Example USB 2

Julian edited this page Jun 28, 2021 · 6 revisions

This is a more advanced example of using RF Explorer Spectrum Analyzer or Signal Generator, based on python example 1

The main limitation of Example 1 is the selection of frequency range. In that example used default configuration and not actually selected by specific code.

What it does

In the case a Spectrum Analyzer is connected, this code configures multiple different scan start/stop frequency ranges, iteratively displaying captured peak signal result on each one of them.

The example begins requesting the default configuration of the analyzer, then set it to 500-600MHz scan, gets one sweep and reconfigures for 600-700MHz, etc - repeat up to 900MHz limit, then close.

Note: depending of your RF Explorer device model, may not support this specific frequency range. In that case please update code start/stop range to adapt to your specific model.

In the case a Signal Generator is connected, generates, first, a frequency sweep and then amplitude sweep during 5 seconds each.

How to run it

  • Install Python 3.5 or later, for more details visit www.python.org - there is no need to uninstall other versions of python, as several python versions can live together as long as you call the right one for the examples.
  • Install pySerial
  • Install RFExplorer for Python library
  • Depending on your OS version, you may need to install Silabs CP210x drivers. Most modern Linux distro and Windows version come with it installed, but Mac need specific install. Check Windows and MacOS driver troubleshooting articles.
  • Download the example from GITHUB repository link

Open a terminal or command line in your OS and run

python3.5 RFE6GEN_Example_USB.py

Expected results

As depicted below (using Windows as example), you will get automatic connection to the USB device using a specific COM port name. Other OS will return different port names.

  • Firmware version of the connected RF Explorer device

  • Active connection at 500,000 baud

  • Some information may depend on the specific device connected and firmware version installed

  • Depending on the device connected - Spectrum Analyzer or Signal Generator - the results will be different.

    • Spectrum Analyzer: receiving data scan, for each specific range, displaying amplitude peak captured value for each sweep range.

    • Signal Generator: generating first a amplitude sweep and then a frequency sweep during some seconds with specific power and frequency. Note: you should always run this examples with a 50 ohms load into the active RF connector.

Detailed source code description

Initialization details and basic structure is the same as Example 1.

However, the main difference comes in how the main running loop works: now is not limited by time, but with frequency range limit.

Inside the loop, the call to objRFE.UpdateDeviceConfig(StartFreq, StopFreq) allows the python code to reconfigure scan range of the device.