My simplified code is as follows (the full code checks for return value of each function)
Code: Select all
' HRDLGetValues is declared like this Declare Function HRDLGetValues Lib "PicoHRDL.dll" (ByVal handle As Integer, ByRef values As Long, ByRef overflow As Integer, ByVal no_of_values As Long) As Long mHandle = HRDLOpenUnit() ' open the unit HRDLSetMains(mHandle, 0) ' Reject 50Hz HRDLSetAnalogInChannel(mHandle, 1, 1, 6, 0) ' channel 1, active, +/-39mV, differential HRDLSetInterval(mHandle, 340, 1) ' 340ms total time, 340ms per conversion HRDLRun(mHandle, 1, 2) ' 1 samples, continuous While HRDLReady(mHandle) = 0 ' Wait for it Thread.Sleep(50) End While Dim val As Long Dim overf As Integer HRDLGetValues(mHandle, val, overf, 1)
I've tried changing to Dim val(10) as long and passing val(0) as parameter, tried changing the Declare to accept ByRef values() as Long and then pass just 'val[ on the HRDLGetValues.
I either get 1st channel ok, the other completely wrong values (in the order of 10^17), or get all channels wrong values, or I get an IndexOutOfRange because somehow Dim val(10) became a Dim val(1) or I get an "Access Violation Exception - Attempted to read or write protected memory. This is often an indication that other memory is corrupted"
I'm not sure how should I proceed here as I'm out of options to test. Any help will be much appreciated.