I just got my brand new ADC-24 and I'm trying to make it work on VB.NET and having a few issues.
All library declarations are done (copied from the VB6 examples) on the header and I can successfully connect to the device (Open returns handler = 1).
I'll be using it for a constant (live-data) measurement, so I thought the option of using HRDLRun and then just keep reading every few ms would be better, I ran into problems with it so I tried using HRDLGetSingleValue without luck as well.
So, I'm coming for help, I'll post both my attempts on a simplified code. The real code I've been checking the return value for each command.
' Open
mHandle = HRDLOpenUnit()
' Reject 50Hz
HRDLSetMains(mHandle, 0)
' channel 1, active, +/-39mV, differential
HRDLSetAnalogInChannel(mHandle, 1, 1, 6, 0)
' 400ms total time, 340ms per conversion
HRDLSetInterval(mHandle, 400, 3)
' 5 samples, continuous
HRDLRun(mHandle, 5, 2) ' I'm really not sure what is meant by samples here, I just need to get the latest data, always the latest.
' Waiting for data
While HRDLReady(mHandle) = 0
Thread.Sleep(50) ' It's running in a BackgrounWorker
End While
While true
HRDLGetValues(mHandle, val(0), overf, 1)
End While
everything goes nice in this code until the actual GetValues, it's always returning the same value, to actually get a new value I have to stop and re-start from the beginning.
Do I have to call Run again? do I have to wait ready again?
' Open
mHandle = HRDLOpenUnit()
' Reject 50Hz
HRDLSetMains(mHandle, 0)
Dim overf As Short = 0
Dim value As Long = 0
' Channel 1, Range +/39mV, 340ms, differential
HRDLGetSingleValue(mHandle, 1, 6, 3, 0, overf, value)
'GetSingleFails, then I try to see why:
HRDLGetUnitInfo(mHandle, str, 50, 8)
' and it gives me 6: invalid parameters
but what parameters here are invalid? It's all copied from the datasheet.
Hi all,
I have a similar problem. I am using VB .NET in Visual Studio Express 2012 and the ADC20. I use the latest version of PicoHRDL.dll. My code is based on the HRDL.FRM and and HRDL.BAS samples. I have managed to successfully open the logger and initialize it.
When this call is made, an Exception is thrown with details as follows:
Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'C:\Users\Mariusz.Wilk\Documents\Visual Studio 2012\Projects\Picolog2\Picolog2\bin\Debug\Picolog2.vshost.exe'.
Additional Information: A call to PInvoke function 'Picolog2!Picolog2.Form1::HRDLGetSingleValue' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
I am not too sure how to solve this problem. I ran this program in VBA version that made the same calls and everything worked as expected.