pulse width trigger

Post your C and C++ discussions here
Post Reply
pmulroy
Newbie
Posts: 0
Joined: Wed Jun 23, 2010 8:31 am

pulse width trigger

Post by pmulroy »

Hello,

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.

Regards,

Patrick

...
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);

...

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: pulse width trigger

Post by Chris »

Hi Patrick

The pulseWidth.lower & upper settings are number of samples, so they depend upon the timbase setting (set in the ps4000GetTimebase call)

For a timesabe of 0 (12.5nS) 100nS would take 8 samples.


Try these settings......

struct tTriggerChannelProperties sourceDetails = { triggerVoltage, triggerVoltageHys,
0,
0, PS4000_CHANNEL_A, LEVEL };


struct tTriggerConditions conditions = {
CONDITION_TRUE, CONDITION_DONT_CARE, CONDITION_DONT_CARE, CONDITION_DONT_CARE, CONDITION_DONT_CARE, CONDITION_DONT_CARE, CONDITION_TRUE };


struct tTriggerDirections directions = {
FALLING, NONE, NONE, NONE, NONE, NONE };

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 = 8;
pulseWidth.upper = 0;
pulseWidth.type = PW_TYPE_LESS_THAN;
pulseWidth.nConditions = 1;
pulseWidth.direction = RISING_LOWER;

pmulroy
Newbie
Posts: 0
Joined: Wed Jun 23, 2010 8:31 am

Re: pulse width trigger

Post by pmulroy »

Hi,

Thanks for that. Seems to trigger ok for me now.

But not sure why you put FALLING as the trigger direction and pulse width direction of RISING_LOWER. Are these because I said it was a positive pulse? What about the POSITIVE_RUNT value?

Regards,

Patrick

Chris
Site Admin
Site Admin
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: pulse width trigger

Post by Chris »

RISING would probably be more in line with what you need, I was just concentrating on getting the pulse width trigger to work, not on the specifics.

Eva zhou
Newbie
Posts: 0
Joined: Mon Jul 21, 2014 8:29 am

Re: pulse width trigger

Post by Eva zhou »

Hi Chris,

How to set the triggerHysteresis in TRIGGER_CHANNEL_PROPERTIES structure? For 1.5% what should this value be? what is the mean of 256*10 in the API demo?


Many Thanks.
Eva

Karunen
Advanced User
Advanced User
Posts: 194
Joined: Thu Nov 21, 2013 9:22 am

Re: pulse width trigger

Post by Karunen »

Hi Eva,

The hysteresis is the similar to the trigger ADC if you want 1.5% you will need to calculate what is is in ADC counts.
So you could take the trigger ADC count and times it by 0.0015 and use that for you hysteresis ADC count.

The 256*10 we provide in the example is just something an arbitrary value.

Kind Regards,
Karunen

Technical Specialist
Pico Technology

Post Reply