Test and Measurement Forum

pulse width trigger

Post your C and C++ discussions here

pulse width trigger

Postby pmulroy » Tue Feb 15, 2011 7:46 am

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

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

Re: pulse width trigger

Postby Chris » Fri Feb 18, 2011 9:31 am

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;
Chris
Site Admin
Site Admin
 
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: pulse width trigger

Postby pmulroy » Tue Feb 22, 2011 9:10 am

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
pmulroy
Newbie
 
Posts: 0
Joined: Wed Jun 23, 2010 8:31 am

Re: pulse width trigger

Postby Chris » Mon Feb 28, 2011 3:46 pm

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.
Chris
Site Admin
Site Admin
 
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: pulse width trigger

Postby Eva zhou » Wed Feb 11, 2015 6:33 am

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
Eva zhou
Newbie
 
Posts: 0
Joined: Mon Jul 21, 2014 8:29 am

Re: pulse width trigger

Postby Karunen » Thu Feb 12, 2015 10:34 am

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
Karunen
Zen Master
Zen Master
 
Posts: 194
Joined: Thu Nov 21, 2013 9:22 am


Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests