Attribute VB_Name = "pac_i8017HW" 'function to get the library version of i-8017HW ' return: version number. ' for example: $106; = Rev:1.0.6 Declare Function get_Lib_Ver Lib "pac_i8017HW.dll" Alias "pac_i8017HW_GetLibVersion" () As Integer ' function to get the library built date ' libDate: library built date 'WINPAC_API(void) pac_i8017HW_GetLibDate(char libDate[]); //unsigned char -> char Declare Sub pac_i8017HW_GetLibDate Lib "pac_i8017HW.dll" (ByVal libdate As String) ' function to get the lattice version of i-8017h at specific slot ' slot: 0 ~ 7 ' firmwareVersion: the lattice version at specific slot ' ' return: 0 = SUCCESS. ' -1 = ERROR. 'WINPAC_API(bool) pac_i8017HW_GetFirmwareVersion(int iSlot,short* firmware); Declare Function pac_i8017HW_GetFirmwareVersion Lib "pac_i8017HW.dll" (ByVal slot As Long, ByRef firmwareVersion As Integer) As Integer ' function to initialize i-8017h at specific slot ' slot: 0 ~ 7 ' ' return: 0 = SUCCESS. ' -1 = ERROR. 'WINPAC_API(bool) pac_i8017HW_Init(int iSlot); Declare Function pac_i8017HW_Init Lib "pac_i8017HW.dll" (ByVal slot As Long) As Integer ' function to get the single ended/differential jumper status for i-8017h at specific slot ' slot: 0 ~ 7 ' selectJumper: 1 Single Ended; 0 Differential. ' ' return: 0 = SUCCESS. ' -1 = ERROR. 'WINPAC_API(bool) pac_i8017HW_GetSingleEndJumper(int iSlot,short* selectJumper); Declare Function pac_i8017HW_GetSingleEndJumper Lib "pac_i8017HW.dll" (ByVal slot As Long, ByRef selectJumper As Integer) As Integer ' function to get the calibrated gain and offset value for i-8017h at specific slot for certain input range ' slot: 0 ~ 7 ' gainType: ' 0: +/- 10.0V ' 1: +/- 5.0V ' 2: +/- 2.5V ' 3: +/- 1.25V ' 4: +/- 20mA ' gainValue: the calibated gain value ' offset: the calibated offset value ' ' return: 0 = SUCCESS. ' -1 = ERROR. 'WINPAC_API(bool) pac_i8017HW_ReadGainOffset_Info(int iSlot,int iGain,unsigned short* iGainValue,short* iOffsetValue); Declare Function pac_i8017HW_ReadGainOffset_Info Lib "pac_i8017HW.dll" (ByVal slot As Long, ByVal gainType As Long, ByRef gainValue As Long, ByRef offset As Integer) As Integer ' function to have programmable LED control for i-8017h at specific slot ' slot: 0 ~ 7 ' LEDValue: 0 ~ 0xffff ' ' return: 0 = SUCCESS. ' -1 = ERROR. 'WINPAC_API(bool) pac_i8017HW_SetLED(int iSlot,unsigned short iLedValue); Declare Function signedSetLed Lib "pac_i8017HW.dll" Alias "pac_i8017HW_SetLED" (ByVal slot As Long, ByVal ledvalue As Integer) As Integer ' function to read float format analog input data from i-8017h at specific slot ' slot: 0 ~ 7 ' channel: 0 ~ 7 if Differential mode; 0 ~ 15 if Single Ended mode ' gainType: ' 0: +/- 10.0V ' 1: +/- 5.0V ' 2: +/- 2.5V ' 3: +/- 1.25V ' 4: +/- 20mA ' fValue: float format analog input data. ' ' return: 0 = SUCCESS. ' -1 = ERROR. 'WINPAC_API(bool) pac_i8017HW_ReadAI(int iSlot,int iChannel,int iGain,float* fValue); Declare Function pac_i8017HW_ReadAI Lib "pac_i8017HW.dll" (ByVal slot As Long, ByVal channel As Long, ByVal gainType As Long, ByRef fvalue As Single) As Integer ' function to read 16 bit hex format analog input data from i-8017h at specific slot ' slot: 0 ~ 7 ' channel: 0 ~ 7 if Differential mode; 0 ~ 15 if Single Ended mode ' gainType: ' 0: +/- 10.0V ' 1: +/- 5.0V ' 2: +/- 2.5V ' 3: +/- 1.25V ' 4: +/- 20mA ' iValue: 16 bit hex format analog input data. ' ' return: 0 = SUCCESS. ' -1 = ERROR. 'WINPAC_API(bool) pac_i8017HW_ReadAIHex(int iSlot,int iChannel,int iGain,short* iValue); Declare Function pac_i8017HW_ReadAIHex Lib "pac_i8017HW.dll" (ByVal slot As Long, ByVal channel As Long, ByVal gainType As Long, ByRef ivalue As Long) As Integer Public Function pac_i8017HW_GetLibVersion() As String Dim hexInt As Integer hexInt = get_Lib_Ver() pac_i8017HW_GetLibVersion = Hex$(hexInt) End Function Public Function pac_i8017HW_SetLED(ByVal slot As Long, ByVal ledvalue As Long) As Integer Dim signedLedValue As Integer Dim ret As Integer If ledvalue > 65535 Or ledvalue < 0 Then MsgBox ("The LED value specified must be in the range 0 ~ 65535 which corresponds to 16 bit representation of the physical indicating LED.") pac_i8017HW_SetLED = False ElseIf ledvalue > 32767 Then signedLedValue = CInt(ledvalue - 65536) pac_i8017HW_SetLED = signedSetLed(slot, signedLedValue) Else signedLedValue = CInt(ledvalue) pac_i8017HW_SetLED = signedSetLed(slot, signedLedValue) End If End Function