Triggering data streaming 5444B

Post your .Net discussions here
Post Reply
EdwardLaw
Newbie
Posts: 0
Joined: Mon Feb 13, 2017 2:25 pm

Triggering data streaming 5444B

Post by EdwardLaw »

Hi,

I'm using a Picoscope 5444B to generate a signal from the Gen port that is triggered on the Ext channel. I will also be using channel A to read in the data from the signal generator by just taking the output from the Gen port and placing it in channel A. I would like to have the scope waiting for a trigger pulse on channel B to then start 'continuous streaming' on channel A. Ideally I would like the streaming to start and stop when triggered on channel B rather than having to pre-set the duration of capture once triggered.

Currently I have managed to modify the code supplied in the SDK (PS5000AStreamingConsole.sln) to set up the Gen signal to respond to the trigger on Ext. However when trying to do triggered streaming I keep getting the status code 290 within the SetTrigger function. In the documentation, this corresponds to an unavailable channel due to USB power restrictions. Due to running on DC mains power, I assume that this is not the issue.

Due to the error, the code skips the SetTrigger function and will start reading in data immediately once started. I have gone through all the functions to ensure that variables such as autotrigger are disabled.

Any suggestions of how to get around status = 290 in the SetTrigger function would be greatly appreciated!
See code below:


/****************************************************************************
* CollectStreamingTriggered
* this function demonstrates how to collect a stream of data
* from the unit (start collecting on trigger)
***************************************************************************/
void CollectStreamingTriggered()
{


short triggerVoltage = mv_to_adc(10000, (short)_channelSettings[(int)Imports.Channel.ChannelB].range); //****** I have set the threshold to 10,000mv in an attempt to get the program to wait for a trigger but it still streams *******//

Imports.TriggerChannelProperties[] sourceDetails = new Imports.TriggerChannelProperties[] {
new Imports.TriggerChannelProperties( triggerVoltage, 10, triggerVoltage, 10, Imports.Channel.ChannelB, Imports.ThresholdMode.Level )};

Imports.TriggerConditions[] conditions = new Imports.TriggerConditions[] {
new Imports.TriggerConditions(Imports.TriggerState.DontCare
Imports.TriggerState.True,
Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare,
Imports.TriggerState.DontCare)};

Imports.ThresholdDirection[] directions = new Imports.ThresholdDirection[]
{ Imports.ThresholdDirection.None,
Imports.ThresholdDirection.Rising,
Imports.ThresholdDirection.None,
Imports.ThresholdDirection.None,
Imports.ThresholdDirection.None,
Imports.ThresholdDirection.None };



Console.WriteLine("Collect streaming triggered...");
Console.WriteLine("Data is written to disk file (test.csv)");
Console.WriteLine("Press a key to start");
WaitForKey();
SetDefaults();

/* Trigger enabled
* Rising edge
* Threshold = 100mV */

SetTrigger(sourceDetails, 1, conditions, 1, directions, null, 0, 0, 0); // Look at SetTrigger for trigger details

StreamDataHandler(1000);
}




/********************************************
Set up the trigger thresholds
*********************************************/

uint SetTrigger(Imports.TriggerChannelProperties[] channelProperties, short nChannelProperties, Imports.TriggerConditions[] triggerConditions, short nTriggerConditions, Imports.ThresholdDirection[] directions, Pwq pwq, uint delay, short auxOutputEnabled, int autoTriggerMs)
{
uint status;

if (
(status = Imports.SetTriggerChannelProperties(_handle, channelProperties, nChannelProperties, auxOutputEnabled, autoTriggerMs)) != 0) /********* THIS IS WHERE STATUS = 290 ************/
{
return status;
}

if ((status = Imports.SetTriggerChannelConditions(_handle, triggerConditions, nTriggerConditions)) != 0)
{
return status;
}

if (directions == null) directions = new Imports.ThresholdDirection[] { Imports.ThresholdDirection.None,
Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None,
Imports.ThresholdDirection.None, Imports.ThresholdDirection.None};

if ((status = 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])) != 0)
{
return status;
}

if ((status = Imports.SetTriggerDelay(_handle, delay)) != 0)
{
return status;
}

if (pwq == null) pwq = new Pwq(null, 0, Imports.ThresholdDirection.None, 0, 0, Imports.PulseWidthType.None);

status = Imports.SetPulseWidthQualifier(_handle, pwq.conditions,
pwq.nConditions, pwq.direction,
pwq.lower, pwq.upper, pwq.type);

return status;
}

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Triggering data streaming 5444B

Post by Martyn »

Please note that when you start streaming the device will start collecting data immediately, and return this to the application, what you do with this data is up to you.

When the trigger event occurs the device will pass through a flag to say that it has triggered, and indicate which sample corresponds to the trigger point.
Martyn
Technical Support Manager

EdwardLaw
Newbie
Posts: 0
Joined: Mon Feb 13, 2017 2:25 pm

Re: Triggering data streaming 5444B

Post by EdwardLaw »

Thanks for your response!

So you are saying that the device will write data to disk as soon as I start it running and will attach a flag to the sample that corresponds to the trigger point? If I wanted to have a minutes gap before my trigger event, would I have to write a minutes worth of 'uninteresting' data to disk before I could start looking at the signal I wanted to investigate?

Many thanks!

EdwardLaw
Newbie
Posts: 0
Joined: Mon Feb 13, 2017 2:25 pm

Re: Triggering data streaming 5444B

Post by EdwardLaw »

My issue is that I cannot seem to alter the trigger conditions so that it will not be immediately triggered. I have set the first argument of mv_to_adc to 3000 but it still will just write the number of samples as defined by maxpostpretriggersamples in the RunStreaming function straight from when I press enter to start the program. This is due to getting the status code 290 whilst in the SetTrigger function.

Many thanks!

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Triggering data streaming 5444B

Post by Martyn »

What you do with the data before the TriggeredAt indicator is up to you, you can just throw it away. I have tried with the default console app, which is set for a 1V trigger, and with a signal applied, the TriggeredAt occurs in the first collection of data, applying the trigger after the start and the TriggeredAT appears at the appropriate point.

I am concerned that you are getting the 290 error code with the 5V supply attached, can you start up the application and post the output, that appears in the console window, before you select to run triggered streaming.
Martyn
Technical Support Manager

EdwardLaw
Newbie
Posts: 0
Joined: Mon Feb 13, 2017 2:25 pm

Re: Triggering data streaming 5444B

Post by EdwardLaw »

That sounds exactly like what I would like to do but the trigger is not being set properly. Which version is the 'default' console app for this specific scope? I have attached a text file of the GUI before selecting triggered streaming.

Many thanks.
Attachments
Console_window.txt
(689 Bytes) Downloaded 514 times

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Triggering data streaming 5444B

Post by Martyn »

The default console app is the app from the SDK with no changes applied, and the output I have is only different in a minor version number of the driver which shouldn't be a problem.

So if you put a breakpoint on the call to StreamDataHandler just after the SetTrigger the status code is still 290 ?
Martyn
Technical Support Manager

EdwardLaw
Newbie
Posts: 0
Joined: Mon Feb 13, 2017 2:25 pm

Re: Triggering data streaming 5444B

Post by EdwardLaw »

Yes, due to the first 'if' statement in SetTrigger returning status = 290 then at that point in the code, I still have the same error code. I have not modified the code other than copying in other functionalities such as the block capture.

Cheers.

EdwardLaw
Newbie
Posts: 0
Joined: Mon Feb 13, 2017 2:25 pm

Re: Triggering data streaming 5444B

Post by EdwardLaw »

Yes the error code is still 290. Could you possibly attach a copy of the code you are using?

Cheers.

EdwardLaw
Newbie
Posts: 0
Joined: Mon Feb 13, 2017 2:25 pm

Re: Triggering data streaming 5444B

Post by EdwardLaw »

Martyn,

After reading through many other posts, it seems as though a block capture may be what I'm looking for. I would like for the picoscope to sit and wait primed for a trigger and then capture for a given duration once triggered. Ideally I would like the capture to stop once the trigger signal is below threshold. I.e a threshold voltage of 3V and I send a pulse of 3.5V to the scope on channel B to initiate capturing on channel A. The pulse width is 2s and so after 2s the scope stops capturing on channel A due to the signal on channel B not reaching threshold anymore.

Is this sort of thing possible?

Thanks for all your help!

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: Triggering data streaming 5444B

Post by Martyn »

Capturing a set amount of data after a trigger event is easy, it doesn't require an off condition to stop the capture as this will happen automatically once the data has been collected. It can be performed in both streaming and block capture modes.

The code I was using was the example in the SDK, I will answer the additional questions you have asked via your Helpdesk email ticket.
Martyn
Technical Support Manager

EdwardLaw
Newbie
Posts: 0
Joined: Mon Feb 13, 2017 2:25 pm

Re: Triggering data streaming 5444B

Post by EdwardLaw »

This issue was solved by using an updated version of 'ps5000a.dll'.

Many thanks to the PicoTech support team.

Post Reply