rapidBlock

Post your .Net discussions here
Post Reply
Mikkel
Newbie
Posts: 0
Joined: Sat Sep 12, 2015 1:39 pm

rapidBlock

Post by Mikkel »

Do anyone have a working VB.net example of rapidBlock for a PicoScope5244B using the ps5000a dll?

I am not able to fully translate the C-code example given in the SDK that I downloaded.

One problem may be the status=ps5000aMemorySegments(handle,64, maxSamples) that returns "30" (hex=1E) PICO_TOO_MANY_SEGMENTS
this does not seem right since I tried to use the settings in the C-example (64 segments).

Hitesh

Re: rapidBlock

Post by Hitesh »

Hi Mikkel,

How have you defined the function ps5000aMemorySegments in your code?

Regards,

Mikkel
Newbie
Posts: 0
Joined: Sat Sep 12, 2015 1:39 pm

Re: rapidBlock

Post by Mikkel »

Yes I modified the ps5000aVBCon.vb with the following:
Declare Function ps5000aMemorySegments Lib "ps5000a.dll" (ByVal handle As Short, ByRef nSegments As UInteger, ByRef nMaxSamples As Integer) As UInteger
Declare Function ps5000aSetNoOfCaptures Lib "ps5000a.dll" (ByVal handle As Short, ByRef nCaptures As UInteger) As UInteger
Declare Function ps5000aGetNoOfCaptures Lib "ps5000a.dll" (ByVal handle As Short, ByRef nCaptures As UInteger) As UInteger

My initialization of the instrument and channelA is the same as in the vbCode posted in the SDK and I got the simple Block mode to work just fine. The problem that I am working on requires that I record a block of data (4K) every 1.25 mico seconds (800 Hz). I believe that this should be possible with the rapid block mode?

Hitesh

Re: rapidBlock

Post by Hitesh »

Hi Mikkel,

What resolution are you using and what is returned for the nMaxSamples parameter?

According to the Programmer's Guide:
Rapid block mode allows you to sample several waveforms at a time with the
minimum time between waveforms. It reduces the gap from milliseconds to less than
2 microseconds (on fastest timebase).
Which timebase index are you using? Although the gap would be less than 2 microseconds using a timebase index of (single channel at 8-bit resolution), it's possible that it may not re-arm in time for the next event if they are 1.25 us apart.

Could you collect data in streaming mode and post-process the data?

Regards,

Mikkel
Newbie
Posts: 0
Joined: Sat Sep 12, 2015 1:39 pm

Re: rapidBlock

Post by Mikkel »

Hi Hitesh,

I use 12 bit resolution (I have also tried 8 bit), timebase=15
mMaxSamples is returned with a value of zero.

I didn't consider streaming mode since I thought it was to slow.

My pc is a 64 bit windows 7 machine and I downloaded the 64 bit dll, so I suppose that this has nothing to do with the trouble?

regards

Mikkel
Newbie
Posts: 0
Joined: Sat Sep 12, 2015 1:39 pm

Re: rapidBlock

Post by Mikkel »

I just realized that I said that I needed 4K of data every 1.25 micro seconds, I meant 1.25 milli seconds of course (1/800 Hz). Sorry.

Hitesh

Re: rapidBlock

Post by Hitesh »

Ah ok :D

Rapid block mode with an 800Hz repeat should be fine.

Please post your code here or send it to support@picotech.com so that we can take a look at the call sequence.

Thanks,

Mikkel
Newbie
Posts: 0
Joined: Sat Sep 12, 2015 1:39 pm

Re: rapidBlock

Post by Mikkel »

Hi Hitesh,

I can certainly send you my messy code as it is, but I have just created a new test project where I converted the c# definitions instead (using an online converter C#->VB) in the hope that this would eliminate my mistakes. I haven't finished, but it seems to work through the ps5000aMemorySegments function which now passes with status=0.

The function definition seems identical: _
Public Function MemorySegments(handle As Short, nSegments As UInteger, ByRef nMaxSamples As Integer) As UInteger
End Function
but now it returns status=0 and nMaxSamples = 4194048.

I will keep working on this and report failure/success

regards

Mikkel
Newbie
Posts: 0
Joined: Sat Sep 12, 2015 1:39 pm

Re: rapidBlock

Post by Mikkel »

Hi Hitesh,

I solved it. The auto translation of the c# code in the SDK (use Teleriks c# to vb converter) did the trick.
Thank you for your help.

A future wish would be a dll that could be directly imported into Visual Studio (VB.NET, C#.NET and other languages) that would eliminate the need to write long import statements which obviously can go wrong. It would also support intellisense.

Regards

Mikkel

Hitesh

Re: rapidBlock

Post by Hitesh »

Hi Mikkel,

There are no plans at the present moment in time to provide dlls that can be directly imported into the Visual Studio environment.

Looking again at the function declaration in the Programmer's Guide:
PICO_STATUS ps5000aMemorySegments
(
short handle,
unsigned long nSegments,
long * nMaxSamples
)
or using the stdint.h data types:
PICO_STATUS ps5000aMemorySegments
(
int16_t handle,
uint32_t nSegments,
int32_t * nMaxSamples
)
the nSegments parameter should be passed by value rather than by reference which is where the error is likely to have occurred. So using the previous declaration style, this should be:

Code: Select all

Declare Function ps5000aMemorySegments Lib "ps5000a.dll" (ByVal handle As Short, ByVal nSegments As UInteger, ByRef nMaxSamples As Integer) As UInteger
Using the DllImport method is also valid.

Regards,

Mikkel
Newbie
Posts: 0
Joined: Sat Sep 12, 2015 1:39 pm

Re: rapidBlock

Post by Mikkel »

A belated thank you

/Mikkel

Post Reply