Programming AWG

Post your C and C++ discussions here
Post Reply
atulkumar
Newbie
Posts: 0
Joined: Fri Dec 23, 2011 3:13 am

Programming AWG

Post by atulkumar » Fri Jan 06, 2012 2:01 pm

Hello!

I have a 2205 device. I want to capture a signal from one of the channels, "modify" it and then "play it back" using the AWG feature. In the PicoScope 6 documentation, I read the following: ".... you can even capture a waveform using your oscilloscope, modify it (if needed) using the AWG editor, and then play it back using the AWG."

How to achieve this using my own program? I need the help on the following specific points:

1. The sample value provided by the driver is a 16 bits signed number whereas the ps2000_set_sig_gen_arbitrary requires a buffer of "unsigned char". How to normalize a 16 bit signed value to "unsigned char". I used (127+(signed_16_bit_value/256)) to do this. Is it the correct way?

2. I use arbitraryWaveformSize as 4096. As I understand, the device will start outputting the voltage value based on the current value in the buffer (with pkToPk as its range). What is not clear to me is the interval at which these values are produced. Does the parameter dwellCount determines this? If yes then how?

3. If I dont want to have any delta phase and sweep (I just want to play the waveform as defined by the values in the buffer), then what should be the values of startDeltaPhase, stopDeltaPhase, deltaPhaseIncrement, sweepType, and sweeps. I read the programmer's guide but the description there was not clear to me.

If there is some code example already for the same then that would help greatly (the code in PS2000con.c is not of much help to me in this case).

Thanks in advance.

Regards,
Atul

Martyn
Site Admin
Site Admin
Posts: 3330
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Programming AWG

Post by Martyn » Thu Jan 12, 2012 11:58 am

The code in the example should help

Code: Select all

delta = ((frequency * waveformSize) / 4096) * 4294967296.0 * 20e-9;

ps2000_set_sig_gen_arbitrary(unitOpened.handle, 0, 2000000, (unsigned long)delta, (unsigned long)delta, 0, 0, arbitraryWaveform, waveformSize, PS2000_UP, 0);
1. Yes that should be fine
2. 4096 data points for one complete cycle at your chosen frequency. Dwell count is only used when sweeping frequency.
3. The example code gives a +/-1V waveform of constant chosen frequency
Martyn
Technical Support Manager

vmjb
Newbie
Posts: 0
Joined: Fri Sep 20, 2013 11:23 am

Re: Programming AWG

Post by vmjb » Mon Sep 23, 2013 2:19 pm

I'd like to do something similar with the 4227 but can't find any examples that use the AWG for the 4000 series?

Apologies - I found them.
Last edited by vmjb on Tue Sep 24, 2013 2:56 pm, edited 1 time in total.

Martyn
Site Admin
Site Admin
Posts: 3330
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Programming AWG

Post by Martyn » Tue Sep 24, 2013 5:52 am

From the C console application in the SDK, noting the differences between the model types

Code: Select all

	if (unit.model == MODEL_PS4262)									
	{
		AWGFileSize = MAX_SIG_GEN_BUFFER_SIZE>>1;						// PS4262 has 4K buffer
		UCVal = 5.2083e-6;																	// 1 / 192KHz
		maxFreq = 20000;																		// 20MHz maximum frequency							
	}
	else																						
	{
		AWGFileSize = MAX_SIG_GEN_BUFFER_SIZE;				// PS4226 / 4227 has 8K buffer
			
		UCVal = 5e-8;										// 1/20MHz
		maxFreq = 100000;									// 100MHz maximum frequency		
	}

delta = ((1.0 * frequency * waveformSize) / AWGFileSize) * (4294967296.0 * UCVal);

		status = ps4000SetSigGenArbitrary(	unit.handle, 
											0,	// offset voltage
											pkpk,	// PkToPk in microvolts. Max = 4uV  +2v to -2V
											(unsigned long)delta,			// start delta
											(unsigned long)delta,			// stop delta
											0, 
											0, 
											arbitraryWaveform, 
											waveformSize, 
											(SWEEP_TYPE)0, 
											0, 
											SINGLE, 
											0, 
											0, 
											SIGGEN_RISING,
											SIGGEN_NONE, 
											0);
Martyn
Technical Support Manager

Post Reply