Since the 5244B requires the signal to be from -32768 and +32767, I wrote this function to do this as seen below. I should note that I am doing this in C++ through the Qt framework.

Code: Select all

`short *Acquisition5000::convertWaveFormToSamples(QVector`rawwaveform)
{
short maxSample = 32767;
QVector tempvector(rawwaveform.size());
for (int i = 0; i < rawwaveform.size(); i++)
{
tempvector[i] = rawwaveform.value(i)*maxSample;
}
return &tempvector[0];
}

Code: Select all

`void Acquisition5000::readInWaveFormFile(QVector` &Array)
{
QFile file("C:/Users/Jason/Documents/Development/Qt/CrackDetection/outdata.csv");
if (!file.open(QIODevice::ReadOnly))
{
qDebug() << "File Not Found in" << QDir::currentPath();
return;
}
QTextStream in(&file);
while (!in.atEnd())
{
QString line = in.readLine();
Array.append(line.toDouble());
}
file.close();
}

From here I used an equation I found on the forums to calculate the deltaphase value as seen below:

Code: Select all

```
unsigned long Acquisition5000::calculateDeltaFromFrequency(double frequency, long waveformSize)
{
return (((frequency * waveformSize) / unitOpened_m.AWGFileSize) * AWG_PHASE_ACCUMULATOR * (1/AWG_DAC_FREQUENCY));
}
```

So the actual function I use to call ps5000aSetSigGenArbitrary is seen below:

Code: Select all

```
void Acquisition5000::setSignalGenerator(double ddsFrequency)
{
PICO_STATUS status;
short *arbitraryWaveform = NULL;
long waveformSize = (long)waveformvector.size(); //max of 49152
unsigned long pkpk = 4000000;
long offset = 0;
arbitraryWaveform = convertWaveFormToSamples(waveformvector);
unsigned long deltaPhase = calculateDeltaFromFrequency(ddsFrequency,waveformSize);
status = ps5000aSetSigGenArbitrary( unitOpened_m.handle,
0, // offset voltage
pkpk, // PkToPk in microvolts. Max = 4V +2v to -2V
deltaPhase, // start delta
deltaPhase, // stop delta
0,
0,
arbitraryWaveform,
waveformSize,
(PS5000A_SWEEP_TYPE)0,
(PS5000A_EXTRA_OPERATIONS)0,
PS5000A_SINGLE,
0,
0,
(PS5000A_SIGGEN_TRIG_TYPE) 0,
(PS5000A_SIGGEN_TRIG_SOURCE) 0,
0);
systemArmed = true;
}
```