PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
PS5000AImports.MaximumValue(m_handle, out m_maxValue); // set max. ADC Counts
PS5000AImports.MinimumValue(m_handle, out m_minValue);
numSamplePerChannel = inSampleSizePerCH; // set Sampling coutn per channel
if (inTriggerMode == 0) //Trigger by CHA
{
ADCThreshold = (short)(inThreshold * m_maxValue * 1000 / (m_inputRanges[(int)m_channelSettings[(int)(PS5000AImports.Channel.ChannelA)].Range]));
status = (short)PS5000AImports.SetSimpleTrigger(m_handle, 1, PS5000AImports.Channel.ChannelA, ADCThreshold, PS5000AImports.ThresholdDirection.Rising, 0, 0); //no trigger, delay 10*8ns
}
else if (inTriggerMode == 2) //Trigger by CHB/CHZ with LB8001
{
ADCThreshold = (short)(inThreshold * m_maxValue * 1000 / (m_inputRanges[(int)m_channelSettings[(int)(PS5000AImports.Channel.ChannelC)].Range]));
status = (short)PS5000AImports.SetSimpleTrigger(m_handle, 1, PS5000AImports.Channel.ChannelC, ADCThreshold, PS5000AImports.ThresholdDirection.Rising, 0, 0); //no trigger, delay 10*8ns
}
else if (inTriggerMode == 3) //Trigger by CHZ with LB8002
{
ADCThreshold = (short)(inThreshold * m_maxValue * 1000 / (m_inputRanges[(int)m_channelSettings[(int)(PS5000AImports.Channel.ChannelD)].Range]));
status = (short)PS5000AImports.SetSimpleTrigger(m_handle, 1, PS5000AImports.Channel.ChannelD, ADCThreshold, PS5000AImports.ThresholdDirection.Rising, 0, 0); //no trigger, delay 10*8ns
}
else
{
status = (short)PS5000AImports.SetSimpleTrigger(m_handle, 0, PS5000AImports.Channel.ChannelA, 1, PS5000AImports.ThresholdDirection.Rising, 0, 0); //no trigger, delay 10*8ns
}
m_BlockReady = false;
m_callbackDelegateBlockReady = BlockCallback;
minBuffers = new short[NumMaxChannel][];
maxBuffers = new short[NumMaxChannel][];
minPinned = new PinnedArray[NumMaxChannel];
maxPinned = new PinnedArray[NumMaxChannel];
for (ch = 0; ch < NumMaxChannel; ch ++)
{
minBuffers[ch] = new short[numSamplePerChannel];
maxBuffers[ch] = new short[numSamplePerChannel];
minPinned[ch] = new PinnedArray(minBuffers[ch]);
maxPinned[ch] = new PinnedArray(maxBuffers[ch]);
if (ratioMode == PS5000AImports.RatioMode.Decimate)
{
status = (short)PS5000AImports.SetDataBuffers(m_handle, (PS5000AImports.Channel)(ch), maxBuffers[ch], minBuffers[ch], (int)numSamplePerChannel, 0, PS5000AImports.RatioMode.Decimate);
----------------------------------------
"this status return 13"
----------------------------------------
}
else
{
status = (short)PS5000AImports.SetDataBuffers(m_handle, (PS5000AImports.Channel)(ch), maxBuffers[ch], minBuffers[ch], (int)numSamplePerChannel, 0, PS5000AImports.RatioMode.None);
}
}
outTimeInterval = 0;
while (PS5000AImports.GetTimebase(m_handle, inTimebase, (int)numSamplePerChannel, out outTimeInterval, out numMaxOutSamples, 0) != 0)
{
inTimebase++;
}
//Start it collecting, then wait for completion
m_BlockReady = false;
m_callbackDelegateBlockReady = BlockCallback;
do
{
retry = false;
status = (short)PS5000AImports.RunBlock(m_handle, inPreTriggerSample, (int)numSamplePerChannel, inTimebase, out timeIndisposed, 0, m_callbackDelegateBlockReady, 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)
{
retry = true;
}
}
while (retry);
for (i = 0; i < inTimeout_cycle; i++)
{
if (!m_BlockReady)
{
if (i == 999)
{
return false;
}
Thread.Sleep(100);
}
else
{
break;
}
}
PS5000AImports.Stop(m_handle);
if (m_BlockReady)
{
short overflow;
if (ratioMode == PS5000AImports.RatioMode.Decimate)
{
//status = Imports.GetValues (_handle, 0, ref sampleCount, 5, Imports.RatioMode.Decimate, 0, out overflow);
status = (short)PS5000AImports.GetValues(m_handle, 0, ref numSamplePerChannel, downSampleRatio, PS5000AImports.DownSamplingMode.Decimate, 0, out overflow);
}
else
{
status = (short)PS5000AImports.GetValues(m_handle, 0, ref numSamplePerChannel, 1, PS5000AImports.DownSamplingMode.None, 0, out overflow);
}
outDataArray = new float[numSamplePerChannel][];
if (status == (short)StatusCodes.PICO_OK)
{
index = 0;
for (x = 0; x < numSamplePerChannel; x++)
{
values = new List();
for (ch = 0; ch < NumMaxChannel; ch ++)
{
value = (float)(maxPinned[ch].Target[x] * m_inputRanges[(int)m_channelSettings[ch].Range] / m_maxValue) / 1000;
values.Add(value);
}
outDataArray[index] = values.ToArray();
index++;
}
}
ret = true;
}