Test and Measurement Forum

AWG with 2205

Post your C and C++ discussions here

AWG with 2205

Postby tulagm » Fri Nov 20, 2009 5:22 am

Hi,

I wrote a small function in C++ Builder to make use of AWG with 2205:

// Freq: frequency in Hertz (0-100000), Peak: amplitude/DC level in mV (0-2000)
bool PicoScope2205Write(float Freq, short Peak)
{
long offsetVoltage;
unsigned long pkToPk;
PS2000_WAVE_TYPE waveType;

if (Freq > 0)
{
offsetVoltage = 0; // symetrical output
pkToPk = (unsigned long)Peak*2000; // Peak-Peak in uV
waveType = PS2000_SQUARE; // square waveform
}
else
{
offsetVoltage = (long)Peak*1000; // positive DC level in uV
pkToPk = 0; // any value
waveType = PS2000_DC_VOLTAGE; // DC level output
}

return (ps2000_set_sig_gen_built_in(handle, // opened scope
offsetVoltage,
pkToPk,
waveType,
Freq, // start frequency
Freq, // no sweep: stop freq same as start
0, // frequency step
0, // time interval between 2 steps
PS2000_UP, // sweep type
0) == NULL);// number of sweeps
}

The aim is to output a fixed DC level if Freq is 0 and generate square wave otherwise. The problem is that the function works well with Freq=0 but do nothing if Freq>0 (SIGNAL OUT stays at 0V). It only works if I change the ps2000_set_sig_gen_built_in calling as following (please note the bold text):

return (ps2000_set_sig_gen_built_in(handle, // opened scope
offsetVoltage,
pkToPk,
waveType,
Freq*1.0, // start frequency
Freq*1.0, // no sweep: stop freq same as start
0, // frequency step
0, // time interval between 2 steps
PS2000_UP, // sweep type
0) == NULL);// number of sweeps

But then the DC level output option (Freq=0) doesn't work anymore. I think it's a type conversion matter but don't understand why and where.

Can anybody help me out of this situation. I'm not very skillful in C++ programming. Thanks in advance.
tulagm
Newbie
 
Posts: 0
Joined: Tue Oct 20, 2009 2:29 pm

Re: AWG with 2205

Postby Robin » Mon Nov 23, 2009 2:05 pm

Hi

Have a look at ps2000con.c in the SDK. This demonstrates using the 2203,4,5 to generate standard and arbitrary waveforms.

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

Re: AWG with 2205

Postby tulagm » Wed Nov 25, 2009 3:50 am

Hi Robin,

Thanks for your suggestion. I've read all examples provided with the package. I've also tried to pass direct values to ps2000_set_sig_gen_built_in or separated my own function into 2 sub-function (1 for generating square wave and 1 for output DC level), and they just work fine as I expected.

Now I just wonder why I can not combine them in a common function (to simplify my program) like the one I've implemented.

In addition, Freq*1.0 could be replaced with anything meaningless like Freq*1 or Freq+0 to have the same effect.

Regards,
tulagm
Newbie
 
Posts: 0
Joined: Tue Oct 20, 2009 2:29 pm


Return to C and C++

Who is online

Users browsing this forum: No registered users and 1 guest