urgent help on ps3000_get_timebase called in C#

Post general discussions on using our drivers to write your own software here
Post Reply
Guest

urgent help on ps3000_get_timebase called in C#

Post by Guest »

Hi,
I need some help on calling the ps3000_get_timebase driver function in a C# application. The function call returns 0 and I can't figure out what is wrong.

[DllImport("PS3000", EntryPoint="ps3000_get_timebase")]
public static extern short ps3000_get_timebase( short handle,
short timebase, long no_of_samples, ref long time_interval_ns,
ref short time_units, short oversample, ref long max_samples );


Any suggestion is much appreciated!

Thanks in advance.

Sarah

Post by Sarah »

Hi

Thank you for your post.

The code you gave looks basically correct apart from a minor variable length issue that I suspect will have been marshalled automatically anyway.

Here is the version that I use:

Code: Select all

[DllImport("PS3000.dll")] 
public static extern short ps3000_get_timebase(
  short handle, 
  short timebase,
  int no_of_samples,
  out int time_interval_ns, 
  out short time_units,
  short oversample,
  out int max_samples);
Remember that long is usually 32 bit in C/C++ but is always 64 bit in C#, so I tend to use int instead, which is 32 bit in C#. Also I use out instead of ref to more explicitly declare the intention of the pointer parameters.

Try the version above just in case this solves the problem quickly; however, I suspect the problem is more likely to be associated with the numbers being given as arguments and the function call sequence.

The obvious first thing to verify is that the handle returned from ps3000_open_unit is valid (should be > 0). With that out of the way, turn a channel on (at least one channel must be active first) with ps3000_set_channel and then, attempt some known working values e.g. -
  • timebase = 4
    no_of_samples = 2000
    oversample = 1
Let me know how you get along with this

Best Regards

Post Reply