The Hantek 6022BE Digital Storage Oscilloscope

For the course on embedded systems we need an oscilloscope to be able to see certain signals created by micro-controller code. These signals are have a signal level of either 5V or 3.3V and are rather slow. These means that a rather limited but cheap scope is good enough for us.
The Hantek 6022BE has a sampling rate of 48 MHz or a bandwidth of some 20 MHz. To make things really cheap it uses an USB interface and the display capabilities of a PC to display scope traces and a graphical user interface (GUI) of the PC to control timebase, signal sensitivity and trigger level. Don’t expect features you will get on a 10 kUS$ Textronix scope, you will quickly hit the limitations of the 6022BE, however it should meet the requirements imposed by the course exercises.

Hantek6022be.png


The Hantek 6022BE has 2 DC coupled input channels, a calibration signal generator emitting a square signal and it is delivered with 2 80 MHz probes and a USB cable to connect it to the PC. In addition to this you get a mini CD with Windows software implementing a GUI based control program and a software development kit which allows to implement your own code.
The scope is based on a Cypress CY7C68013A chip, which is essentially a 8051 μ Controller with built in RAM, I2C and USB interface. An external I2C EPROM is used to store USB Vendor and Product ID as well as a few calibration parameters.
When the scope is plugged into the Windows PC a driver is started downloading firmware into the Cypress RAM making it ready for operation. The code is stored in RAM and must therefore re-loaded each time the scope is powered. Once the firmware is loaded the Vendor ID is changed making the scope looks like a different device.

This is how the Windows application looks like:

windowsSoft.png

Channel B is connected to the calibration signal which tells us that this is a 1 kHz square wave.
The horizontal time base can be selected between 1,2,5,10,20,50,100,200,500 ns/division up to
1,2,5 s/division. Of course 1 ns/division is pretty useless on 20 MHz scope.

The vertical sensitivity can be selected from 20 mV to 5V per division.

You can trigger the scope in

  • auto mode
  • normal mode
  • or single shot
and you can trigger on channel A or B and select the trigger slope. The trigger is done purely in software: First data is taken on the scope, then transferred via USB to the PC where the triggering is computed in software.

The scope can run in normal y(t) mode showing the time dependence of the signal or in X/Y mode, where the X axis corresponds to the signal read on the second channel. There are some mathematical functions that can be executed on the signals:

  • channel A + channel B
  • channel A - channel B
  • channel A * channel B
  • channel A / channel B
  • FFT (Fast Fourier Transform) showing the frequency content of the signal
The signal trace can be exported to an ASCII file and re-imported.

Running the Hantek 6022BE under Linux

Just like in the Windows case we must first first load the scope with its firmware. There are different ways to do this:
use udev rules to load the firmware using the fxload program
make the application program load the firmware if it is not loaded yet

When is scope is plugged in without the firmware being loaded it announces itself as a Cypress Semiconductor device with Vendor ID 0x04b4.


lsusb-1.png

This changes to ROHM LSI Systems (a company that probably has nothing to do with this scope) because the Vendor ID has changed to 0x4b5.

lsusb-2.png


When browsing the WEB for information of the Hantek 6022BE under Linux, this is what I found:
Openhantek by Oliver Haag. This is a git repository with software for Hantek scopes. Unfortunately it only supports more expensive scopes from Hantek. Several people have started to implement drivers for the 6022BE but have not come very far (hantek602be support in openhantek). However you will find code there porting the originally QT-4 based openhantek code to Qt-5.
Then there is a driver implementation (hantek driver) which consists of a functions to download the firmware and to set sensitivity and time base and a main program to demonstrate these functions. This also is rather incomplete.
Then there is hantek6022api which is a library of Python code. This however also contains firmware code for the Cypress chip and the author (J. Hoenicke) of this 8051 code has done very interesting reverse engineering figuring out what the USB commands to the scope are and how to use them.
The 8051 code is given as source code as well as disassembled original code from Hantek. It also supplies a program that allows the user to read out the RAM and EPROM contents.
On my dual boot PC I loaded the original Hantek firmware into the scope, then rebooted into Linux and used the example_linux_readfirmware.py included in hantek6022api to extract this code. After disassembly with dis51 I was able to compare the code with the one included as stock firmware in hantek602api to confirm that they are identical.
Cypress, the producer of the CY7C68013A chip provides a the cyusb library and a GUI program showing how to program the chip. This has not much to do with the scope but shows how to download and upload code, reset the CPU, read or write the EEPROM etc.
Finally there is the sigrok repository of software for different types of measurement instruments and the Hantek 6022BE is one of the supported devices (oufff,for once we are lucky). This uses the firmware code of J. Hoenicke. Unfortunately sigrok uses again different Vendor ID and Product ID after loading the firmware. Since we have the source code, I was able to modify this. sigrok also contains a simple GUI application (pulseview) to visualize the traces read from the scope.


pulseview.png

The above screen dump shows the trace read from the Hantek6022be when the probe is connected to the calibration pulse generator.

-- Uli Raich - 2017-01-24

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng Hantek6022be.png r1 manage 1180.6 K 2017-02-09 - 16:32 UnknownUser  
PNGpng lsusb-1.png r1 manage 27.2 K 2017-01-24 - 20:47 UnknownUser lsusb before loading firmware
PNGpng lsusb-2.png r1 manage 34.5 K 2017-01-24 - 20:48 UnknownUser lsusb after loading firmware
PNGpng pulseview.png r1 manage 50.8 K 2017-01-24 - 20:50 UnknownUser pulseview
PNGpng windowsSoft.png r1 manage 104.6 K 2017-02-11 - 11:46 UnknownUser  
Edit | Attach | Watch | Print version | History: r11 | r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r3 - 2017-02-11 - uli
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback