Saturday, 17 March 2018

Hantek 6022BE on Lubuntu 17.10: OpenHantek

My Hantek USB oscilloscope was supplied with Windows software, but how can I run it on Linux?


There are a couple of FOSS options for Linux including OpenHantek and Sigrok.


I have tried both Sigrok (with pulseview) and OpenHantek, but I much prefer OpenHantek.

The Hantek 6022BE is a nice, low cost, 20MHz bandwidth scope module that runs via USB connection on a computer. I've seen plenty of reviews where the reviewer condemns this device as "rubbish". These are typically by people that already have proper free-standing oscilloscopes costing hundreds of pounds.

The strength of the Hantek is that it is cheap, but still very useful when used as a visual diagnostic aid on low voltage electronics projects. Naturally it is not as good as a proper, free standing oscilloscope. But many hobbyists either can't afford a full oscilloscope, or can't justify the cost for a piece of test equipment that may only be used once or twice a year.

Since the Hantek is powered from a computers USB ports (it uses 2 sockets in order to meet the power requirements) I certainly would not try to use it on any equipment containing high voltages. The BNC input connectors are labelled "35V max". Most of my projects run well below 24Volts.

So rubbish, it is not!

Installation method


These are my notes from installing OpenHantek on Lubuntu.

Install required stuff via a terminal:-

sudo apt install g++ cmake qttools5-dev qttools5-dev-tools libfftw3-dev binutils-dev libusb-1.0-0-dev libqt5opengl5-dev mesa-common-dev libgl1-mesa-dev libgles2-mesa-dev

Download OpenHantek from Git to get the latest master copy:  https://github.com/OpenHantek/openhantek

Using file manager, extract files by right-clicking on the tar.gz file, and select Extract Here

Navigate to new uncompressed folder: .../openhantek-master

Right-click to create a new folder: build

Navigate into  .../build  folder and hit F4, to open a terminal at this location, then type in terminal:-

cmake ../

...(note the space after cmake) and then:-

make -j2


...and then:-

sudo make install

Now connect your Hantek scope via the two USB cables to your computer and type in a terminal;

OpenHantek

You should see the "Select Device" dialog. If the firmware does not load within a few seconds, cancel and then type:-

sudo OpenHantek

I had to navigate to: /lib/udev/rules.d/60-hantek.rules and change ownership from root to the current user.

Note: the output of command  lsusb  
- before OpenHantek firmware is loaded: ID 04b4:6022 Cypress Semiconductor Corp  
- OpenHantek successfully loaded: ID 04b5:6022 ROHM LSI Systems USA, LLC

I created a Hantek.desktop launcher file with the following contents:-

[Desktop Entry]
Version=1.0
Name=OpenHantek
Comment=Oscilloscope
GenericName=Oscilloscope
Exec=OpenHantek
Icon=/usr/share/pixmaps/digitalphosphor.png
Terminal=false
Type=Application
Categories=System;Utility;
StartupNotify=true

Note: obviously you need to enter a path to a real icon location (I copied this icon into pixmaps).

Save this file in: /usr/share/applications for access from your menu, or save to desktop to launch from there.

operation


The first problem was that the display appeared to be too high for my screen. If I grab-and-drag the window, only the width changed. After a lot of fiddling around I realised that the control panels were dockable. I dragged each one to the left hand side of the screen and they magically became tabbed.


When I recently installed a newer version on another laptop, I didn't seem to have layout problems. So maybe this has been fixed, or my second laptop has a more favourable screen size.

There was also a bug with the Timebase and Samplerate settings, but this has now been fixed.

On first use, I connected a probe to the Hantek 1kHz test point, set the Trigger Mode to Hard-/Software and then pressed the Run arrow.

To move a channel trace up or down, just click and drag on either CH1 or CH2 on the Y axis. Trigger level is set in a similar way via the coloured arrows on the right of the trace.

My main problem when running on my old ASUS laptop, is that OpenHantek seems to run the processor pretty hard, and the cpu temperature rises to a dangerously high temperature of 95'C.

However, it seems to run OK on my newer Entroware laptop, with the temperature running less than 60'C and cpu loaded to about 65%. I can hear the cpu fan throttle up after a while, so I will need to keep an eye on this.

I can't imagine that OpenHantek runs very happily on a Raspberry Pi, but if I get time, I'll give it a go.

I do like the 'zoom' mode;



Select Zoom from the View menu, then drag the vertical markers (1 & 2) to set the zoom range. You can drag the red marker (shown in the top left corner in the above illustration) to move through the sample buffer.


With Spectrum enabled, I fed the scope with a 20kHz sine wave.
scope waveform + spectrum display


The Frequencybase was set to 10kHz/div, so the 20kHz fundamental appears 2 divisions from left. The minor pulses are harmonics and other spurious signals.

 

Edit January 2021

 

The OpenHantek project is no longer maintained, but the code is stable and still works absolutely fine.

However, you may be interested in a forked version of this project called OpenHantek 6022:-

 https://captainbodgit.blogspot.com/2021/01/hantek-6022be-on-peppermint-10.html

 ...which has a few more features as is currently an active project.




8 comments:

  1. Hi Steve - funnily enough I'd just installed Lubuntu on my old workbench Samsung NC10 and have been setting up OpenHantek on it. Thanks for the post. Just a note for anyone who gets a message in OH about their system not supporting OpenGL 1.5 - try instead running (or amending your shortcut to) OpenHantek --useGLES

    ReplyDelete
  2. Thanks for the very in-depth tutorial. Unfortunately I have a problem when trying to follow it to install OpenHantek on Raspberry 3 B+, with Raspbian (I can't get Lubuntu to boot on 3B+). When I run "cmake ../" I get errors, I think the main one is "Looking for pthread_create in pthreads - not found". Could you help me fix this problem?

    ReplyDelete
    Replies
    1. I'm sorry I haven't tried this on the Pi.

      Take a look at Git and see if there is already an open issue. If not, post one and they should be able to help you:-
      https://github.com/OpenHantek/openhantek/issues

      Delete
  3. Thank you so much for this excellent walkthrough. I was having quite a time getting this to build you saved me hours of headscratching and taught me a good bit about working with cmake.

    ReplyDelete
  4. I would also like to thank you very much for making this walk through available. I am a Linux beginner and have failed a few times before to try to compile this by myself. I did however have a similar issue as the top poster but was able to fix it using the --useGLES suffix. I appreciate all your work.

    ReplyDelete
  5. Thank you very much for giving this information. But after installation I have got and error while opening the port as follows,

    OpenHantek: symbol lookup error: OpenHantek: undefined symbol: libusb_get_port_numbers

    i am using ubuntu 16.04

    If you have an idea.... please advice

    Thanks

    ReplyDelete
  6. If you are using Ubuntu linux then you can just run

    snap install openhantek
    snap connect openhantek:raw-usb

    This will install the snap version of openhantek

    ReplyDelete