Test and Measurement Forum

Can not able to read valid data in buffer....!!!

Post your C and C++ discussions here

Can not able to read valid data in buffer....!!!

Postby umesh.lokhande » Fri Dec 14, 2012 1:53 pm

Hello,
i am writing application to read voltage from PicoScope Model: 3206. Since from couple of days i am trying to read buffer from Channel A. but cant able to get valid data in buffer. Technical details are as follows,

At very first i want to read from channel A and without any triggering input. I only want to check functionality from this implementation. The sequence of function in my source file are as follows,

ps3000_open_unit();

ps3000_set_channel(psHandler, PS3000_CHANNEL_A, TRUE, TRUE, PS3000_100MV);

ps3000_set_trigger(psHandler, PS3000_NONE, 16400, PS3000_RISING, 0, 0);

ps3000_get_timebase(psHandler, 1, 1000, &time_interval, &time_units, 1, &max_sample);

ps3000_run_block(psHandler, 1000, 1, 1, &time_indisposed_ms);

ps3000_ready(psHandler);

ps3000_get_values(psHandler, &buffer_a[0], 0, 0, 0, &overflow, 1000);

Here in "buffer_a[0]", i expected to have some data, But could not get which parameter in my application is going wrong

Awaiting kind rely.

Thanks
umesh.lokhande
Newbie
 
Posts: 0
Joined: Fri Dec 14, 2012 1:39 pm

Re: Can not able to read valid data in buffer....!!!

Postby Martyn » Mon Dec 17, 2012 11:01 am

Can you post your code so that we can see the functional logic as well as the api calls, or can you try the PS3000Con.c code that is supplied with the sdk.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2344
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Can not able to read valid data in buffer....!!!

Postby umesh.lokhande » Mon Dec 17, 2012 12:30 pm

Hello Martyn,
Thank you for your reply.....here is my code. What i don't understand here is every function works fine but the Buffer always shows some garbage value.....I hope this code is enough for you to figure it out which parameter from my implementation is going wrong......!!!

Thanks in Adavnce...!!!


Code: Select all
#include "pico_scope.h"


PicoScope::PicoScope(QObject *parent) :
    QObject(parent)
{

}

int32_t PicoScope::openScope()
{
    short status;

    long time_interval;
    short time_units;
    long max_sample;
    long time_indisposed_ms;

    psHandler = ps3000_open_unit();

    if (psHandler <= 0)
        return(PS_OPEN_FAILED);

    status = ps3000_set_channel(psHandler, PS3000_CHANNEL_A, TRUE, TRUE, PS3000_100MV);

    if (status != 1)
        return(PS_SET_CHANNEL_FAILED);

    status = ps3000_set_trigger(psHandler, PS3000_NONE, 16400, PS3000_RISING, 0, 0);

    if (status != 1)
        return(PS_SET_TRIGGER_FAILED);

    status = ps3000_get_timebase(psHandler, 1, 1000, &time_interval, &time_units, 1, &max_sample);

    if (status != 1)
        return(PS_GET_TIMEBASE_FAILED);

    status = ps3000_run_block(psHandler, 1000, 1, 1, &time_indisposed_ms);

    if (status != 1)
        return(PS_RUN_BLOCK_FAILED);

    return (PS_NO_ERROR);
}

int32_t PicoScope::ReadScope()
{
    short status;
    short buffer_a[1000];
    short overflow;

    status = ps3000_ready(psHandler);

    if (status != 1)
        return(PS_READY_FAILED);

    status = ps3000_get_values(psHandler, &buffer_a[0], 0, 0, 0, &overflow, 1000);

    if (status == 0)
        return(PS_GET_VALUES_FAILED);

    qDebug()<<"Values from Channel a0 : "<< buffer_a[0];

    status = ps3000_stop(psHandler);

    if (status != 1)
        return(PS_STOP_FAILED);

    return (PS_NO_ERROR);

}
umesh.lokhande
Newbie
 
Posts: 0
Joined: Fri Dec 14, 2012 1:39 pm

Re: Can not able to read valid data in buffer....!!!

Postby Martyn » Mon Dec 17, 2012 1:26 pm

Have you got an example of the data you collect, even if you think it is garbage ?
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2344
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Can not able to read valid data in buffer....!!!

Postby umesh.lokhande » Mon Dec 17, 2012 2:15 pm

Yes, in my buffer i got some random repetative numbers and very often are 0, 260, 520 etc,
umesh.lokhande
Newbie
 
Posts: 0
Joined: Fri Dec 14, 2012 1:39 pm

Re: Can not able to read valid data in buffer....!!!

Postby Martyn » Mon Dec 17, 2012 4:14 pm

What signal are you feeding into the scope, and what data would you expect to see in the buffer ?
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2344
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Can not able to read valid data in buffer....!!!

Postby umesh.lokhande » Mon Dec 17, 2012 5:06 pm

Hello Martyn,

I want to set channel A of Picoscope 3206 by external 5v DC input from power supply without any trigger input. I want to get this equivalet data of 5v in my buffer. Once i am sure that i have right data into buffer futhermore i want to plot this voltage on Graph. But I have got lot more difficulties just to set parameters and make it work.....!!!

I ask you pls if possible guide me some steps to configure PS3206(Function calls) in Block mode to read external input voltage from channel A to buffer so that I will use this content of buffer for further processing.

Awaiting your kind reply

Thanks in Advance
umesh.lokhande
Newbie
 
Posts: 0
Joined: Fri Dec 14, 2012 1:39 pm

Re: Can not able to read valid data in buffer....!!!

Postby Martyn » Tue Dec 18, 2012 7:00 am

Are you actually feeding in 5V when you get the values 0, 260, 520 as you have set the channel up to the 100mV range as per the following line
Code: Select all
ps3000_set_channel(psHandler, PS3000_CHANNEL_A, TRUE, TRUE, PS3000_100MV)

If not and there is nothing connected then what you are seeing is probably just noise and perfectly normal adc counts for our scope.

You can convert to volts by using
Code: Select all
( adc_count * input_range ) / 32767
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2344
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Can not able to read valid data in buffer....!!!

Postby umesh.lokhande » Tue Dec 18, 2012 9:28 am

Hello Martyn,
All works fine now exactly the way i wanted.
Thank you very much for your time to time replies.

Regards,
Umesh
umesh.lokhande
Newbie
 
Posts: 0
Joined: Fri Dec 14, 2012 1:39 pm


Return to C and C++

Who is online

Users browsing this forum: No registered users and 1 guest