Hacking a $100 Signal Generator

Signal generators are a useful piece of kit to have on your electronics bench. The downside is that they tend to be rather expensive. If you have $100 to drop on a new toy, the MHS-5200A is a low cost, two channel, 25 MHz generator that can be found on eBay.

The downside is the software. It’s an ugly Windows interface that’s a pain to use. The good news is that [wd5gnr] reverse engineered the protocol so you don’t have to. This means other software can be developed to control the device.

When connected to a computer, this function generator shows up as a virtual USB serial port. The documentation that [wd5gnr] assembled lists all the serial commands you can send, and what they do. If you aren’t into manually setting waveforms from a serial terminal (who is?) there’s a tool for doing that automatically on Github. This takes in a CSV file describing a waveform, and programs the generator to make it for you.

The software is also compatible with Waveform Manager Plus, a free GUI tool for defining waveforms. Putting this all together, you can have a pretty capable waveform generator for less than $100.

23 thoughts on “Hacking a $100 Signal Generator

        1. I wonder what the internal differences (if any) are between the different models. Whether there is a difference in hardware or whether the different speeds are mediated by firmware a la Rigol oscilloscope.

          1. I can only find a Chinese spec on Taobao, but it looks like the 25 MHz version is sine wave only above 6 MHz. So I might guess the higher frequency models have more filtering? I wish I could find a decent spec-sheet and/or review of this thing. Where I live I would have to pay around 50% of the purchase price additional to actually get the thing because of taxes, duties, handling charges, etc. So I’m looking at around $120_$140 all-in. Pricey for a Chinese crap-shoot.

    1. That’s exactly the question I was going to ask. How’s cleanliness of the sine, how well low-pass filtered is the output?

      Having a look at http://www.ebay.com/itm/6-25MHZ-DDS-Dual-Channel-waveform-signal-generator-frequency-meter-signal-source-/181755288378?pt=LH_DefaultDomain_0&var=&hash=item2a51759b3a

      The picture that says “sine 5Vpp” below it shows an oscilloscope clearly displaying it 5.2Vpp, which is an error of 4%, which can be O.K. for most applications.

      The spec sheet on that ebay site says 5ppm frequency accuracy. That seriously underjoys me, but then again, exactly the oscillator you can pay for. Sadly, that same spec sheet says 1% amplitude error, whilst we saw 4% in a photograph, so I’m not convinced that one should be trusted.

      Now, assuming the technological (not physical) details in that spec sheet are right, namely that the device has an 8bit DAC (giving us a max SNR of 1.76dB + (6*8)dB= 49.76dB due to quantization) running at 200MS/s, we can deduct that a) for that price, they didn’t design circuitry to actually push 200MB/s from the CPU to the DAC and b) considering that the more costly variant has a max 25MHz sine-only output, I’d say there’s been some optimization for the sine case, and the device can keep up 50MS/s from CPU to DAC. That’s pretty fine. Assuming there’s a grain of truth in the 200MS/s that they claim: They’re probably using an internally interpolating anti-imaging DAC that promises good spectrum up to 100MHz (f_DAC/2, Nyquist is your friend).

      Now, DDS is nice, but has some shortcomings (compared to other synthesizer architectures), so I’m always a bit confused when Hams think the right thing to create a digital oscillator would clearly be DDS. DDS with fixed precision indexing will always suffer under the fact that frequencies that can’t be represented as a fraction of the DAC rate, within the accuracy offered by the length of the DDS lookup table, have spurs. Now, 1024 entries in that DDS table (spec sheet) isn’t all that much — again, assume f_sample=50MS/s and f_sine = 1kHz; you’ll see that it should take 1ms to traverse through that table, or 50k samples. that table is only 1024 values long, Meaning that most values are repeated 50 times; a “PWM” approach with an appropriate low-pass filter might fix the resulting step-y response with its less-than-nice spectral properties, but that’s typically much more complicated to implement (it has switchable hardware filters! so complicated to do right! So expensive to get good filters!) than just not using DDS in the first place but going for CORDICS and the like.

    2. The cheap one probably uses on-chip Sine table for the sine wave output while the more expensive one has some external RAM based lookup table.
      The 1% error might be just for the chip, but it might be as high as 4% when you look at the errors at the system level – resistors in external buffer/amplifier, power supply/reference, temperature extremes, long term drifts etc.

  1. the specs list only higher than 6MHz for “sine wave” in the 3 “top” models,
    all wave forms are speced at 6MHz
    so it seams they add in the more expensive ones some kind of additional ( hardware?) sine wave generator.

  2. So would any of you recommend this to a hobbyist/Ham as a first generator? I need something to build filters, test inductors, etc. I will likely find many more uses in the future but as a first piece of equipment of this sort – is it worth it?

  3. Hi, I’m running a window 10 computer, when I try to run setwave5200 COM5 test.csv 15 in the command prompt, window says it it’s not an internal or external command. I made sure that the files are in my working directory. Thank you.

    1. You need to install a reader program to read csv (comma separated values) file, such as notepad, or better, a spreadsheet program (as included with libre office.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.