Controlling a FeelTech function generator with a computer: issues and fixes

Controlling a FeelTech function generator with a computer: issues and fixes

The FeelTech/FeelElec arbitrary waveform generators are cool, inexpensive, signal sources that provide a whole lot of functionality, and work well from low frequencies up to tens of megahertz. But, boy, do I hate twiddling with buttons, changing settings a single digit at a time.

The answer–for test harnesses, remote control and just plain ease of use–is computer control.

One of the reasons I settled on the FeelTech devices, beyond the specs, price and all the reviews, is the fygen library, by Matt Wach. The function generators use a simple serial API to control them via USB, and fygen lets you use that from Python–cool!

FeelTech FY2320 and signal on oscilloscope

When I got around to installing the lib and trying it out, hilarity ensued.

Hm, non responsive… So I went through a process of discovery/debugging and realized that:

  • The FY2300-20M/FY2320, unlike other FY series devices it seems, operates at 9600bps
  • It doesn’t always terminate its responses with newlines and sometimes doesn’t care to respond at all
FY2320 v3.4

This broke a few assumptions in the fygen library, hence the lack of functionality.

I have the 20MHz version of the FY2300, which the v3.4 firmware describes as the FY2320 model, and its the only one I have to play with, so I don’t know how widespread this problem is, if it’s just a firmware or model issue or what… Still, I haven’t had this thing for too long, so it may well be that others are also in this position.

After playing around in the code (thank you open source and thank you Matt), I managed to get computer control working (probably/hopefully without disturbing the existing functionality), namely by:

  • Adding a few parameters to the constructor, to allow for setting the baudrate and indicating we shouldn’t expect newlines everywhere;
  • Making the distinction between queries (reads) and commands (possibly one-way communications) explicit; and
  • enhancing the _recv() method to deal with non-newline-terminated responses.

So far, I’ve only tested this with the FY2320 and Python3 so buyer beware… but if you have the ‘2320 or another FY23XX that operates at 9600bps, download this library or get my github fork of the project (just note that you have to checkout the fy2320v3p4 branch to see the changes). With it you can then

import fygen
# construct, using new parameters
fy = fygen.FYGen('/dev/ttyUSB0', 
      debug_level=1, 
      baudrate=9600,   # required for my FY2320
      unterminated_responses=True, # required for my FY2320
      read_before_write=False) # optional
# reads are slower than writes, in this case
# which is why I set read_before_write=False


# then do all the things
fy.set(channel=fygen.CH1, enable=True, 
       wave='sin', freq_hz=2e6, volts=2.5)

fy.set_sweep(mode=fygen.SWEEP_FREQUENCY, 
       start_freq_hz=1000, 
        end_freq_hz=12000, time_seconds=5)


fy.force_sweep_enable=True # may be required...
fy.set_sweep(enable=True)

# etc.

You can get more info and briefly see it in action, here

Hopefully, this will let you work with your Feeltech waveform generator too. Comments, questions or enhancements welcome, here or through github. Enjoy.

Library Source/Downloads