Test and Measurement Forum

Ps3204A and streaming

Post general discussions on using our drivers to write your own software here

Ps3204A and streaming

Postby Massimo » Thu Jun 09, 2011 7:50 pm

Hi,

I'm using a ps3204a device with a sofware written on my own. I have implemented a solution that use the streaming mode continuously (autostop is set to 0) but when the buffer is wrapped the device stops streaming and the autostop flag is autoset to 1. Furthermore the getstreaming function is always returning 0 samples read after that event.
I've written the application using vb.net and here you can see the call to the runstreaming function:

ReturnValue = ps3000aRunStreaming(Handle, _
32, _
PS3000A_TIME_UNITS.PS3000A_NS, _
0, _
ps3204memorysize, _
0, _
4, _
PS3000A_RATIO_MODE_AVERAGE, _
ps3204memorysize)

Thanks for your help.

Massimo
Massimo
 

Re: Ps3204A and streaming

Postby Chris » Fri Jun 10, 2011 1:21 pm

You need to use the AutoStopped function in the ps3000aWrap.dll

(Note, in vb.net a long is a 64 bit number, whereas when the documentation refers to a long, it is a 32 bit number, therefore, use interger in place of long, UInteger in place of unsigned long)

Declare Function IsReady Lib "ps3000awrap.dll" (ByVal handle As Integer) As Short
Declare Function AvailableData Lib "ps3000awrap.dll" (ByVal handle As Integer, ByRef startIndex As Integer) As UInteger
Declare Function AutoStopped Lib "ps3000awrap.dll" (ByVal handle As Integer) As Short



Do
Do
status = GetStreamingLatestValues(handle)
Loop While IsReady(handle) = 0

newSamples = AvailableData(handle, startIndex)
totalSamples = totalSamples + newSamples

System.Threading.Thread.Sleep(100)
Console.Write("Collected " & newSamples & "samples, ")
Console.Write("Index = " & startIndex & " ,")
Console.WriteLine("Total " & totalSamples)

autoStop = AutoStopped(handle)
Loop While autoStop = 0

Call ps3000aStop(handle)

Call ps3000aStop(handle)
Chris
Site Admin
Site Admin
 
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: Ps3204A and streaming

Postby Massimo » Fri Jun 10, 2011 4:48 pm

Thanks for your fast reply.

I'm sorry but I need to don't stop the acquisition. Is there a way to let the scope acquire the data without autostop due to buffer wrapping around?
Massimo
 

Re: Ps3204A and streaming

Postby Chris » Mon Jun 13, 2011 9:18 am

If you implement the code above, samples will be collected indefinatey without stopping.
Chris
Site Admin
Site Admin
 
Posts: 169
Joined: Tue Aug 17, 2010 9:00 am
Location: St. Neots

Re: Ps3204A and streaming

Postby Massimo » Mon Jun 13, 2011 10:14 pm

Hi,

thanks for your reply.
I have already tried your code using the functions in the provided SDK with the same result.
I have also implemented a solution using your snippet but the result is always the same.
About the conversion between managed and com data types I use to help myself with this hyperlink and I haven't experienced any problem until now.
http://msdn.microsoft.com/en-us/library/sak564ww.aspx

After a buffer memory wrap around the device sets the autostop flag to 1 and stops streaming.

Here is a snippet of the last implementation obtained from your snippet:

Declare Function AvailableData Lib "ps3000awrap.dll" (ByVal handle As Short, ByRef startIndex As UShort) As Integer
Declare Function AutoStopped Lib "ps3000awrap.dll" (ByVal handle As Short) As UShort
Declare Function GetStreamingLatestValues Lib "ps3000awrap.dll" (ByVal handle As Short) As UShort
Declare Function IsReady Lib "ps3000awrap.dll" (ByVal handle As Short) As UShort
Declare Function ps3000aRunStreaming Lib "ps3000a.dll" (ByVal handle As IntPtr, _
ByRef sampleInterval As UInteger, _
ByVal sampleIntervalTimeUnits As short, _
ByVal maxPreTriggerSamples As UInteger, _
ByVal maxPostTriggerSamples As UInteger, _
ByRef autoStop As Short, _
ByVal downSampleRatio As UInteger, _
ByVal downSampleRatioMode As short, _
ByVal overviewBufferSize As UInteger) As short
status= ps3000aRunStreaming(Handle, _
32, _
2, _
0, _
4194218, _
0, _
1, _
0, _
4194218)
Do
Do
status = GetStreamingLatestValues(Handle)
Loop While IsReady(Handle) = 0

newSamples = AvailableData(Handle, startIndex)
prev = prev + newSamples

System.Threading.Thread.Sleep(100)
Console.Write("Collected " & newSamples & "samples, ")
Console.Write("Index = " & startIndex & " ,")
Console.WriteLine("Total " & prev)

autoStop = AutoStopped(Handle)
Loop While autoStop = 0 Or TSTrigBtnStop.Checked

Call ps3000aStop(Handle)

Call ps3000aStop(Handle)

here is the result:
Collected 4194213samples, Index = 0 ,Total 4194213
Collected 5samples, Index = 65445 ,Total 4194218
Collected 0samples, Index = 0 ,Total 4194218

The buffer size is set to 4194218.

Could you give it a try?
My device is a Ps3204A.

Thanks for your help
Massimo
Massimo
 

Re: Ps3204A and streaming

Postby Massimo » Thu Jun 16, 2011 9:01 pm

Finally I've got it.

There were two matters:
- I've changed the runstreaming declaration, the autostop argument need to be passed byval and not byref.
- I've used the last driver. I was using 1.0.0.45 instead of 1.0.0.66

Massimo
Massimo
 


Return to General Software Discussions

Who is online

Users browsing this forum: No registered users and 2 guests