I'm having a problem coding up a pulse width trigger and can't find an example of one in the sdk. Just wondering if you could check the code snippet below or point me to an example.
Basically I want to code up chan A, positive pulse, threshold of 100mv and pulse width less than 100ns and 1.5% hysteresis. This works fine for me in the PicoScope trigger settings window. But code below is not triggering for me.
short triggerVoltage = mv_to_adc(100, range);
short triggerHysteresis = mv_to_adc(150, range); //?? For 1.5% what should this value be?
sourceDetails.thresholdUpper = triggerVoltage;
sourceDetails.thresholdUpperHysteresis = triggerHysteresis;
sourceDetails.thresholdLower = triggerVoltage;
sourceDetails.thresholdLowerHysteresis = 0;
sourceDetails.channel = PS4000_CHANNEL_A;
sourceDetails.thresholdMode = LEVEL;
conditions.channelA = CONDITION_TRUE;
conditions.channelB = CONDITION_DONT_CARE;
conditions.channelC = CONDITION_DONT_CARE;
conditions.channelD = CONDITION_DONT_CARE;
conditions.external = CONDITION_DONT_CARE;
conditions.aux = CONDITION_DONT_CARE;
memset(&pulseWidth, 0, sizeof(struct tPwq));
memset(&directions, 0, sizeof(struct tTriggerDirections));
conditions.pulseWidthQualifier = CONDITION_DONT_CARE; //??? I tried CONDITION_TRUE here aswell.
delay = 0;
directions.channelA = RISING;
struct tPwqConditions pwqconditions;
pwqconditions.channelA = CONDITION_TRUE;
pwqconditions.channelB = CONDITION_DONT_CARE;
pwqconditions.channelC = CONDITION_DONT_CARE;
pwqconditions.channelD = CONDITION_DONT_CARE;
pwqconditions.external = CONDITION_DONT_CARE;
pwqconditions.aux = CONDITION_DONT_CARE;
pulseWidth.conditions = &pwqconditions;
pulseWidth.lower = 0; // ??
pulseWidth.upper = 100;
pulseWidth.type = PW_TYPE_LESS_THAN;
pulseWidth.nConditions = 1;
pulseWidth.direction = RISING; // ??
status = SetTrigger(unit.handle, &sourceDetails, 1, &conditions, 1, &directions, &pulseWidth, delay, 0, 0);