Example Code

Using Hantek 6022 oscilloscope for long term recording and interval high sampling rate recording

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.


  • Oscilloscope Device


  • LabVIEW


  • Hantek 6022

Code and Documents




This example is using Hantek oscilloscope in order to record two voltage channels data and record them in a file less than 10 values per second and also doing quick acquisition at 1MHz sampling rate at constant interval and saving data on local hard disk.


This example is based on SDK - HTMarch.dll Manual VB 6.0 IDE Updated: 16-JAN-2017 Note: HTMarch.dll was compiled under VC++6.0. 

--ONE call to Config AND Acquire, AND Retrieve (and Correct) sample data. [Mark_O, Oct'13]
--returns 0 for failure and non-0 for success.

HTMARCH_API short WIN_API dsoReadHardData(

unsigned short DeviceIndex, // access more than one module

short* pCH1Data, // ptrs to 2 storage buffers
short* pCH2Data,
unsigned long nReadLen, // length of 'reading data'

short* pCalLevel, // ** ptr to calibrationLevel vector (see dsoSetCalLevel); input?

int nCH1VoltDIV, // sensitivity settings (0-7=20mV-5V)
int nCH2VoltDIV,

short nTrigSweep, // sweepMode: 0=Auto, 1=Normal ??, 2=single
short nTrigSrc, // 0=chan1, 1=chan2
short nTrigLevel, // level=0-255
short nSlope, // 0=rise, 1=fall

int nTimeDIV, // sampleRate (0-27=48MSa-100KSa/s, see dsoSetTime)
short nHTrigPos, // pre-TriggerData: 0-100% (control pre/post buffering)

unsigned long nDisLen, // ** length of DisplayData (huh?)
unsigned long * nTrigPoint, // index of returned triggerPoint

short nInsertMode // ** D-value Mode: 0=Step, 1=Line, 2=SinX/X (huh?)

I know the DisplayLength has a meaning in the DrawWave function, it's just used to clip the data and only display a portion of it, what it's being used for in GetRaw I'm not sure... perhaps it's clipping the data also?

D-Value mode is how the data is interpolated when you are at 2us or lower, the options are as follows:
1. Step - Interpolate in right angle steps
2. Line - Interpolate in obtuse angles
3. SinX - Interpolate in sine

The reason the Get Raw data function asks for these arguments is because it's doing the interpolation.

As for the Calibration functions, the firmware might be storing the cal data in the I2C IC.


Hope this will be usefull 



Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.