Test and Measurement Forum

Picoscope 3224, Excel & fast_streaming_ns

Post your VB and VBA discussions here

Picoscope 3224, Excel & fast_streaming_ns

Postby bforb » Sun Jan 20, 2008 6:11 am

I have had a frustrating day trying to get fast_streaming_ns working with excel/VBA.
I had been quite successful getting the Picoscope to run under Excel in block mode, more or less continuously collecting datapoints into a spreadsheet every 0.5 s (where each point actually is calculated - essentially averaged, using a 4th channel timing signal -- from 1000 0.5 ms points, each of which is 78x oversampled), with simultaneous graphing etc. etc. Things slow down a bit when the spreadsheet gets many thousand points, but that can be fixed by refreshing excel less often.
I thought I would make it a bit more efficient (collecting all the data instead of 80-90% of it) by using fast_streaming_ns with a callback to my own C++ dll to gather my data, with excel polling the C++ package now and then for my data. This would have worked nicely if ps3000 continued to callback my C routine every time it had a certain amount of new data -- however it actually does not do this, so overall I don't think the approach is useful. Meanwhile however I made a few observations trying to call fast_streaming from Excel; maybe these will be of interest to someone:
(a) The time units argument (PS3000_TIME_UNITS) (enum) has to be declared as a long in VBA, otherwise ps3000_run_streaming_ns will return 0 every time. I don't think there is a problem declaring all those unsigned longs as long but maybe I am missing something.
(b) ps3000_get_steaming_last_values returns a 0 or 1, never a larger number (max_samples in the docs?)
(c) Whenever I set autostop to 0, ps3000_run_streaming_ns returns 0 (fails to run streaming). So I can not figure out how to keep it running continuously, which would have been the idea. [variables surrounding this one in the argument list seem to do what they should, so I don't think this is a matter of incorrect function definition.]
(d) If the overview_buffer_size is much smaller than max_samples, excel crashes bigtime. I guess this is the painful way to check ps3000_overview_buffer_status. I did use the magic number 18349 successfully (see other post), what's with that particular number, someone's birthday?
(e) My callback works fine using the AddressOf operator. Each time I feed it to get_streaming_last_values it calls me back once (sometimes twice!?) with part of the data, but not continuously as long as there is data, as I had hoped.

Essentially I was hoping fast_streaming_ns and my C function could handle data collection and accumulation in the background with Excel VBA just worrying about updating the spreadsheet now and then without worrying about missing datapoints. But fast_streaming is not designed to run and callback continuously that way. I could presumably do this with a separate thread myself, but I don't think I want to undertake that.
Related to this, it would be really nice if fast_streaming or conventional streaming did oversampling (as an alternative to aggregation), that would make life a lot easier also.
Posts: 1
Joined: Sun Jan 20, 2008 5:08 am
Location: New Haven, CT USA

Postby ziko » Wed Feb 13, 2008 9:34 am

Hi and thank you for your post. I have forwarded your feedback to the relevant people.

Kind regards

Technical Specialist
Zen Master
Zen Master
Posts: 1705
Joined: Fri Dec 01, 2006 10:03 am
Location: St Neots

Return to VB and VBA (Excel, Access)

Who is online

Users browsing this forum: No registered users and 0 guests