Issue with pulse width triggers
Issue with pulse width triggers
Based on the example at github, I have created some code where I try to set up triggering.
int timeInterval;
int maxSamples;
Imports.GetTimebase(_handle,200000000, BUFFER_SIZE, out timeInterval, 1, out maxSamples, 0 );
Console.WriteLine(timeInterval + "ns " + maxSamples);
short triggerVoltage = mv_to_adc(100, (short)_channelSettings[(int)Imports.Channel.ChannelA].range); // ChannelInfo stores ADC counts
ushort hysteresisVoltage = Convert.ToUInt16(mv_to_adc(50, (short)_channelSettings[(int)Imports.Channel.ChannelA].range));
ushort hysteresisLowerVoltage = Convert.ToUInt16(mv_to_adc(50, (short)_channelSettings[(int)Imports.Channel.ChannelA].range));
Imports.TriggerChannelProperties[] triggerChannelProperties = new Imports.TriggerChannelProperties[]
{
new Imports.TriggerChannelProperties(triggerVoltage,
hysteresisVoltage,
triggerVoltage,
hysteresisLowerVoltage,
Imports.Channel.ChannelA,
Imports.ThresholdMode.Level)
};
Imports.TriggerConditions[] triggerConditions = new Imports.TriggerConditions[]
{
new Imports.TriggerConditions(Imports.TriggerState.True, // Channel A
Imports.TriggerState.DontCare, // Channel B
Imports.TriggerState.DontCare, // Channel C
Imports.TriggerState.DontCare, // Channel D
Imports.TriggerState.DontCare, // external
Imports.TriggerState.DontCare, // aux
Imports.TriggerState.DontCare, // pwq
Imports.TriggerState.DontCare)
};
Imports.ThresholdDirection[] directions = new Imports.ThresholdDirection[]
{ Imports.ThresholdDirection.RisingOrFalling, // Channel A
Imports.ThresholdDirection.None, // Channel B
Imports.ThresholdDirection.None, // Channel C
Imports.ThresholdDirection.None, // Channel D
Imports.ThresholdDirection.None, // ext
Imports.ThresholdDirection.None };
Imports.PwqConditions[] pwqConditions = new Imports.PwqConditions[1];
pwqConditions[0].ChannelA = Imports.TriggerState.True;
pwqConditions[0].ChannelB = Imports.TriggerState.DontCare;
pwqConditions[0].ChannelC = Imports.TriggerState.DontCare;
pwqConditions[0].ChannelD = Imports.TriggerState.DontCare;
pwqConditions[0].Digital = Imports.TriggerState.DontCare;
pwqConditions[0].Aux = Imports.TriggerState.DontCare;
pwqConditions[0].External = Imports.TriggerState.DontCare;
Imports.PulseWidthType[] pulseWidthType = new Imports.PulseWidthType[1];
pulseWidthType[0] = Imports.PulseWidthType.GreaterThan;
Imports.SetTriggerChannelConditions(_handle, triggerConditions, 1);
Imports.SetTriggerChannelDirections(_handle,
directions[(int)Imports.Channel.ChannelA],
directions[(int)Imports.Channel.ChannelB],
directions[(int)Imports.Channel.ChannelC],
directions[(int)Imports.Channel.ChannelD],
directions[(int)Imports.Channel.External],
directions[(int)Imports.Channel.Aux]);
Imports.SetTriggerChannelProperties(_handle, triggerChannelProperties, 1, 0, 0);
Imports.SetPulseWidthQualifier(_handle, pwqConditions, 1, directions[0], 2000000000, 2000000000, pulseWidthType[0]);
int timeDisposed;
_callbackDelegate = BlockCallback;
Imports.RunBlock(_handle, 0, 0, _timebase, _oversample, out timeDisposed, 0, _callbackDelegate, IntPtr.Zero);
I have used extreme values for the purpose of testing how this works. Now having set samplerate to 2000000000(1sample = 1,6seconds), and pulse width to 2000000000, the trigger shouldn't trigger before 3200000000 seconds or 101 years have passed(is this correct?) However, when I run the program, the trigger triggers immedietly.
I have tried to set up trigger in the PicoScope6 app, with the result im expecting.
Obviously there is something I don't understand here, but I expect that the condition of the signal has to stay below the threshold for 2000000000(Set in SetPulseWidthQualifier) samples before it can trigger.
Re: Issue with pulse width triggers
-
- Newbie
- Posts: 0
- Joined: Thu Sep 21, 2023 11:30 pm