PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
initOsciloStatus = Imports.OpenUnit(out osciloHandle, null);
if (initOsciloStatus == 0)
{
Imports.SetChannel(osciloHandle, Imports.Channel.ChannelA, 1, 0, Imports.Range.Range_5V, 0);
Imports.SetChannel(osciloHandle, Imports.Channel.ChannelB, 1, 0, Imports.Range.Range_5V, 0);
Imports.SetChannel(osciloHandle, Imports.Channel.ChannelC, 1, 0, Imports.Range.Range_5V, 0);
Imports.SetChannel(osciloHandle, Imports.Channel.ChannelD, 1, 0, Imports.Range.Range_5V, 0);
Imports.MemorySegments(osciloHandle, 1, out maxSamples);
//MessageBox.Show("Maximum of samples: " + maxSamples.ToString());
}
short sbCap = 20; short sbCap2 = 0;
StringBuilder sb = new StringBuilder(sbCap);
res = Imports.GetUnitInfo(osciloHandle, sb, sbCap, out sbCap2, 4); // 4 = PICO_BATCH_AND_SERIAL
if (res == 0)
{
oscSerialNo = sb.ToString();
MessageBox.Show("SN: " + oscSerialNo.
}
Code: Select all
if (osciloHandle > -1)
{
Imports.SetTriggerChannelDirections(osciloHandle, Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.Rising);
Imports.TriggerConditions[] myCond = new Imports.TriggerConditions[1];
myCond[0].ChannelA = Imports.TriggerState.True;
Imports.SetTriggerChannelConditions(osciloHandle, myCond, 1);
Imports.TriggerChannelProperties[] myProp = new Imports.TriggerChannelProperties[1];
myProp[0].HysteresisMajor = hysteresis_Major;
myProp[0].HysteresisMinor = hysteresis_Minor;
myProp[0].Channel = Imports.Channel.ChannelA;
myProp[0].ThresholdMajor = threshold_Major;
myProp[0].ThresholdMinor = threshold_Minor;
//myProp[0].ThresholdMode = Imports.ThresholdMode.Level;
myProp[0].ThresholdMode = Imports.ThresholdMode.Window;
Imports.SetTriggerChannelProperties(osciloHandle, myProp, 1, 0, 0);
}
Code: Select all
if (osciloHandle > -1)
{
short result;
int indisposedTime;
_callbackDelegate = DataInputCallback;
BUFFER_SIZE = 5000; // 5000 samples, timebase = 110;
result = Imports.RunBlock(osciloHandle, 200, BUFFER_SIZE - 200, timeBase, 1, out indisposedTime, 0, _callbackDelegate, IntPtr.Zero);
if (result != 0) MessageBox.Show("Starting measurement failed.");
}
Code: Select all
Imports.SetTriggerChannelDirections(osciloHandle, Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.Rising); // OLD
Imports.TriggerConditions[] myCond = new Imports.TriggerConditions[1]; // OLD
myCond[0].ChannelA = Imports.TriggerState.True; // OLD
myCond[0].ChannelB = Imports.TriggerState.DontCare; // NEW
myCond[0].ChannelC = Imports.TriggerState.DontCare; // NEW
myCond[0].ChannelD = Imports.TriggerState.DontCare; // NEW
myCond[0].Pwq = Imports.TriggerState.True; // NEW
myCond[0].External = Imports.TriggerState.DontCare; // NEW
Imports.SetTriggerChannelConditions(osciloHandle, myCond, 1); // OLD
Imports.PwqConditions[] pwq = new Imports.PwqConditions[1]; // NEW
pwq[0].ChannelA = Imports.TriggerState.True; // NEW
pwq[0].ChannelB = Imports.TriggerState.DontCare; // NEW
pwq[0].ChannelC = Imports.TriggerState.DontCare; // NEW
pwq[0].ChannelD = Imports.TriggerState.DontCare; // NEW
pwq[0].External = Imports.TriggerState.DontCare; // NEW
Imports.SetPulseWidthQualifier(osciloHandle, pwq, 1, Imports.ThresholdDirection.PositiveRunt, 10, 0, Imports.PulseWidthType.GreaterThan); // NEW
Imports.TriggerChannelProperties[] myProp = new Imports.TriggerChannelProperties[1]; // OLD
// myProp[0].HysteresisMajor = hysteresis_Major; // REMOVED
// myProp[0].HysteresisMinor = hysteresis_Minor; // REMOVED
myProp[0].Channel = Imports.Channel.ChannelA; // OLD
myProp[0].ThresholdMajor = threshold_Major; // OLD
myProp[0].ThresholdMinor = threshold_Minor; // OLD
myProp[0].ThresholdMode = Imports.ThresholdMode.Window; // OLD
Imports.SetTriggerChannelProperties(osciloHandle, myProp, 1, 0, 0); // OLD
Code: Select all
myProp[0].ThresholdMode = Imports.ThresholdMode.Level;
Code: Select all
void SetTrigger()
{
short threshold_Major = 19507; //(4 volts on 5 V scale)
string results = "";
uint status = 0;
int timeIntervalNanoseconds = 0;
int maxSamples = 0;
do
{
status = Imports.GetTimebase(osciloHandle, timeBase, BUFFER_SIZE, out timeIntervalNanoseconds, overSample, out maxSamples, 0);
if (status == StatusCodes.PICO_INVALID_TIMEBASE)
{
timeBase++;
}
}
while (status != StatusCodes.PICO_OK);
Imports.TriggerChannelProperties[] sourceDetails = new Imports.TriggerChannelProperties[] { new Imports.TriggerChannelProperties(threshold_Major, 256, threshold_Major, 256, Imports.Channel.ChannelA, Imports.ThresholdMode.Level) };
Imports.TriggerConditions[] conditions = new Imports.TriggerConditions[] { new Imports.TriggerConditions(Imports.TriggerState.True, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.True) };
Imports.PwqConditions[] pwqConditions = new Imports.PwqConditions[] { new Imports.PwqConditions(Imports.TriggerState.True, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare) };
results += "SetTriggerChannelProperties: [";
results += Imports.SetTriggerChannelProperties(osciloHandle, sourceDetails, 1, 0, 0).ToString();
results += "]\r\n";
results += "SetTriggerChannelConditions: [";
results += Imports.SetTriggerChannelConditions(osciloHandle, conditions, 1).ToString();
results += "]\r\n";
results += "SetTriggerChannelDirections: [";
results += Imports.SetTriggerChannelDirections(osciloHandle, Imports.ThresholdDirection.FallingLower, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None).ToString();
results += "]\r\n";
results += "SetTriggerDelay: [";
results += Imports.SetTriggerDelay(osciloHandle, 0).ToString();
results += "]\r\n";
results += "SetPulseWidthQualifier: [";
results += Imports.SetPulseWidthQualifier(osciloHandle, pwqConditions, 1, Imports.ThresholdDirection.Rising, 10, 0, Imports.PulseWidthType.GreaterThan).ToString();
results += "]\r\n"; // 10 samples width of pulse
results += "threshold_Major = " + threshold_Major.ToString() + "\r\n";
results += "Sample length = " + timeIntervalNanoseconds.ToString() + " ns\r\n";
results += "Maximum of samples = " + maxSamples.ToString() + " ns\r\n";
MessageBox.Show(results);
StartMeasurement();
}
//-----------------------------------------------------------------------------------
void StartMeasurement()
{
if (osciloHandle > -1 && initOsciloStatus==0)
{
short result;
int indisposedTime;
_callbackDelegate = DataInputCallback;
result = (short)Imports.RunBlock(osciloHandle, 200, BUFFER_SIZE - 200, timeBase, overSample, out indisposedTime, 0, _callbackDelegate, IntPtr.Zero);
if (result != 0)
{
MessageBox.Show("Cannot measure.\r\nError code: " + result.ToString(), generalTexts.msgLabel, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
//-----------------------------------------------------------------------------------
void DataInputCallback(short handle, short status, IntPtr pVoid)
{
// flag to say done reading data
if (status != (short)StatusCodes.PICO_CANCELLED)
{
dataSaved = true;
}
}