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
Dim val As Long
Dim overf As Integer
HRDLGetValues(mHandle, val, overf, 1)
this code works fine and I can continuous read channel 1, but when I expand to enable channel 3 and 5 (differential) using the same HRDLSetAnalogInChannel configuration and change the interval to 1020ms (3*240ms) on HRDLSetInterval, there's nothing I do on the HRDLGetValues that gives me the 3 values.
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.