Can't make get_timebase() work from my C# class

Forum for discussing PicoScope (version 5)
Guest

Post by Guest »

Now i have got it working, starting sampling
but I only enabled channel A yet I keep on getting the data to BufferB.

It doesn't meter whether I plug it to channel A or B in the device I get reading into bufferB

when the configuration is (plugged into channelB):

Code: Select all

PICO.SetChannel(PS3000.Channel.ChannelA , true , PS3000.Coupling.DC , PS3000.Range.Range2V);
            PICO.SetChannel(PS3000.Channel.ChannelA,false, PS3000.Coupling.DC, PS3000.Range.Range2V);
the result is that bufferB get the sempling,

when the configuration is (plugged into channelB):

Code: Select all

PICO.SetChannel(PS3000.Channel.ChannelA , false, PS3000.Coupling.DC , PS3000.Range.Range2V);
            PICO.SetChannel(PS3000.Channel.ChannelA, true, PS3000.Coupling.DC, PS3000.Range.Range2V);

I get both in bufferA and bufferB data...

why? what's probably wrong now?

Thanks.

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

Post by markB »

I cannot repeat your problem. If B is disabled, the buffer does not get modified after the call to GetValues.

In both of your code snippets, you enabled then disable ch A, ch B is never set. Could this be your problem?
Regards

Mark

Guest

Post by Guest »

Hello again Mark,

I have some issues I can't seem to solve with data reading.

To begin with, when my PS3224 is connected to computer, but no probe is

connected, I still get values into bufferA array.

I mean, there is no sampling going on and still I receive values into my

buffer array.

why is that? how can it be solved???

thank you.

Guest

Post by Guest »

This is a peace of my code:

PS3000 PICO = new PS3000();
PICO.Open();
PICO.SetChannel(channel_A , A_enabled , a_coupling , range);
PICO.SetChannel(channel_B , B_enabled , b_coupling , range);
PICO.SetTrigger(channel_A , threshold , A_direction , delay, AutoTriggerMs);
PICO.SetTrigger(channel_B , threshold, B_direction , delay, AutoTriggerMs);
PICO.GetTimebase(timaBase, NumOfSamples, out nsInterval, out TimeUnit, overSemple, out MaxSamples);
PICO.RunBlock(NumOfSamples , timaBase , overSemple , out timeIndesposedMs);
PICO.Ready();
PICO.GetValues(bufferA, bufferB, bufferC, bufferD, out overflows , numValues);

that is the function calling part in my program

if you need any other information please tell me.

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

Post by markB »

I dont understand what your problem is.

Your buffers will not be modified by PS3000.dll unless there is a call to ps3000_get_values or ps3000_get_times_and_values. If you make a call to these functions without first calling run, then undefined behaviour will occur.
Regards

Mark

Guest

Post by Guest »

Code: Select all

Your buffers will not be modified by PS3000.dll unless there is a call to ps3000_get_values or ps3000_get_times_and_values. If you make a call to these functions without first calling run, then undefined behaviour will occur.
I did call run block, as you can see in my code.

and yet after calling run and get values, but with out being plugged to a

source threw a probe on any one of the channels.

still data is written to buffers as if it collects data from no where.

that way, how am I supposed to know whether the data it collects when it is

connected to a probe is accurate??

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

Post by markB »

Sorry, I didnt see your code before I posted the reply.

You need test the return value of PICO.Ready() to see if the device is ready yet:

Code: Select all

PICO.RunBlock(NumOfSamples, timaBase, overSemple, out timeIndesposedMs);

while(!PICO.Ready())
  ;

PICO.GetValues(bufferA, bufferB, bufferC, bufferD, out overflows , numValues); 
If you call GetValues before the device has finished collecting any data the buffers will be filled with garbage. I guess this is the problem that you are seeing
Regards

Mark

Guest

Post by Guest »

thanks I will try that out.

just for the record I must say I did wait in debug mode for ready to return

the value 1, only then did I call get_values.

and still I got some garbage values I am not sure from where.

I will post a response if it solves the problem or if the problem consist.

Guest

Post by Guest »

It seems to working though I am still not sure of the accuracy of the results.

Can you please tell me, couldn't find in the documentation, what does the

buffer hold???

is it voltage in miliVolts, collected from the circuit??

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

Post by markB »

The buffer is scaled in 16bit adc counts.

The best place to look is the ps3000con.c C example. This will give you examples of all the operating mode and value scaling.
Regards

Mark

Guest

Post by Guest »

In the c file PS3000con.c it seems like its adc 12bit resolution.

any way from what I understand to get real translated values to mV

I need to calculate threw the formula :
Q= EFSR / (2^m -1)

Where Q is resolution in volts, EFSR is the full scale voltage range, and M is resolution in bits. The number of intervals is given by the number of available levels minus one.
the calculation in the C file seems different from the formula I read about,

they take buffer contents multiply by my range, say 2V, in milivolts = 2000.

and then divide by 32767.

I don't understand that calculation or which one to use.

Sorry, but I am not familiar with these things so I do need that help.

thnks.

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

Post by markB »

Zero corresponds to zero volts: 32767 and -32767 correspond to the minimum and maximum voltage on the currently selected range.

It is therefore not hard to see that:

Code: Select all

Scaled Volts = 16bitAdcCount * RangeMax / 32767

eg. For an Adc Count of 3277 on the +/-10V range:

Scaled Volts = 3277 * 10 / 32767 = 1V
Regards

Mark

Post Reply