Test and Measurement Forum

VB arbitrary waveform signal generation problom

Post your .Net discussions here

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Fri Jan 11, 2013 2:04 pm

What are the settings of the input channel ?
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2355
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Fri Jan 11, 2013 2:45 pm

do you mean the channel_select settings? here is the code
Code: Select all
Select Case Channel_Select.Text
      Case "A"
         channelTXT = "A"
         Call ps2000_set_channel(ps2000_handle, 0, 1, dc, cboVoltageA.ListIndex + 1)
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Fri Jan 11, 2013 2:56 pm

here is the code of signal reciption
Code: Select all
If oneChannel = "A" Then
   For i = 0 To 500
    sA(i) = (values_a(i) / 32767) * (mv_a)
    sT(i) = values_time(i) / 1000000
   
   Next i
End If
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Sat Jan 12, 2013 1:34 am

Hi
after a number of experiments, an interesting phenomena occurs to me, that is while I set the waveform buffer document(no metter .csv or .txt), the pktopk voltage varies with the different kinds of delimiters, which means if I set the delimiter as '\t', the pktopk voltage is about 228mv, if the delimiter is set as SPACE, the pktopk is 112mv; delimiter ',' corresponds to 57mv, and if I set the sequence without a delimeter the pktopk is 28mv ( the result doesn't match the sequence you sent to me which is also without a delimeter but still generates a pktopk value as 234mv, and this phenomena is also beyond my understand).
It is a confusing but interesting question, knowledgable as you are, could you please do me a faver and shine your light on the problem.
thank you
yangzhaoshu
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Sat Jan 12, 2013 9:28 am

The file I sent works with the c console example in the SDK, when parsed by the code it generates an arbitrary waveform buffer that contains a sequence of 256 bytes with hex values of 00 7f or ff.

You need to ensure that your VB parser creates such a buffer, or just manually code the buffer to test out the theory.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2355
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Sun Jan 13, 2013 2:02 am

Hi
I have test the buffer according to your suggestion, and modified my program, but an Compilation error of ' Type mismatch ' occur, could you tell me what on earth the type of the Parameter waveform, is it a string or a Array of strings? the debugging result is attached with the email.
here is the codes
Code: Select all
Private Sub arbgen()
Dim ok As Integer
ok = 1
offsetvoltage = Int(Val(Text2(0).Text) * 1000)
pktopk = Int(Val(Text2(1).Text) * 1000)
startdeltaphase = Val(Text2(2).Text)
stopdeltaphase = Val(Text2(3).Text)
deltaphaseincrement = Val(Text2(4).Text)
dwellcount = Val((Text2(5).Text))
arbitrarywavesize = 4096
ReDim arbitrarywaveform(arbitrarywavesize - 1) As String
Open "D:\Documents\Waveforms\ysquare11.csv" For Input As #2
Do While Not EOF(2)
Line Input #2, S
Loop
  Close #2
arbitrarywaveform = Split(S, "/t")
Select Case arbstype.Text
   Case "Up": sweeptype = 0
   Case "Down": sweeptype = 1
   Case "UpDown": sweeptype = 2
   Case "Downup": sweeptype = 3
End Select
sweeps = Int(Val(Text2(6).Text))
If ps2000_handle Then
  ok = ps2000_set_sig_gen_arbitrary(ps2000_handle, offsetvoltage, pktopk, startdeltaphase, stopdeltaphase, _
  deltaphaseincrement, dwellcount, arbitrarywaveform, arbitrarywavesize, sweeptype, sweeps)
End If
End Sub

thank you for helping me.
yangzhaoshu
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Sun Jan 13, 2013 3:00 am

the debugging result
Attachments
debuggingResult.JPG
the debugging result
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Mon Jan 14, 2013 7:31 am

arbitraryWaveform is not a string, it is an array of 8 bit values which represent the waveform.

Code: Select all
Dim arbitraryWaveform(12) As Integer = {255,255,255,255,127,127,127,127,0,0,0,0}


where 0 is the negative peak, 127 is zero and 255 is the positive peak values
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2355
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Thu Jan 17, 2013 8:52 am

Hi
I have tried again to modify my program, checked all the parameters and ensured the waveform as an array of integers, but the output signal is still fail to simulate the sequence I set, measured by another oscilloscope, the output waveform seems to be a periodic perturbations, while the build-in waveforms such as ‘sine’, ‘square’ and ‘triangle’ wave are generated perfectly, indicating that the PicoScope oscilloscope itself is functioning well and the created arbitrary waveform signal is still fail to be generated, and there must be something wrong in my codes shown as follow
Code: Select all
Private Sub arbgen()
Dim ok As Integer
Dim i As Integer
ok = 1
offsetvoltage = Int(Val(Text2(0).Text) * 1000)
pktopk = Int(Val(Text2(1).Text) * 1000)
startdeltaphase = Val(Text2(2).Text)
stopdeltaphase = Val(Text2(3).Text)
deltaphaseincrement = Val(Text2(4).Text)
dwellcount = Val((Text2(5).Text))
arbitrarywavesize = 500
ReDim arbitraryWaveform(1 To arbitrarywavesize) As Integer
Open "D:\Documents\Waveforms\ysquare11.csv" For Input As #2
Do While Not EOF(2)
  For i = 1 To UBound(arbitraryWaveform)
Input #2, arbitraryWaveform(i)
Next i
Loop
Close #2
Select Case arbstype.Text
   Case "Up": sweeptype = 0
   Case "Down": sweeptype = 1
   Case "UpDown": sweeptype = 2
   Case "Downup": sweeptype = 3
End Select
arbstype.ListIndex = 1
sweeps = Int(Val(Text2(6).Text))
If ps2000_handle Then
  ok = ps2000_set_sig_gen_arbitrary(ps2000_handle, offsetvoltage, pktopk, startdeltaphase, stopdeltaphase, _
  deltaphaseincrement, dwellcount, arbitraryWaveform, arbitrarywavesize, sweeptype, sweeps)
End If
End Sub

thank you for helping me
Attachments
ysquare11.csv
the sequense to build a waveform
(1.68 KiB) Downloaded 94 times
local window.JPG
the screenshot about the parameter of waveform
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Thu Jan 17, 2013 9:10 am

Can you post a picture of the waveform you see and the waveform you expect to see.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2355
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Thu Jan 17, 2013 12:06 pm

the pictures are in the attachment
Attachments
attachment.rar
pictures
(22.06 KiB) Downloaded 128 times
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Thu Jan 17, 2013 1:01 pm

Ok that helps.

Can you tell me every parameter value in this call except arbitraryWaveform which you have given

Code: Select all
ok = ps2000_set_sig_gen_arbitrary(ps2000_handle, offsetvoltage, pktopk, startdeltaphase, stopdeltaphase, _
  deltaphaseincrement, dwellcount, arbitraryWaveform, arbitrarywavesize, sweeptype, sweeps)
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2355
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Thu Jan 17, 2013 1:05 pm

The following is the line of code from the c application

Code: Select all
delta = ((frequency * waveformSize) / 4096) * 4294967296.0 * 20e-9;
   ps2000_set_sig_gen_arbitrary(unitOpened.handle, 0, 2000000, (unsigned long)delta, (unsigned long)delta, 0, 0, arbitraryWaveform, waveformSize, PS2000_UP, 0);
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2355
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Fri Jan 18, 2013 12:14 am

Dear Martyn
I've modified my parameters in AWG as your suggestions, while the effects is limited, It is seems like a periodic perturbations stilling, the parameters I set is listed as below:
Offset voltage = 0
pktopk = 800000
Startdeltaphase = delta = (frequency * arbitrarywavesize) / 4096) * 4294967296# * 0.00000002
stopdeltaphase = startdeltaphase
deltaphaseincrement = 0
dwellcount = 0
Arbitrarywaveform is attached in the file
arbitrarywavesize = 500
sweeptype=down
sweeps=0
And here is the coding I call the function
Code: Select all
Private Sub arbgen()
Dim ok As Integer
Dim i As Integer
Dim delta As Long
Dim frequency As Integer
ok = 1
offsetvoltage = Int(Val(Text2(0).Text) * 1000)
pktopk = Int(Val(Text2(1).Text) * 1000)
arbitrarywavesize = 500
frequency = 150
ReDim arbitraryWaveform(1 To arbitrarywavesize) As Integer
delta = ((frequency * arbitrarywavesize) / 4096) * 4294967296# * 0.00000002
Open "D:\Documents\Waveforms\ysquare11.csv" For Input As #2
Do While Not EOF(2)
  For i = 1 To UBound(arbitraryWaveform)
Input #2, arbitraryWaveform(i)
Next i
Loop
Close #2
Select Case arbstype.Text
   Case "Up": sweeptype = 0
   Case "Down": sweeptype = 1
   Case "UpDown": sweeptype = 2
   Case "Downup": sweeptype = 3
End Select
arbstype.ListIndex = 1
If ps2000_handle Then
  ok = ps2000_set_sig_gen_arbitrary(ps2000_handle, offsetvoltage, pktopk, delta, delta, 0, 0, arbitraryWaveform, arbitrarywavesize, sweeptype, 0)
End If
End Sub

The pictures and data of the waveforms both I want and I set are attached with the email, there is a Chinese saying goes "解铃还需系铃人", (which means In order to untie the bell, the person who tied it is required). So I convince you, as the authority in this area, will be the one finally helps me solving the problem.
Many thanks
yangzhaoshu
Attachments
attachment.rar
the data and pictures of what I get and want
(24.96 KiB) Downloaded 102 times
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Mon Jan 21, 2013 12:55 pm

Can you give the follwoing a go
Code: Select all
Module Module1

    Declare Function ps2000_open_unit Lib "ps2000.dll" () As Integer
    Declare Function ps2000_close_unit Lib "ps2000.dll" (ByVal handle As Integer) As Integer
    Declare Function ps2000_set_sig_gen_arbitrary Lib "ps2000.dll" (ByVal handle As Integer,
                                                                    ByVal offsetVoltage As Integer,
                                                                    ByVal pkTopk As Integer,
                                                                    ByVal startDeltaPhase As Integer,
                                                                    ByVal stopDeltaPhase As Integer,
                                                                    ByVal deltaphaseincrement As Integer,
                                                                    ByVal dwellcount As Integer,
                                                                    ByRef arbitrarywaveform As Byte,
                                                                    ByVal arbitrarywavesize As Integer,
                                                                    ByVal sweeptype As Integer,
                                                                    ByVal sweeps As Integer) As Integer
    Dim ps2000_handle As Integer


    Sub Main()
        Dim ok As Integer
        Dim delta As Integer
        Dim frequency As Integer
        Dim offset As Integer
        Dim peak As Integer
        Dim increment As Integer
        Dim dwell As Integer
        Dim sweepType As Integer
        Dim sweeps As Integer
        Dim arbitraryWaveform(12) As Byte
        Dim arbitrarywavesize As Integer

        arbitraryWaveform = {255, 255, 255, 255, 127, 127, 127, 127, 0, 0, 0, 0}
        arbitrarywavesize = 12
        frequency = 10000   
        offset = 0
        peak = 800000
        increment = 0
        dwell = 0
        sweepType = 0
        sweeps = 0
        delta = ((frequency * arbitrarywavesize) / 4096) * 4294967296.0# * 0.00000002
        ok = 1
        ps2000_handle = ps2000_open_unit()

        If ps2000_handle Then
            ok = ps2000_set_sig_gen_arbitrary(ps2000_handle, offset, peak, delta, delta, increment, dwell, arbitraryWaveform(0), arbitrarywavesize, sweepType, sweeps)
        End If

        ps2000_close_unit(ps2000_handle)
    End Sub

End Module
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2355
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

PreviousNext

Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 0 guests