Author Topic: MHS-5200A Serial Protocol Reverse Engineered  (Read 55712 times)

0 Members and 2 Guests are viewing this topic.

Offline wd5gnrTopic starter

  • Regular Contributor
  • *
  • Posts: 179
MHS-5200A Serial Protocol Reverse Engineered
« on: June 27, 2015, 08:57:39 pm »
I picked up an MHS-5200A DDS Signal Generator for about US$80 on eBay. The Windows software is horrible, plus it is in Windows. Would probably work in Wine, but I can't get NI-VISA to install in Wine and don't really care.

So here's the basic serial protocol for the device (it looks like a COM port): https://docs.google.com/document/d/1HbLQ4u87RJkD3Ktyw7k9U7Zh5BPNzbrhMlszNGdXiiY/edit?usp=sharing

I missed one or two, but all I really want it to shove the arbitrary buffers in. I don't even care about a GUI, to be honest so.... that will be my next post is my solution for that ;-)

Here's what I know so far. Corrections or comments welcome.

https://docs.google.com/document/d/1HbLQ4u87RJkD3Ktyw7k9U7Zh5BPNzbrhMlszNGdXiiY/edit?usp=sharing

By the way, the software is listed as for the 5200 or the 3200 but a different document on the 3200 shows a pretty different protocol so the software must adapt.


 

Offline wd5gnrTopic starter

  • Regular Contributor
  • *
  • Posts: 179
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #1 on: June 28, 2015, 03:19:01 am »
Ok after a busy day, here you go:
https://github.com/wd5gnr/mhs5200a



I didn't bother trying to operate the instrument from the software (although you can), I only care about loading the arbitrary waveform memories.
 
The following users thanked this post: Bravo

Offline Muxr

  • Super Contributor
  • ***
  • Posts: 1369
  • Country: us
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #2 on: June 28, 2015, 06:26:04 am »
Nice, I should give this a try on my MHS-3225. Wonder if they are compatible. Just re-read your first post, and noticed the protocol is different.
 

Offline wd5gnrTopic starter

  • Regular Contributor
  • *
  • Posts: 179
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #3 on: June 28, 2015, 01:05:11 pm »
Yup. In addition, I have a bug somewhere. It only works when I have the port open with some test software. I am trying to fix that this morning. Worse case, I'll rewrite in C.

Ok, fixed and enhanced. I have a few more pushes today and then hopefully done at least for now.
« Last Edit: June 28, 2015, 02:06:32 pm by wd5gnr »
 

Offline wd5gnrTopic starter

  • Regular Contributor
  • *
  • Posts: 179
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #4 on: June 28, 2015, 04:23:07 pm »
If you can't stand not having a GUI, I found the TTI Waveform Manager Plus runs well under Wine and is free to download (registration required). If you export to "normalized" you can import to the MHS5200A by using the -f flag to the software I provide. Here's some screen shots:

The app:



The scope showing the uploaded wave from the signal generator:


The TTI app is at http://tti1.co.uk/downloads/waveman-plus.htm
 

Offline Polossatik

  • Frequent Contributor
  • **
  • Posts: 295
  • Country: be
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #5 on: July 02, 2015, 08:43:08 am »
the specs I found on ebay list only higher than 6MHz for “sine wave” in the 3 “top” models (12/20/25 MHz),
all other wave forms are speced at 6MHz


Care to open up and have a look if the difference is pure in firmware or they add in the more expensive ones some kind of additional ( hardware?) sine wave generator.
? :)
Real Circuit design time in minutes= (2 + Nscopes) Testim + (40 +120 Kbrewski) Nfriends

Testim = estimated time in minutes Nscopes= number of oscilloscopes present Kbrewski = linear approx of the nonlinear beer effect Nfriends = number of circuit design friends present
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8515
  • Country: us
    • SiliconValleyGarage
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #6 on: July 02, 2015, 10:00:06 am »
Teardown !
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline wd5gnrTopic starter

  • Regular Contributor
  • *
  • Posts: 179
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #7 on: July 02, 2015, 03:01:59 pm »
Yes it is on my list, although the cost difference between the units is pretty small so I just got the 25MHz one. I think the span is about $10 from low to high, but I might be remembering wrong.

What I am currently about 1/2 way done with is a setup that will create a virtual file system (like ~/dds with a subdirectory for each slot. Then it launches waveman or another editor of your choice. You save your wave to (for example) ~/dds/5 and it sends it to the instrument and moves the file to ~/dds/5/sent for future reference. That would make using waveman a lot easier.

Almost done with it and will update github when it is done.
 

Offline wd5gnrTopic starter

  • Regular Contributor
  • *
  • Posts: 179
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #8 on: July 03, 2015, 04:20:36 am »
I just posted a draft version of the wavegen script. You WILL have to edit it for your use. Basically, it creates some directories and launches the TTI editor (or any editor). Then you simply save your file in CSV or NRM format into the directory you want and the download happens magically. For example, I save to ~/dds/4 to write to slot 4.
 

Offline wd5gnrTopic starter

  • Regular Contributor
  • *
  • Posts: 179
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #9 on: July 12, 2015, 06:01:20 pm »
Fixed a small bug in the software if you haven't updated lately, you should. Meanwhile, here's the innards of the device:


https://imgur.com/a/dAPBi#0


Here's the first of the 5 pictures:


 

Offline lcltech

  • Newbie
  • Posts: 1
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #10 on: July 13, 2015, 06:29:02 am »
Nice, I should give this a try on my MHS-3225. Wonder if they are compatible. Just re-read your first post, and noticed the protocol is different.

Does anybody know what else is the difference between MHS-3200A and MHS-5200A? The specs are exactly the same.
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3780
  • Country: de
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #11 on: July 20, 2015, 09:12:37 pm »
Teardown !

I have received my 25MHz unit and it is pretty much the same as in the photo. The architecture seems to be an STM8 micro (small TQFP on the right) handling the coms & display, CH340G (upper right TSOP) usb uart bridge deals with the USB part. The signals are produced by a Lattice MachXO2 CPLD/FPGA (large QFT in the center) with 2 8bit resistor DACs (left of it) with some opamps (immediately left of the DAC ladders) and AD603ARs (left from the opams). I didn't remove the heatsink, so not sure what is under it - perhaps some power transistors.

The rest is not very interesting - there are relays to switch the outputs on and off, standard 2 line LCD, encoder knob on a separate board and a boatload of passives. The bottom right of the board is a switching PSU.

It looks fairly well built, actually, especially for the price. I have seen much much worse already.

However, what I would love to get is an English manual. The original is in Chinese, unfortunately. I still haven't figured how to actually use the counter functionality the unit is supposed to have nor how to use the various synchronization inputs, including the TTL inputs and outputs on header in the back.


the specs I found on ebay list only higher than 6MHz for “sine wave” in the 3 “top” models (12/20/25 MHz),
all other wave forms are speced at 6MHz

Care to open up and have a look if the difference is pure in firmware or they add in the more expensive ones some kind of additional ( hardware?) sine wave generator.
? :)

There isn't any separate gen for 25MHz and 6MHz square wave. I have checked the signal on my scope and when set to square wave, the signal starts getting distorted around 1-2MHz and the higher you go, the more sine-like it looks, until you get basically straight sine wave above around 4-5MHz (it might do 6MHz, but I didn't probe it correctly). On the scope it looks like as if there was a heavy low pass filter and the higher harmonics were getting progressively cut from the signal as the frequency was increased. Not sure whether there is a physical low pass filter on the output or whether it is an artifact of the sampling.







 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3780
  • Country: de
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #12 on: July 20, 2015, 09:47:32 pm »
If you can't stand not having a GUI, I found the TTI Waveform Manager Plus runs well under Wine and is free to download (registration required). If you export to "normalized" you can import to the MHS5200A by using the -f flag to the software I provide.

Thanks for this, that software is really pretty good. I have tried your scripts to upload the waveforms to the generator and hats off to your shell scripting :-p

I would probably rather do it using Python or something like that though, shell/awk isn't the best choice for this type of job, not to mention that Python is a bit more portable than the above combo.

BTW, a pro tip for anyone using this generator - record a waveform with a scope, save as CSV, open it using Waveman, clean up and upload to the generator. Bingo, signal reproduced for debugging stuff. Works like a charm!

 

Offline wd5gnrTopic starter

  • Regular Contributor
  • *
  • Posts: 179
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #13 on: July 21, 2015, 04:33:58 am »
I don't have an English manual, but I've worked it all out. You probably figured that what the main buttons do (pgup/dn for the menu). For the counter on the menu look for:

MSR-Sel. Press OK to go external or TTL.
MSR-Mode. Press Ok to select frequency/count/pos pulse width/neg pulse width/period/duty cycle
Gate-Time. Freqency gate


One of the menu items changes depending on your MSR-Mode (the one after Gate time). If it says C it is reading counts.pressing ok pauses. If it says F it is reading frequency. You can probably figure the rest out from there.

 

Offline wd5gnrTopic starter

  • Regular Contributor
  • *
  • Posts: 179
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #14 on: July 21, 2015, 04:34:40 am »
I'm not a big Python fan, but the script works well and with Cygwin actually that is a pretty portable combo too ;-)

 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3780
  • Country: de
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #15 on: July 21, 2015, 08:36:49 am »
I don't have an English manual, but I've worked it all out. You probably figured that what the main buttons do (pgup/dn for the menu). For the counter on the menu look for:

MSR-Sel. Press OK to go external or TTL.
MSR-Mode. Press Ok to select frequency/count/pos pulse width/neg pulse width/period/duty cycle
Gate-Time. Freqency gate


One of the menu items changes depending on your MSR-Mode (the one after Gate time). If it says C it is reading counts.pressing ok pauses. If it says F it is reading frequency. You can probably figure the rest out from there.


Ah ok! Really "obvious"!  :palm:

Jeeze, that user interface was designed by monkeys ...

BTW, any idea how the TTL outputs actually work? There are 8 outputs and in input. I guess the input is for the counter and perhaps to synchronize the frequency sweep, but how to use the outputs?

 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3780
  • Country: de
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #16 on: July 21, 2015, 08:39:36 am »
I'm not a big Python fan, but the script works well and with Cygwin actually that is a pretty portable combo too ;-)

Ouch, Cygwin ...  :o I will probably try to hack a little app up to manage the uploads for this.
 

Offline wd5gnrTopic starter

  • Regular Contributor
  • *
  • Posts: 179
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #17 on: July 21, 2015, 12:09:17 pm »

Ah ok! Really "obvious"!  :palm:

Jeeze, that user interface was designed by monkeys ...

BTW, any idea how the TTL outputs actually work? There are 8 outputs and in input. I guess the input is for the counter and perhaps to synchronize the frequency sweep, but how to use the outputs?

Nope, haven't played with the TTL outputs yet.
 

Offline przemek

  • Newbie
  • Posts: 3
  • Country: us
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #18 on: July 22, 2015, 05:50:40 am »
I compiled an English manual from Google-translated original Chinese text and other sources of information:
https://github.com/przemekklosowski/mhs52xx/raw/master/MHS5200.pdf
 

Offline wd5gnrTopic starter

  • Regular Contributor
  • *
  • Posts: 179
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #19 on: July 22, 2015, 12:06:04 pm »
Awesome! Thank you for doing that!
 

Offline biot

  • Regular Contributor
  • *
  • Posts: 70
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #20 on: July 22, 2015, 03:38:56 pm »
May I suggest sticking some sort of license on that document, at least on the translation and protocol documentation part? Perhaps CC-BY-SA or something like it.

Very nice to see such nice work coming out of a community, in view of the vendor's underwhelming support.
 

Offline przemek

  • Newbie
  • Posts: 3
  • Country: us
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #21 on: July 23, 2015, 02:36:57 am »
Initially I thought the translation will be useful to the manufacturer,  but I pinged them by email and they didn't reply. I then essentially rewrote the thing, so I feel I am entitled to controlling the copyright, and of course I prefer a collaborative license like CC. Will do, although I will have to put this project off for a while now.

By the way, it's written in LyX/LaTeX, and the source is on Github, so you're welcome to clone it and push patches. It uses quite a bit of optional packages/style files, easy to pick up from error messages if you start creating PDFs.
 

Offline przemek

  • Newbie
  • Posts: 3
  • Country: us
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #22 on: July 23, 2015, 02:43:35 am »
By the way, I want a FOSS/Linux program to drive MHS5200. I considered writing a Python/Qt app, but it occurred to me that maybe it could be interfaced to sigrok: it already supports Hantek and Siglent generators. Thoughts?
 

Offline biot

  • Regular Contributor
  • *
  • Posts: 70
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #23 on: July 23, 2015, 09:16:56 am »
By the way, I want a FOSS/Linux program to drive MHS5200. I considered writing a Python/Qt app, but it occurred to me that maybe it could be interfaced to sigrok: it already supports Hantek and Siglent generators. Thoughts?
Alas, sigrok does not support signal generators as an instrument class yet. Those listed on the hardware support page are marked red (planned). You're welcome to take it on.

And you're right, a UI for these just screams Python/Qt.
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3780
  • Country: de
Re: MHS-5200A Serial Protocol Reverse Engineered
« Reply #24 on: July 24, 2015, 09:53:14 am »
I compiled an English manual from Google-translated original Chinese text and other sources of information:
https://github.com/przemekklosowski/mhs52xx/raw/master/MHS5200.pdf

Big kudos for this! This manual looks better than the original, even!

 :-+
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf