ps2000_get_times_and_values: times buffer

Post your .Net discussions here
Post Reply
Jimmy_Sk8a
User
User
Posts: 2
Joined: Fri Oct 17, 2008 11:43 am
Location: Zurich, Switzerland

ps2000_get_times_and_values: times buffer

Post by Jimmy_Sk8a »

hello,

getting values with ps2000_get_times_and_values works, but times array is filled with the same number for each value. i think it's a type problem. I tried different declarations:

Code: Select all

[DllImport("PS2000.dll", EntryPoint = "ps2000_get_times_and_values")] 
public static extern System.Int32 GetTimesAndValues1(short handle, System.Int32[] time_buffer, short[] buffer_a, short[] buffer_b, short[] buffer_c, short[] buffer_d, short overflow, short time_units, System.Int32 no_of_samples);
...
[DllImport("PS2000.dll", EntryPoint = "ps2000_get_times_and_values")]
	public static extern int GetTimesAndValues2(short handle, int[] times, short [] buffer_a,  short [] buffer_b, short [] buffer_c, short [] buffer_d, out short overflow, short time_units, int no_of_samples);
buffer declaration and function call:

Code: Select all

short[] Values_a     = new short[200000];
short[] Values_b     = new short[200000];
System.Int32[] b_times = new System.Int32[200000];

GetTimesAndValues1(handle,b_times,Values_a,Values_b,new short[0],new short[0],overflow,2,100);
...
short[] Values_a     = new short[200000];
short[] Values_b     = new short[200000];
int[] b_times = new int[200000];

GetTimesAndValues2(handle,b_times,Values_a,Values_b,new short[0],new short[0],out overflow,2,100);
but times values have all the same values, eg. 204793
what am I doing wrong? In Delphi it works with a longint array, and the manuals says long* times, which should be a 32bit-Int in .Net if i'm right.

Thank you for your help!
jimmy

Erik
PICO STAFF
PICO STAFF
Posts: 53
Joined: Mon Oct 23, 2006 8:16 am
Location: Cambridgeshire, UK

Post by Erik »


TimOster
Newbie
Posts: 0
Joined: Mon Dec 01, 2014 5:36 pm

Re: ps2000_get_times_and_values: times buffer

Post by TimOster »

THANK YOU Eric for the link. I've been struggling with this.

The example code returns raw ADC readings I think. How do you convert that to the actual voltage?

TIA,

Tim

Hitesh

Re: ps2000_get_times_and_values: times buffer

Post by Hitesh »

Hi Tim,

You can convert the raw ADC values to milliVolts using the following formula:

Code: Select all

milliVolts = (raw_value / PS2000_MAX_VALUE) * voltage_range_mv
where

PS2000_MAX_VALUE = 32767

e.g.

For a 1V range:

(16384 / 32767) * 1000 = 500mV

Regards,

Post Reply