Test and Measurement Forum

Interfacing VBNet programs to Pico ADC controllers

Post your .Net discussions here

Interfacing VBNet programs to Pico ADC controllers

Postby Dave Cowles » Fri Nov 16, 2007 7:55 pm

I am a fairly new programmer in Visual Basic 2005 and totally new to communicating with Pico Technology Data Loggers via Visual Basic.
I have a new Pico Technologies ADC-24 Data Logger that I wish to program an interface for.
I downloaded and ran Pico Technologies HRDL program for Visual Basic. The program was written for an earlier version of Visual Basic but VB 2005 successfully upgraded it and it ran properly, communicating with the ADC-24. In the HRDL program all the calls to the ADC-24 are referenced as functions which call the PicoHRDL.dll library. All the functions are defined in a module so that they can be referenced anywhere in the program. The functions are then called (successfully) from the main module.

Here is my problem: Following HRDL's example, I created a new program. I created a module that defines all the function calls identically to what HRDL did (I simply copied all the function definitions in the HRDL module). I copied the PicoHRDL.dll file into the program's folder. I then tried to make a function call (with identical syntax as used in HRDL) in the main module. However, the program will not run--it crashes with an unhandled overflow exception (implying division by zero) at the line where I call the function.

I can't seem to find any way to avoid this. If I do not call the function the program runs perfectly. Can anyone give me an idea of what I am not doing right?

Thanks!

Dave Cowles
Dave Cowles
User
User
 
Posts: 3
Joined: Fri Nov 16, 2007 7:42 pm

Postby ziko » Thu Nov 29, 2007 2:26 pm

Hi Dave, thank you for your post.

Have you tried to debug it to see where the problem is? If so could you be more specific as to where the problem occurs, i.e. what function call , what parameters are you passing and so on.

Kind regards
Ziko

Technical Specialist
ziko
Zen Master
Zen Master
 
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Specific program code

Postby Dave Cowles » Thu Nov 29, 2007 6:39 pm

Thank you for your reply, Ziko.

I have discovered the reason for my trouble. It seems to be a very simple and emrarassing one of not having a match in the variable types. I thought I had checked and rechecked that but sure enough, after leaving the code and coming back to it I noticed a mismatch. After the mismatch was corrected the code was able to function.

By the way--I have encountered a problem with the HRDLGetUnitInfo function. That seems to be the only one that uses a fixed-length string as one of the parameters passed (at lease I assume that the notation char * string for one parameter and stringlength for the next parameter denotes a fixed-length string). It turns out that Visual Basic 2005 no longer directly supports fixed-length strings. Since VB 2005 is so closely integrated with the Microsoft .NET framework I am guessing that none of the other languages associated with .NET framework, such as Microsoft C, will support them either. So the result is that I cannot call HRDLGetInfo to learn what kind of card is present, any error codes, etc. I tried using a non-fixed length string for the parameter but it didn't work.

Do you or anyone else know how to work around this issue?

Dave
Dave Cowles
User
User
 
Posts: 3
Joined: Fri Nov 16, 2007 7:42 pm

Postby markB » Fri Nov 30, 2007 4:29 pm

I'm not a VB expert but the following syntax should work for C#. I guess it wouldnt take too much to get this working for VB.

Code: Select all
    [DllImport("PicoHRDL.dll")]
    public static extern short HRDLGetUnitInfo (
      short handle,
      StringBuilder info,
      short infoLength,
      short infoType);
Regards

Mark
markB
Site Admin
Site Admin
 
Posts: 83
Joined: Tue Mar 27, 2007 9:43 am
Location: Cambridgeshire,UK

Postby Dave Cowles » Fri Nov 30, 2007 5:17 pm

Thanks, Mark--I'll check into that. VB has no Stringbuilder variable type but I will check to see if it might have an equivalent.

Dave
Dave Cowles
User
User
 
Posts: 3
Joined: Fri Nov 16, 2007 7:42 pm


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

Who is online

Users browsing this forum: No registered users and 1 guest