c++ trigger setup problem

Post general discussions on using our drivers to write your own software here
Post Reply
Guest

c++ trigger setup problem

Post by Guest » Thu Dec 20, 2007 2:17 pm

hello,

ich have a problem with a self written c++ (visual studio) program, that must work with a trigger. without trigger the program works fine.

my triggersetup should work with the ext channel and channel A + signal generator (for testing).

/********/
channelproperty1.upperThreshold = 8000;
channelproperty1.lowerThreshold = 0;
channelproperty1.hysteresis = 0;
channelproperty1.thresholdMode = LEVEL;
channelproperty1.channel = PS5000_EXTERNAL;
status = ps5000SetTriggerChannelProperties(handle,&channelproperty1,1,0,0);

/**********/
conditions.channelA = TriggerConditions::DontCare;
conditions.channelB = TriggerConditions::DontCare;
conditions.channelC = TriggerConditions::DontCare;
conditions.channelD = TriggerConditions::DontCare;
conditions.ext = TriggerConditions::True;
conditions.aux = TriggerConditions::DontCare;
conditions.pwq = TriggerConditions::DontCare;
ps5000SetTriggerChannelConditions(handle,&conditions,1);

/***********/
ps5000SetTriggerChannelDirections(handle,
NONE,
NONE,
NONE,
NONE,
RISING,
NONE);

/***startstreaming**/
ps5000RunStreaming(handle,&sampleInterval,PS5000_NS,0,0,true,1,bufferSize);

/***sampling******/
while (samples < bufferSize)
{
Thread::Sleep(100);
status = ps5000GetStreamingLatestValues(handle, callBack, NULL);
}

/***callBack******/
extern "C" void __stdcall callBack
(short handle,
long noOfSamples,
unsigned long startIndex, //
short overflow,
unsigned long triggerAt,
short triggered,
short autoStop,
void * pParameter)
{
g_autoStop = autoStop;
received = true;
samples += noOfSamples;
}

/***finish**/

one problem is, that the flag triggered is true after the first callback call, although the external trigger is switched off. the second call the triggered flag is flags and will never be true again, although the trigger is switched on.
at the third call the autostop flag is true (dont know why, the max values aren't collected).
and a last failure case: if the triggerchannel is switched on at the beginning of the data collection - the propgram starts correctly (but collect to much data - bufferoverflow)

i hope anybody can help me

ziko
Advanced User
Advanced User
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Post by ziko » Mon Feb 11, 2008 12:46 pm

Hi and thank you for your post.

One of the software engineers has kindly had a look at your example and found that

"Yo are not setting the number of preTriggerSamples or postTriggerSamples thus the auto stop will automatically fire.

ps5000RunStreaming(handle,&sampleInterval,PS5000_NS, preSample, postSamples, true,1,bufferSize);

The preSamples or postSamples needs to be above 0, if you want to collect a million samples before the trigger and a million samples after the trigger then the two parameters are set to one million.
"

Hope this helps.

Kind regards
Ziko

Technical Specialist

Post Reply