Readng multiple channels from API

Post any questions you may have about our current range of oscilloscopes
Post Reply
amiurunkj
Newbie
Posts: 0
Joined: Fri Feb 10, 2017 1:58 am

Readng multiple channels from API

Post by amiurunkj »

Hi Everybody,

I have a Picoscope 5242A device connected to my PC, and I would like to read the data from two channels in block mode (and later maybe streaming mode) using python.

My question is: how to do that? With one channel it is no problem, but when I have two I cannot tell the ps5000aGetValues command which channel to read, it does not have an argument for that. Even though I have activated both channels, when I read the data, I get a series of data points which seem to come from Ch1.

Any help would be greatly appreciated!

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

Re: Readng multiple channels from API

Post by Martyn »

You need to specify buffers using ps5000aSetDataBuffer or ps5000aSetDataBuffers for all of the enabled channels. The driver will then populate these buffers with the correct data when requested by ps5000aGetValues.
Martyn
Technical Support Manager

amiurunkj
Newbie
Posts: 0
Joined: Fri Feb 10, 2017 1:58 am

Re: Readng multiple channels from API

Post by amiurunkj »

Thank you so much!

I have segmented the memory into two and assigned a buffer to each segment, and I am trying to invoke ps5000aGetValues for each of them, but I receive PICO_NO_SAMPLES_AVAILABLE error. This should mean that the run has not been completed which I don't understand, I wait sufficiently long before moving to the next command.

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

Re: Readng multiple channels from API

Post by Martyn »

Can you post your code, we can then see where it is going wrong.
Martyn
Technical Support Manager

fredschreck
Newbie
Posts: 0
Joined: Tue Feb 20, 2018 10:25 am

Re: Readng multiple channels from API

Post by fredschreck »

Hello there.

I have a similar problem, I configured channesl A,B & C to capture data and set an simple trigger to A. Afterwards I divide the buffer in 3 segments and try to collect them after an trigger event (see code below). I want to capture data on all channels after one trigger event, but it seems that the device is waiting for a trigger event to collect each segment, so the total collection takes 3 seconds with an input signal of 1 Hz at channel A. (Tried with only 2 Channels -> 2 seconds).

How do I capture and collect data on 3 Channels simultaneously? I played around with overlapping segments but it resulted in the same behaviour.

Code: Select all

ps.set_memory_segments(3)
stat, buf1 = ps.locate_buffers(channel=ps.m.Channels.A, samples=100, start_segment=0, stop_segment=0, mode=ps.m.RatioModes.raw, downsample=1)
stat, buf2 = ps.locate_buffers(channel=ps.m.Channels.B, samples=100, start_segment=1, stop_segment=1, mode=ps.m.RatioModes.raw, downsample=1)
stat, buf3 = ps.locate_buffers(channel=ps.m.Channels.C, samples=100, start_segment=2, stop_segment=2, mode=ps.m.RatioModes.raw, downsample=1)

#ps.set_overlapped_buffers( [ buf1[0], buf2[0], buf3[0] ])

StartTime = time.time()
ps.collect_segments(start_segment=0, stop_segment=2, interval=10, block=True)
#ps.collect_segment_overlapped(buf1[0], interval=10, block=True)
#ps.collect_segment_overlapped(buf2[0], interval=10, block=True)
#ps.collect_segment_overlapped(buf3[0], interval=10, block=True)
EndTime = time.time()
print EndTime-StartTime #-> gives 3 seconds

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

Re: Readng multiple channels from API

Post by Martyn »

You don't need to segment the memory to collect data from multiple channels, all channels are contained within a single segment.

You just need to use ps5000aSetDataBuffer or ps5000aSetDataBuffers three times, once for each channel, and then ps5000aGetValues which will read the channel data from the scope into these buffers.
Martyn
Technical Support Manager

fredschreck
Newbie
Posts: 0
Joined: Tue Feb 20, 2018 10:25 am

Re: Readng multiple channels from API

Post by fredschreck »

Okay, it seems that I misunderstood the concept of a segment until now.
Now it works like a charm.

Thanks,
Fred

Post Reply