Test and Measurement Forum

Continuous Read from ADC-24

Post your .Net discussions here

Continuous Read from ADC-24

Postby Budius » Wed Jul 04, 2012 1:29 pm

I can perfectly read 1 value Continuously from my ADC-24 on VB.NET but some reason I'm not getting the right code to read 3 channels.
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
End While
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.
Posts: 0
Joined: Wed Jul 04, 2012 11:30 am

Re: Continuous Read from ADC-24

Postby Hitesh » Thu Jul 05, 2012 9:57 am

Hi Budius,

As per your other forum post, please use the 'Integer' data type instead of 'Long' and 'Short' where the API requires that data type.

The following knowledge base article might be of interest:


Please note that Strings need to be passed by value.

In the case where you have 3 channels, what happens if you call the HRDLGetNumberofEnabledChannels function?

Please send in the code to support@picotech.com if the above suggestion does not resolve the problem.

Technical Support Engineer
Site Admin
Site Admin
Posts: 2359
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 0 guests