Test and Measurement Forum

Problem using PicoScope4224 sample

Post your C and C++ discussions here

Problem using PicoScope4224 sample

Postby srul » Wed Aug 11, 2010 1:29 pm

Hi,
I recently bought PicoScop4224, I want to use it by transfering data to my PC , I'm using your sample that called ps4000con.c with no success , there are some H files that missing that needs to run _getch & _kbhit functions , I tried to download it from the internet but he keep asking me for more and more H FILES.
I'm compiling with CVI.

Please advise me what I have to do to run your sample.
Regards
israel.
srul
Newbie
 
Posts: 0
Joined: Wed Aug 11, 2010 11:17 am

Re: Problem using PicoScope4224 sample

Postby Robin » Fri Aug 13, 2010 8:34 am

Hi

Those functions are in the MS C runtime library (included with Visual Studio and many other IDEs) and are defined in the header conio.h. It sounds like your IDE doesn't include these library functions.

You could change the code so that it doesn't use these functions.

Robin
Robin
Zen Master
Zen Master
 
Posts: 558
Joined: Fri Sep 19, 2008 10:17 am

Re: Problem using PicoScope4224 sample

Postby srul » Sun Aug 15, 2010 6:10 am

Hi,

I have the conio.h, but he needs more files like:
cdefs.h
ioctl.h
select.h
sys-types.h
termios.h
types.h
unistd.h
those files are not there .....I download them from the internet
but it's still not enough.
I also tried to change the code, but it's not simple as u think.
I dont know what those function do.
I guess that _Kbhit wait for the user hit the keyboard , so why use a special function????

Please advise me what to do.
I'm using CVI compiler it's belong to NI.

I need simple things from this driver, just to set the picoscop and read data.

thanks.
srul
Newbie
 
Posts: 0
Joined: Wed Aug 11, 2010 11:17 am

Re: Problem using PicoScope4224 sample

Postby Robin » Wed Aug 18, 2010 11:37 am

Hi

I need simple things from this driver, just to set the picoscop and read data.


Even if you cannot run the example, it should help you to understand how to collect a block of data, for example. The API functions are described in the Programmer's Guide.

Regarding using the MS C Runtime Library, the following might help...

http://www.microsoft.com/downloads/details.aspx?FamilyId=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en

Robin
Robin
Zen Master
Zen Master
 
Posts: 558
Joined: Fri Sep 19, 2008 10:17 am

Re: Problem using PicoScope4224 sample

Postby srul » Thu Aug 19, 2010 11:32 am

Hi,

Thanks for your help, I succeded runing your example by changing the function "_getch()" to "getchar()" and "_kbhit()"
to "keyHit()" .

I have some question regarding to your sample:

1.GetTimeBase function: is it function to set the timebase or just discover which timebase available in the scop.

I'm entering squre wave drom the pulse generator and when
I set the PG freq to 1-10Hz i see the data is very well, but when I i set the PG to 1Khz the data is defective.
I think its because I don't change the timebase correctly.
here are the defines that i'm using:

#define TimeBase_100nSec (100e-9*2e7)+1
#define TimeBase_200nSec (200e-9*2e7)+1
#define TimeBase_500nSec (500e-9*2e7)+1
#define TimeBase_1uSec (1e-6*2e7)+1
#define TimeBase_2uSec (2e-6*2e7)+1
#define TimeBase_5uSec (5e-6*2e7)+1
#define TimeBase_10uSec (10e-6*2e7)+1
#define TimeBase_20uSec (20e-6*2e7)+1
#define TimeBase_50uSec (50e-6*2e7)+1
#define TimeBase_100uSec (100e-6*2e7)+1
#define TimeBase_200uSec (200e-6*2e7)+1
#define TimeBase_500uSec (500e-6*2e7)+1
#define TimeBase_1mSec (1e-3*2e7)+1
#define TimeBase_2mSec (2e-3*2e7)+1
#define TimeBase_5mSec (5e-3*2e7)+1
#define TimeBase_10mSec (10e-3*2e7)+1
#define TimeBase_20mSec (20e-3*2e7)+1
#define TimeBase_50mSec (50e-3*2e7)+1
#define TimeBase_100mSec (100e-3*2e7)+1
#define TimeBase_200mSec (200e-3*2e7)+1
#define TimeBase_500mSec (500e-3*2e7)+1

2. my second question is when i'm using thw 'w' key meaning
get triggered streaming , I receive in the data.txt 4 columns,
I understand columns 1 and 2, why do i need columns 3 and 4?
1 2 3 4
10652, 3251, 10020, 3058,
11176, 3411, 10584, 3230,
11652, 3556, 11108, 3390,
12072, 3684, 11564, 3529,
12404, 3785, 11968, 3652,
12704, 3877, 12316, 3759,
12912, 3940, 12616, 3850,
13072, 3989, 12844, 3920,
13160, 4016, 12932, 3947,
13176, 4021, 12964, 3956,
13072, 3989, 12824, 3914,
12912, 3940, 12596, 3844,
12668, 3866, 12300, 3754,
12388, 3780, 11948, 3646,
12020, 3668, 11528, 3518,
11600, 3540, 11020, 3363,
11092, 3385, 10496, 3203,
10564, 3224, 9932, 3031,
10004, 3053, 9320, 2844,

thanks for your help
best regards
israel.
srul
Newbie
 
Posts: 0
Joined: Wed Aug 11, 2010 11:17 am

Re: Problem using PicoScope4224 sample

Postby Robin » Thu Aug 19, 2010 11:59 am

Hi

ps4000GetTimebase can be used to discover the available timebases and it returns the sample interval for a given timebase code. It does not set the timebase and you don't have to use it.

There are four columns because the example uses aggregation and these are the min and max values, as described in section 4.6.4 of the programmer's guide.

Robin
Robin
Zen Master
Zen Master
 
Posts: 558
Joined: Fri Sep 19, 2008 10:17 am

Re: Problem using PicoScope4224 sample

Postby srul » Thu Aug 19, 2010 12:15 pm

hi Robin,
Thank u for your quick answer.

sorry, But i still have the first problem.
When I changing the setting of th PG to 1KHz the data that I receive is defective, why is that?
do i need to change some other function or setting to receive
correct data?
srul
Newbie
 
Posts: 0
Joined: Wed Aug 11, 2010 11:17 am

Re: Problem using PicoScope4224 sample

Postby Robin » Thu Aug 19, 2010 12:25 pm

Hi

Sorry, I missed part of your question.

Your #defines look correct. What timebase are you using and what aggregation factor are you using? In what way is the data defective?

Robin
Robin
Zen Master
Zen Master
 
Posts: 558
Joined: Fri Sep 19, 2008 10:17 am

Re: Problem using PicoScope4224 sample

Postby srul » Thu Aug 19, 2010 12:34 pm

that is the thing , How do i Change the TimeBase ??
the GetTimeBase function like u said is just to discover....but How do i changed it???, I understand that if i change the Freq int the PG I need to chang also another thing in the setting function so I can receive correct data.

what is the aggregation factor means?
srul
Newbie
 
Posts: 0
Joined: Wed Aug 11, 2010 11:17 am

Re: Problem using PicoScope4224 sample

Postby Robin » Fri Aug 20, 2010 11:42 am

Hi

When using block mode, the timebase is passed to ps4000RunBlock. When using streaming, you pass the sample interval to ps4000RunStreaming.

Aggregation is described in the programmer's guide. It is a way of reducing the data returned by the drive. For example, if you had an aggregation factor of 10, the driver would return the minimum and maximum values from each set of 10 samples.

Robin
Robin
Zen Master
Zen Master
 
Posts: 558
Joined: Fri Sep 19, 2008 10:17 am

Re: Problem using PicoScope4224 sample

Postby srul » Wed Sep 01, 2010 8:05 am

Hi again,

I have a few questions:

1. can i read data from two channels together when the trigger is on channel A?

2. How can I changed the trigger level?, i used this function :

short triggerVoltage = mv_to_adc(100,unit->channelSettings[PS4000_CHANNEL_B].range); // ChannelInfo stores ADC counts

struct tTriggerChannelProperties sourceDetails = { triggerVoltage, triggerVoltage, 256 * 10,PS4000_CHANNEL_B,
LEVEL };

fro this function i understand that the trigger level is 100mv, is that true?
srul
Newbie
 
Posts: 0
Joined: Wed Aug 11, 2010 11:17 am

Re: Problem using PicoScope4224 sample

Postby Robin » Thu Sep 02, 2010 7:57 am

Hi

srul wrote:1. can i read data from two channels together when the trigger is on channel A?


Yes.

srul wrote:fro this function i understand that the trigger level is 100mv, is that true?


Correct!

Robin
Robin
Zen Master
Zen Master
 
Posts: 558
Joined: Fri Sep 19, 2008 10:17 am

Re: Problem using PicoScope4224 sample

Postby srul » Thu Sep 02, 2010 8:56 am

hi Robin,

Ok, I need more help from you.

I need u to give me example how can I read two channels together.

is it possible only on streeming mode?

I really need the example, thanks.
srul
Newbie
 
Posts: 0
Joined: Wed Aug 11, 2010 11:17 am

Re: Problem using PicoScope4224 sample

Postby Robin » Fri Sep 03, 2010 8:05 am

ps4000con.c does use all channels in both block and streaming modes. See SetDefaults()
Robin
Zen Master
Zen Master
 
Posts: 558
Joined: Fri Sep 19, 2008 10:17 am


Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests