Hantek DSO3062 SDK manual HTHardDLL

Page 1
SDK - HTHardDll.dll Manual
VC++6.0 IDE
Note:
HTHardDll.dll was compiled under VC++6.0. WORD: unsigned short BOOL: bool ULONG: unsigned long
The following ifdef block is the standard way of creating macros which make exporting from a DLL simpler. All files within this DLL are compiled with the DLL_API symbol defined on the command line. this symbol should not be defined on any project that uses this DLL. This way any other project whose source files include this file see DLL_API functions as being imported from a DLL, wheras this DLL sees symbols defined with this macro as being exported.
#ifndef DLL_API #define DLL_API extern "C" __declspec(dllimport) #endif
Define __stdcall:
#define WIN_API __stdcall
Defines the struct for the application.
_HT_RELAY_CONTROL contains the relay control information.
typedef struct _HT_RELAY_CONTROL
{ BOOL bCHEnable[4]; WORD nCHVoltDIV[4]; WORD nCHCoupling[4]; BOOL bCHBWLimit[4]; WORD nTrigSource; BOOL bTrigFilt; WORD nALT; }RELAYCONTROL,*PRELAYCONTROL;
Parameters Remarks: bCHEnable[4]: The channel is enable/disable.Value: 1 is enable; 0 is disable. nCHVoltDIV[4]: The VOLT/DIV index of the channel. nCHCoupling[4]: The coupling index of the channel .
Page 2
ValueDC is 0AC is 1GND is 2
bCHBWLimit[4]The bandwidth of the channel.
Value: be enable is 1: be disable is 0. nTrigSourceThe index of the trigger source. If the channel has 4 channels, the value is : CH1 is 0, CH2 is 1, CH3 is 2 , …… bTrigFiltThe High Frequency Rejection. Be enable is 1, disable is 0. nALTIf the trigger is alternate trigger, the value is 1, otherwise is 0.
Example:
Declare a variable: RELAYCONTROL myRelayControl; Declare a pointer: PRELAYCONTROL pRelayControl;
_HT_CONTROL_DATA contains some controls.
typedef struct _HT_CONTROL_DATA
{ WORD nCHSet;//Channel Enable/Disable
//The 0 bit: 0 is enable, 1 is disable. // The 1 bit: 0 is enable, 1 is disable. // The 2 bit: 0 is enable, 1 is disable. // The 3 bit: 0 is enable, 1 is disable. WORD nTimeDIV; //The index of time Base WORD nTriggerSource; // The index of the trigger source WORD nHTriggerPos; //The Horizontal Trigger Pos (Value: 0 ~ 100) WORD nVTriggerPos; //The Vertical Trigger Pos (Value: 0 ~ 255) WORD nTriggerSlope; //The Edge trigger Slope (Rise slope is 0,Fall slope is 1) ULONG nBufferLen; //The buffer Length ULONG nReadDataLen; //The Data Length of have be read. WORD nALT; // Is alternate trigger or not
}CONTROLDATA,*PCONTROLDATA;
Example:
Declare a variable: CONTROLDATA myControlData; Declare a pointer: PCONTROLDATA pControlData;
Functions:
1. DLL_API BOOL WINAPI dsoSetUSBBus (
WORD nDeviceIndex )
Return value: If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE.
Page 3
Parameters: nDeviceIndex index of the device Remarks: If you change to USB communication, you must call this function firstly.
2. DLL_API WORD WINAPI dsoHTReadCalibrationData (
WORD nDeviceIndex, WORD* pLevel, WORD nLen )
Return value: If the function succeeds, the return value is1.
If the function fails, the return value is zero.
Parameters:
nDeviceIndex index of the device pLevel pointer to buffer, save the device calibration data nLen the calibration buffer size Remarks: This function must be called when initializing the device.
3. DLL_API WORD WINAPI dsoHTSearchDevice(short* pDevInfo)
Return Value:
The number of have connected devices.
Parameters: pDevInfo pointer to devices information that have connected to PC. Remarks: You should call this function to know how many devices that have connected to PC. One PC supports 64 devices to be connected. Example:
short DevInfo[64];
WORD nConnectedDevNum = 0; //DevInfo Initial…. //… //Call this function nConnectedDevNum = dsoHTSearchDevice(DevInfo); if (nConnectedDevNum > 0)
Page 4
{ For(int i=0 ;i<64 i++)
{
if (DevInfo[i] = = 0) { // has device. The device is not used. } else if (DevInfo[i] = = 1) { // has device. The device is used. } else { //No device was found. }
}
}
4. DLL_API WORD WINAPI dsoHTSetCHPos(
WORD nDeviceIndex, WORD* pLevel, WORD nVoltDIV, WORD nPos, WORD nCH )
Return Value: If the function succeeds, the return value is zero. If the function fails, the return value is zero.
Parameters: nDeviceIndex index of the device pLevel pointer to calibration level. nVoltDIV index of channel nPos the position of channel, range: 0 ~ 255 (8bit) nCH the target channel (CH1 is 0, CH2 is 1, CH3 is 2. ………….) Remarks: Set channel level (Zero Level)
Example:
Page 5
WORD nDeviceIndex = 0; WORD CHLevel[256]; // the calibration level, see dsoHTReadCalibrationData function WORD nVoltDIV = 6; // WORD nPos = 128; // WORD nCH = 0; //
// if ( 0 = = dsoHTSetCHPos(nDeviceIndex,CHLevel,nVoltDIV,nPos,nCH) ) ; //Fail else ; //Succeed
5. DLL_API WORD WINAPI dsoHTSetVTriggerLevel (
WORD nDeviceIndex, WORD* pLevel, WORD nPos)
Return value:
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.
Parameters:
nDeviceIndex index of current device pLevel pointer to calibration level nPos the position of the trigger level, range : 0 ~ 255 (8bit) Remarks: Set the position of the trigger level.
Example:
WORD nDeviceIndex = 0; WORD CHLevel[256]; //the calibration level, see dsoHTReadCalibrationData function WORD nPos = 128; //call function if ( 0 = = dsoHTSetVTriggerLevel( nDeviceIndex, CHLevel, nPos) ) ; //Fail else ; //Succeed
6. DLL_API WORD WINAPI dsoHTSetHTriggerLength(
WORD nDeviceIndex, ULONG nBufferLen, WORD HTriggerPos, WORD nTimeDIV ,WORD nYTFormat
Page 6
)
Return value: If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Parameters: nDeviceIndex index of current device. nBufferLen the buffer length HTriggerPos the horizontal trigger position( percent ), range : 0 ~ 100 nTimeDIV index of the TIME/IDV nYTFormat the mode of the horizontal format. Value: 0: Normal, 1: Scan, 2: Roll Remarks: Set the trigger length Example: WORD nDeviceIndex = 0; ULONG nBufferLen = 10240;//10K WORD HTriggerPos = 50; //50% WORD nTimeDIV = 12; //40us //Call function if ( 0 = = dsoHTSetHTriggerLength(nDeviceIndex,nBufferLen,HTriggerPos,
nTimeDIV) ) ; //Fail else ; //Succeed
7. DLL_API WORD WINAPI dsoHTSetCHAndTrigger(
WORD nDeviceIndex, RELAYCONTROL RelayControl)
Return value: If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Parameters: nDeviceIndex index of current device RelayControl See “_HT_RELAY_CONTROL” Remarks Set channel and trigger
Page 7
Example: WORD nDeviceIndex = 0; RELAYCONTROL RelayControl; //RelayControl Initial…. //Call function if ( 0 = = dsoHTSetCHAndTrigger(nDeviceIndex,RelayControl) ) ; //Fail else ; //Succeed
8. DLL_API WORD WINAPI dsoHTSetCHAndTriggerVB(
WORD nDeviceIndex, WORD* pCHEnable, WORD* pCHVoltDIV, WORD* pCHCoupling, WORD* pCHBWLimit, WORD nTriggerSource, WORD nTriggerFilt, WORD nALT )
Return value: If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Parameters: nDeviceIndex index of current device pCHEnable point to Channel Onoff Item of “_HT_RELAY_CONTROL” pCHVoltDIV point to Channel Voltate Item of “_HT_RELAY_CONTROL” pCHCoupling point to Channel Coupling Item of “_HT_RELAY_CONTROL” pCHBWLimit point to Channel BWLimt Item of “_HT_RELAY_CONTROL” nTriggerSource Trigger Source Item of “_HT_RELAY_CONTROL” nTriggerFilt tTrigger Filt Item of “_HT_RELAY_CONTROL” nALT Alt Item of “_HT_RELAY_CONTROL” Remarks Set channel and triggeruse for VB program environment Example: WORD nDeviceIndex = 0;
Page 8
WORD pCHEnable[4] = {1,1,1,1}; WORD pCHVoltDIV[4] = {6,6,6,6}; WORD pCHCoupling[4] = {1,1,1,1}; WORD pCHBWLimit[4] = {0,0,0,0}; WORD nTriggerSource = 0; //CH1 WORD nTriggerFilt = 0; WORD nALT = 0;
// Call function
if(0==dsoHTSetCHAndTriggerVB(nDeviceIndex,pCHEnable,pCHVoltDIV, pCHCoupling,
pCHBWLimit, nTriggerSource, nTriggerFilt, nALT) ) ; //Fail else ; //Succeed
9. DLL_API WORD WINAPI dsoHTSetTriggerAndSyncOutput(
WORD nDeviceIndex, WORD nSynMode, WORD nlaTriggerMode, WORD nTriggerMode, WORD nTriggerSlope, WORD nPWCondition, ULONG nPW, USHORT nVideoStandard, USHORT nVedioSyncSelect, USHORT nVideoHsyncNumOption, WORD nSync )
Return value: If the function succeeds, the value is nonzero. If the function fails, the value is zero. Parameters: nDeviceIndex index of current device nSynMode, type of Trigger Source value: 0: when select CH /CH2 /EXT as Trigger Source. 5: when select D0~D15 as Trigger Source nlaTriggerMode, he mode of the trigger D0~D15: Edge trigger is 0, Pulse Trigger is 1. nTriggerMode the mode of the trigger. Edge trigger is 0, Pulse Trigger is 1. nTriggerSlope
Page 9
the slope of the edge trigger, Rise slope is 0, Fall slope is 1. nPWCondition the condition of the pulse trigger
value: + Less is 0 + Equal is 1 + More is 2
- Less is 3
- Equal is 4
- More is 5 nPW the pulse width value. The time range of the pulse width is 10ns ~ 10s, the pulse width value range is 2 ~ 200000000010ns/5 ~ 10000000000ns/5 nVideoStandard Set video standard, value : 0 is PAL/SECAM ,1 is NTSC nVedioSyncSelect Set video sync, value: All Lines:0 All Field:1 Odd Field:2 Even Field;3 Line Num:4 nVideoHsyncNumOption Set video line number, the min value is 1. nSync The synchro output is enable or disable. 1 is enable, 0 is disable. Remarks: set trigger Exmaple: WORD nDeviceIndex = 0;
WORD nSynMode = 0;//Trigger CH1/CH2/EXT
WORD nlaTriggerMode = 0; / Edge Trigger WORD nTriggerMode = 0; //Edge Trigger WORD nTriggerSlope = 0; //Rise Slope WORD nPWCondition = 0; // ULONG nPW = 2; //10ns, nPW = 10ns/5 WORD nSync = 0; //Closed //Call function
if (0 = = dsoHTSetTriggerAndSyncOutput(nDeviceIndex, nSynMode,
nlaTriggerMode ,nTriggerMode, nTriggerSlope,
nTriggerCondition, nPW, nSync) ) ; //Fail else ; //succeed
Page 10
10. DLL_API WORD WINAPI dsoHTSetSampleRate(
WORD nDeviceIndex, WORD nTimeDIV, WORD nYTFormat )
Return value: If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Parameters: nDeviceIndex index of the current device nTimeDIV index of the TIME/DIV nYTFormat the mode of horizontal format. 0: Normal, 1: Scan, 2: Roll Remarks; Set sampling rate Exmaple: WORD nDeviceIndex = 0; WORD nTimeDIV = 12; //index of the TIME/IDV. //Call function if (0 = = dsoHTSetSampleRate(nDeviceIndex, nTimeDIV) ) ; //Fail else ; //Succeed
11. DLL_API WORD WINAPI dsoHTStartCollectData(WORD nDeviceIndex)
Return value:
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Parameters: nDeviceIndex index of current device Remarks: Notify the device to prepare collecting data Example: WORD nDeviceIndex = 0; if (0 = = dsoHTStartCollectData(nDeviceIndex) ) ; //Fail else
Page 11
; //Succeed
12. DLL_API WORD WINAPI dsoHTStartTrigger(WORD nDeviceIndex)
Return value:
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Parameters: nDeviceIndex index of the current device Remarks: Notify the device to detect trigger signal.
Example: WORD nDeviceIndex = 0;
if (0 = = dsoHTStartTrigger(nDeviceIndex) ) ; //Fail else ; //Succeed
13. DLL_API WORD WINAPI dsoHTForceTrigger(WORD nDeviceIndex)
Return value:
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. Parameters: nDeviceIndex index of the device Remarks: Force to trigger the signal
Example: WORD nDeviceIndex = 0;
if (0 = = dsoHTForceTrigger(nDeviceIndex) ) ; //Fail else ; //Succeed
14. DLL_API WORD WINAPI dsoHTGetState(WORD nDeviceIndex)
Return value:
If the device prepares to collect data, the return value is 1. If the device is detecting trigger signal, the return value is 3.
Page 12
If the device has collected data, the return value is 7. You can read the data only the return value is 7. Parameters: nDeviceIndex Index of the device Remarks: Retrieve the collect state of the device.
Example: WORD nDeviceIndex = 0;
while ( dsoHTGeState(nDeviceIndex) != 0x07)
{ continue; } //Read data from the device
15. DLL_API WORD WINAPI dsoHTGetData (
WORD nDeviceIndex, WORD* pCH1Data, WORD* pCH2Data, WORD* pCH3Data, WORD* pCH4Data, PCONTROLDATA pControl );
Return value: If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.
Parameters: nDeviceIndex idex of the device pCH1Data pointer to CH1 Data buffer pCH2Data pointer to CH2 Data buffer pCH3Data pointer to CH3 Data buffer pCH4Data pointer to CH4 Data buffer pControl Set _HT_CONTROL_DATA Remarks: Read the data to PC buffer from the device. Example:
Page 13
WORD nDeviceIndex = 0; WORD nInsertMode = 2; //Sinx /x if ( 0 = = dsoSDGetData ( nDeviceIndex, pCH1Data, pCH2Data, pCH3Data, pCH4Data , pControl) ) ; //Fail else ; //Succeed
16. DLL_API BOOL WINAPI laSetTrigSource(
WORD DeviceIndex,
unsigned char nSour
)
Return value: If the function succeeds, the return value is true. If the function fails, the return value is false. Parameters: nDeviceIndex idex of the device nSour
trigger logic channel value: 0~15: D0~D15
Remarks: set logic D0~D15 as trigger source Example: WORD nDeviceIndex = 0; unsigned char nSour 0; // D0
if ( false = = laSetTrigSource(DeviceIndex, nSour))
; //Fail else ; //Succeed
17. DLL_API BOOL WINAPI laSetVoltDiv(
WORD DeviceIndex, WORD *nlaVoltDiv )
Return value: If the function succeeds, the return value is true. If the function fails, the return value is false. Parameters: nDeviceIndex idex of the device
Page 14
nlaVoltDiv
point to Voltage of 16 logic channel value 0~119: -6V~+6V
Remarks:
set gate level of logic channel Example: WORD nDeviceIndex = 0; WORD nlaVoltDiv[16]; WORD i; for(i=0;i<16;i++)
{
nlaVoltDiv[i] = 58;//-0.2V }
if ( false = = aSetVoltDiv(WORD DeviceIndex, nlaVoltDiv))
; //Fail else ; //Succeed
17. DLL_API BOOL WINAPI dsoGetDisplayDataFromSourceDataSingle(
short *pDisplayData,
WORD *pSourceData, WORD *LeverPos, ULONG nDataLen, WORD nCH )
Return value: If the function succeeds, the return value is true. If the function fails, the return value is false. Parameters: pDisplayData
point to data.
pSourceData, point to data. LeverPos, point to display data. nDataLen date length ,default:10240 nCH
one of 18 channel value: 0~17
Remarks:
Page 15
find out value of 18 channels from 4 channels collected. CH1/CH2 unchanged,CH3 is D0~D7,CH4 is D8~D15 Example:
short pDisplayData[18][10240]; //value of 18 channels
WORD pSourceData[4][10240]; //4 channels collected WORD LeverPos[18]; // display data of 18 channels ULONG nDataLen = 10240; //default WORD nCH; //channel
for (i=0;i<18;i++)
{
if(i<2)
{
if(!(dsoGetDisplayDataFromSourceDataSingle(pDisplayData[i],
pSourceData[i] , LeverPos, nDataLen,i)))
{
//Error
break;
} }
else if(i<10)
{
if(!(dsoGetDisplayDataFromSourceDataSingle(pDisplayData[i],
pSourceData[2] , LeverPos, nDataLen,i)))
{
// Error
break;
} }
else if(i<18)
{
if(!(dsoGetDisplayDataFromSourceDataSingle(pDisplayData[i],
pSourceData[3] , LeverPos, nDataLen,i)))
{
// Error
break;
} }
}
if (i == 18)
{ //Succeed }
Page 16
Flow-Chart:
dsoSetUSBBus()
dsoHTReadCalibrationData()
dsoHTSetSampleRate()
dsoHTSetCHAndTrigger()
Init
dsoHTSetTriggerAndSyncOutput()
dsoHTSetCHLeverPos()
dsoHTSetVTriggerLevel()
dsoHTSetHTriggerLengthAndPos()
dsoHTStartCollectData()
1
dsoHTStartTrigger()
Loop
3
Return dsoHTGetState()
7
dsoSDGetData()
Loading...