PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
while (!stopPicoscope) //is set to true if user stops the processing
{
do
{
retry = false;
status = Imports.RunBlock(_handle, 0, (int)sampleCount, _timebase, out timeIndisposed, 0, _callbackDelegate, IntPtr.Zero);
if (status == (short)StatusCodes.PICO_POWER_SUPPLY_CONNECTED || status == (short)StatusCodes.PICO_POWER_SUPPLY_NOT_CONNECTED || status == (short)StatusCodes.PICO_POWER_SUPPLY_UNDERVOLTAGE)
{
status = Imports.ChangePowerSource(_handle, status);
retry = true;
}
else
{
//textMessage.AppendText("Run Block Called\n");
}
}
while (retry);
while (!_ready)
{
//Thread.Sleep();
}
Imports.Stop(_handle);
if (_ready)
{
short overflow;
status = Imports.GetValues(_handle, 0, ref sampleCount, 1, Imports.DownSamplingMode.None, 0, out overflow);
if (copyNewValues) // is set to true in data processing module after data has been copied from receivedDataTmpChA/B buffer to dataprocessing module's own buffer
{
Array.Copy(maxBuffersChA, receivedDataTmpChA, maxBuffersChA.Length);
Array.Copy(maxBuffersChB, receivedDataTmpChB, maxBuffersChB.Length);
copyNewValues = false;
}
if (status == (short)StatusCodes.PICO_OK)
{
//textMessage.AppendText("Have Data\n");
}
else
{
//textMessage.AppendText("No Data\n");
}
}
else
{
//textMessage.AppendText("data collection aborted\n");
}
Imports.Stop(_handle);
Thread.Sleep(25);
}
Code: Select all
while (!stopPicoscope) //is set to true if user stops the processing
{
do
{
retry = false;
status = Imports.RunBlock(_handle, 0, (int)sampleCount, _timebase, out timeIndisposed, 0, _callbackDelegate, IntPtr.Zero);
if (status == (short)StatusCodes.PICO_POWER_SUPPLY_CONNECTED || status == (short)StatusCodes.PICO_POWER_SUPPLY_NOT_CONNECTED || status == (short)StatusCodes.PICO_POWER_SUPPLY_UNDERVOLTAGE)
{
status = Imports.ChangePowerSource(_handle, status);
retry = true;
}
else
{
//textMessage.AppendText("Run Block Called\n");
}
}
while (retry);
while (!_ready)
{
//Thread.Sleep();
}
Imports.Stop(_handle);
if (_ready)
{
short overflow;
status = Imports.GetValues(_handle, 0, ref sampleCount, 1, Imports.DownSamplingMode.None, 0, out overflow);
if (copyNewValues) // is set to true in data processing module after data has been copied from receivedDataTmpChA/B buffer to dataprocessing module's own buffer
{
Array.Copy(maxBuffersChA, receivedDataTmpChA, maxBuffersChA.Length);
Array.Copy(maxBuffersChB, receivedDataTmpChB, maxBuffersChB.Length);
copyNewValues = false;
}
if (status == (short)StatusCodes.PICO_OK)
{
//textMessage.AppendText("Have Data\n");
}
else
{
//textMessage.AppendText("No Data\n");
}
}
else
{
//textMessage.AppendText("data collection aborted\n");
}
Imports.Stop(_handle);
Thread.Sleep(25);
}
Code: Select all
public void getBlockDataTmp()
{
uint status;
//---------------------------------------------------------------------------------------------------------------------------------
//********************************* Initialize signal gen *************************************************
//---------------------------------------------------------------------------------------------------------------------------------
try
{
startFreq = Convert.ToDouble("1");
pkToPk = 2000000; //1v?
offset = Convert.ToInt32("0");
}
catch
{
MessageBox.Show("Error with start frequency, offset and/or pktopk", "INVALID VALUES", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
stopFreq = startFreq;
increment = 0;
dwellTime = 0;
sweeptype = Imports.SweepType.PS5000A_UP;
Imports.WaveType wavetype = Imports.WaveType.PS5000A_SQUARE;// PS5000A_SINE;
if (wavetype == Imports.WaveType.PS5000A_DC_VOLTAGE)
{
pkToPk = 0;
}
status = Imports.SetSigGenBuiltInV2(_handle, offset, pkToPk, wavetype, startFreq, stopFreq, increment, dwellTime, sweeptype,
operations, shots, sweeps, triggertype, triggersource, extinthreshold);
if (status != StatusCodes.PICO_OK)
{
MessageBox.Show("Error SetSigGenBuiltInV2 error code :" + status.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
status = Imports.SetSigGenBuiltInV2(_handle, offset, pkToPk, wavetype, startFreq, stopFreq, increment, dwellTime, sweeptype,
operations, shots, sweeps, triggertype, triggersource, extinthreshold);
//---------------------------------------------------------------------------------------------------------------------------------
chRange = 10;
status = Imports.SetChannel(_handle, Imports.Channel.ChannelA, 1, Imports.Coupling.PS5000A_DC, Imports.Range.Range_10V, 0);
status = Imports.SetChannel(_handle, Imports.Channel.ChannelB, 1, Imports.Coupling.PS5000A_DC, Imports.Range.Range_10V, 0);
//status = Imports.SetChannel(_handle, Imports.Channel.ChannelC, 0, Imports.Coupling.PS5000A_DC, Imports.Range.Range_10V, 0);
//status = Imports.SetChannel(_handle, Imports.Channel.ChannelD, 0, Imports.Coupling.PS5000A_DC, Imports.Range.Range_10V, 0);
short enable = 1;
uint delay = 0;
short threshold = 0;
short auto = 0;
status = Imports.SetSimpleTrigger(_handle, enable, Imports.Channel.External, threshold, Imports.ThresholdDirection.Rising, delay, auto);
_ready = false;
_callbackDelegate = BlockCallback;
_channelCount = 4;
PinnedArray[] minPinned = new PinnedArray[_channelCount];
PinnedArray[] maxPinned = new PinnedArray[_channelCount];
int timeIndisposed;
minBuffersChA = new short[sampleCount];
maxBuffersChA = new short[sampleCount];
minBuffersChB = new short[sampleCount];
maxBuffersChB = new short[sampleCount];
bufferValueChA = new short[sampleCount];
bufferValueChB = new short[sampleCount];
minPinned[0] = new PinnedArray(minBuffersChA);
maxPinned[0] = new PinnedArray(maxBuffersChA);
minPinned[1] = new PinnedArray(minBuffersChB);
maxPinned[1] = new PinnedArray(maxBuffersChB);
status = Imports.SetDataBuffers(_handle, Imports.Channel.ChannelA, maxBuffersChA, minBuffersChA, (int)sampleCount, 0, Imports.RatioMode.None);
status = Imports.SetDataBuffers(_handle, Imports.Channel.ChannelB, maxBuffersChB, minBuffersChB, (int)sampleCount, 0, Imports.RatioMode.None);
int maxSamples;
while (Imports.GetTimebase(_handle, _timebase, (int)sampleCount, out timeInterval, out maxSamples, 0) != 0)
{
//textMessage.AppendText("Timebase selection\n");
_timebase++;
}
_timebase = 3;
//textMessage.AppendText("Timebase Set\n");
/* Start it collecting, then wait for completion*/
_ready = false;
_callbackDelegate = BlockCallback;
while (!acqStopped)
{
do
{
retry = false;
status = Imports.RunBlock(_handle, 0, (int)sampleCount, _timebase, out timeIndisposed, 0, _callbackDelegate, IntPtr.Zero);
if (status == (short)StatusCodes.PICO_POWER_SUPPLY_CONNECTED || status == (short)StatusCodes.PICO_POWER_SUPPLY_NOT_CONNECTED || status == (short)StatusCodes.PICO_POWER_SUPPLY_UNDERVOLTAGE)
{
status = Imports.ChangePowerSource(_handle, status);
retry = true;
}
else
{
//textMessage.AppendText("Run Block Called\n");
}
}
while (retry);
while (!_ready)
{
//Thread.Sleep();
}
Imports.Stop(_handle);
if (_ready)
{
short overflow;
status = Imports.GetValues(_handle, 0, ref sampleCount, 1, Imports.DownSamplingMode.None, 0, out overflow);
if (status == (short)StatusCodes.PICO_OK)
{
}
else
{
//textMessage.AppendText("No Data\n");
}
}
else
{
//textMessage.AppendText("data collection aborted\n");
}
Imports.Stop(_handle);
//Thread.Sleep(25);
}
foreach (PinnedArray p in minPinned)
{
if (p != null)
p.Dispose();
}
foreach (PinnedArray p in maxPinned)
{
if (p != null)
p.Dispose();
}
}