multiple scope data syncing

Post your C and C++ discussions here
Post Reply
madnugget
Newbie
Posts: 0
Joined: Thu Feb 17, 2022 3:00 am

multiple scope data syncing

Post by madnugget »

I am using a total of 5 picoscope of the ps3000 series.
I have used the example code and modified it to run as 5 independent threads.
I had use a main simple C++ code to send a start streaming 'S' (as per example code, through winsock) command to each of the scope's example code. All parallel individual scope's logging is running on the same PC.

Understand that there could be a delay in terms of triggering the data acquisition, I had added a line of code to get the system time just before the api command of ps3000aRunStreaming. I had set the sample data to be large enough for my usage and only write to file when I am done with data acquisition.

My problem faced was my triggered test pulse is not synced in all the picoscope, despite plotting data VS system time, in difference of tens of ms. My scopes are configured in timebase 9 = 56ns sample interval. May I know is there any underlying hardware timing/clock that can explain this?

I can understand that if I had plotted data VS absolute number of data point, the delay in calling of the ps3000aRunStreaming can result in the pulse not in sync (e.g if Scope A started earlier than B, it will capture more points, hence the trigger pulse will not be in sync. However, if plotting based on common logged start time, it should be)

Thanks

bennog
Advanced User
Advanced User
Posts: 208
Joined: Mon Nov 26, 2012 9:16 am
Location: Netherlands

Re: multiple scope data syncing

Post by bennog »

you have to sacrifice 1 channel on every scope to do synchronization.

because the internal oscillator of the scopes are not exactly the same.
And you have the delay of shared USB host controllers so not all scopes can transmit data at the same time.

A 10Hz square wave would be sufficient if I read your timing problem.

Benno

madnugget
Newbie
Posts: 0
Joined: Thu Feb 17, 2022 3:00 am

Re: multiple scope data syncing

Post by madnugget »

agree that the internal oscillator of the scopes are not the same and it would not be possible for exact sync. The delay caused by this, i supposed would be minute given the sampling rate.

I am not too familiar how is the exact processes going on backend. Upon calling the function ps3000aRunStreaming, i supposed data is continuously acquired from the scope is being sent to the PC buffer (driverbuffer) through the USB? I dont suppose the data is being stored on the scope and subsequently transferred to the PC through the getStreamingValue function. When you mention the delay of the USB host controller, is it referring to the following chain, code all of runStreaming->USB->scope? The rest of the data were in sync if I do a data alignment, which address the effect of internal oscillator should not be a major issue.

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

Re: multiple scope data syncing

Post by Martyn »

Once you issue the RunStreaming command data will start being returned over the USB to the driver, the memory on the device is only used as FIFO to prevent data loss if the USB bus is busy. As you can't start all scopes at the same time you will get the effect you are seeing where the data will align but at different points in the returned buffers,

If you have an identifiable point in the input signals that can be used as a trigger, you can use this with the Streaming mechanism to return a TriggeredAt sample value. This will allow you to align the data collection from different scopes within the limits of the oscillators.
Martyn
Technical Support Manager

madnugget
Newbie
Posts: 0
Joined: Thu Feb 17, 2022 3:00 am

Re: multiple scope data syncing

Post by madnugget »

Thanks Martyn for the explanation. Given that codes are run line by line, the issuing of the RunStreaming command will still be in somewhat sequential and is exactly as what you have described. I tackled the situation but logging the exact system time in ns just before the every RunStreaming command of every scope. Given that each data point was a fixed interval, I had added the sample interval to the logged time. Theoretically this should align my data but I am not observing that.

Would you be able to explain more regarding using the TriggeredAt or point me to an example on how to use it? Are you referring to the ps3000aSetSimpleTrigger? I am actually planning to multiplex a start signal (high pulled to low) into channel 1 of each scope such that I can shift all the data referencing to this start signal.
Thanks in advance!

bennog
Advanced User
Advanced User
Posts: 208
Joined: Mon Nov 26, 2012 9:16 am
Location: Netherlands

Re: multiple scope data syncing

Post by bennog »

that start signal is the way I should go for streaming.

Curious to know what other options Martin has to do this in streaming mode.

Benno

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

Re: multiple scope data syncing

Post by Martyn »

Even if you do the timing of the RunStreaming commands you can't control the time it will take the driver to act on the command and issue it to the device as this will be affected by other users of the USB bus, including the devices that have already started streaming. This timing will be random and strongly influenced by the O/S as it allocates the USB resources.

If you can multiplex a start signal that is fed into each of the devices you should be able to set up simple trigger that reads this, this will then be marked in the returned data set for each device as the TriggeredAt value. So you may have Scope 1 indicating this at sample 100 of it's data, scope 2 at sample 1234, scope 3 at 542 and so you will then be able to align the data sets with this additional knowledge.
Martyn
Technical Support Manager

madnugget
Newbie
Posts: 0
Joined: Thu Feb 17, 2022 3:00 am

Re: multiple scope data syncing

Post by madnugget »

Martyn, Thanks!My intention is to multiplex in a TTL high signal and pull it to TTL low to signal the start of my data reference and do data alignment post processing. The trigger method seems to be a more efficient method of doing it. Will you be able to advise on the proper code setup of the Trigger and extracting the TriggeredAt example?

Post Reply