Test and Measurement Forum

VB arbitrary waveform signal generation problom

Post your .Net discussions here

VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Sun Jan 06, 2013 5:16 am

Hi
I have recently acquired a PicoScope 2203 Oscilloscope for the purpose of using the AWG to output a waveform signal in arbitrary form in VB.
According to the Programmer’s Guide, I call the function of ‘ps2000_set_sig_gen_arbitrary’, and a window pop up writing ‘error49, DLL Calling convention error’ I guess the error may be accrued in the parameter of ‘arbitrarywaveform’, but I fail to figure it out.
I am posting the code I am using at the moment to turn on the generator. Can someone shine his or her light onproblems, please?
The calling code in main program
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 = Int(Val(Text2(2).Text))
stopdeltaphase = Int(Val(Text2(3).Text))
deltaphaseincrement = Int(Val(Text2(4).Text))
dwellcount = Val((Text2(5).Text))
Open "D:\Documents\Waveforms\y11.csv" For Input As #2
Do While Not EOF(2)
Line Input #2, S
Loop
arbitrarywaveform = S
arbitrarywavesize = 501
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

The declaration code in module
Code: Select all
Declare Function ps2000_set_sig_gen_arbitrary Lib "ps2000.dll" _
(ByVal handle As Integer, _
ByVal offsetvoltage As Long, _
ByVal pktopk As Long, _
ByVal startdeltaphase As Long, _
ByVal stopdeltaphase As Long, _
ByVal deltaphaseincrement As Long, _
ByVal dwellcount As Long, _
ByVal arbitrarywaveform As Variant, _
ByVal arbitrarywavesize As Long, _
ByVal sweeptype As Integer, _
ByVal sweeps As Long) As Integer
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Hitesh » Mon Jan 07, 2013 1:48 pm

Hi,

What version of VB are you using?

I notice that you have the following in the declaration:

Code: Select all
ByVal arbitrarywaveform As Variant, _


Are you able to define this as a a String? Are your data values for the generator in the range 0 - 255?

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 1997
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Tue Jan 08, 2013 5:08 am

Hi
thank you for your help, I've refined my program acording to your suggestion, and the problem was finally worked out. now I have sth new to ask, that is: is there a lower limit of pktopk voltage in the function of ps2000SetSigGenBuiltIn, because once I set my pktopk voltage below 500mV (more or less), and connected the Ports of SIGNALOUT and CHA, I can get nothing but noise, when I set the pktopk voltage above 800mV, the output in channal A matched the output signal very well.
大恩未敢言谢
(which means: your help is too precious for me to say thank you!)
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Hitesh » Tue Jan 08, 2013 5:17 pm

Hi yangzhaoshu,

The specification for the PicoScope 2203 AWG is:

Output range ±250 mV to ±2 V pk–pk with ±1 V offset


The minimum value for pkToPk would be 500.

I hope this helps.
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 1997
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Wed Jan 09, 2013 11:35 am

thank you for your help but as I referred to my manual, I cannot find the details of the signal generator as your quote, coud you do me a favor to tell me where to get a more detailed one
thank you for helping me
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Thu Jan 10, 2013 7:16 am

ysquare.csv
the sequense to generate a waveform
(770 Bytes) Downloaded 124 times
Hi Hitesh
I have encountered another problem when I use ps2203 to generate a arbitrary signal, the waveform of the signal is successfully generated by the sequence stored in buffer, but the pktopk voltage generated by AWG cannot meet the set pktopk value in AWG function parameter, as I set the pktopk voltage as 800mV, while the output pktopk voltage is just 40mv measured by the Voltmeter, the code is shown as below, please do me a faver to solve the problem.
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))
Open "D:\Documents\Waveforms\ysquare.csv" For Input As #2
Do While Not EOF(2)
Line Input #2, S
Loop
arbitrarywaveform = S
arbitrarywavesize = 256
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)
  Close #2
End If
End Sub

and the sequence is attached with this email
我对你的敬佩犹如滔滔江水延绵不绝
(which means: My admiration for you is like a surging river stretches without a break)
yangzhaoshu
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Hitesh » Thu Jan 10, 2013 12:19 pm

Hi yangzhaoshu,

The specification can be found here:

http://www.picotech.com/discontinued/PicoScope2203.html

You need to make sure that your values for the AWG are integers in the range 0 -> 255 where

0 corresponds to -1
127 should correspond to 0
255 corresponds to +1

When you then set pkToPk to 800mV - you should find you get a waveform in the range +/- 400mV

I hope this helps.

Ps. Here's some quotes for you - I hope you like them :)

帮助曾经伤害过不要 - Help Ever, Hurt Never
这条河的努力,渴望和斗争合并的海从它的 - The river strives, yearns and struggles to merge with the sea from which it originates.
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 1997
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Thu Jan 10, 2013 1:13 pm

Hi Hitesh
thanks for your help and your quotes, as it was said 'help ever, hurts never', helpful as you are, I guess, will never be hurted.
yangzhaoshu
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 5:10 am

Hi Hitesh
I have tried to refine my programs by the solution you told, setting all the values in waveform buffer as integers between 0 and 255, unfortunately, the output signal still fail to meet the pktopk voltage set in the AWG function, there may be sth wrong in other parameters in the function, which are listed as follow
offset voltage(mv) 0
pktopk voltage(mv) 800
start delta phase 0
stop delta phase 60
delta incremet 1
dwellcount 1
arbitrarywaveformsize 256
And the refined waveform sequence is attached with this email.
Could you please do me a faver to chack the parameters and programs again, because an effctive arbitrary signal output is crucial to my subject, and that's why I trust Pico Technoledgy.
yangzhaoshu
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 5:14 am

the refined waveform sequence attachment
Attachments
ysquare1.csv
refined sequence
(852 Bytes) Downloaded 107 times
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Hitesh » Fri Jan 11, 2013 10:47 am

Hi yangzhaoshu,

Looking at your parameters, I can see the following:

offset voltage(mv) 0 - This is in microvolts
pktopk voltage(mv) 800 - This is in microvolts and so should be 800000

When you read the values into 'arbitrarywaveform', what values appear in the array? Are you able to put a breakpoint and then verify the data values are as expected?

Regards,
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 1997
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: VB arbitrary waveform signal generation problom

Postby Hitesh » Fri Jan 11, 2013 11:06 am

One further tip suggested by a colleague - try using

Code: Select all
Val(Convert.ToByte(string))


to ensure the values read in are correct.

It's probably better to have your values in a column and read them in line by line.
Hitesh

Technical Specialist
Pico Technology
Hitesh
Site Admin
Site Admin
 
Posts: 1997
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Fri Jan 11, 2013 12:13 pm

Hi Hitesh
the offset voltage and the pktopkvoltage set are right because in my code the both parameters are multiplied by 1000 shown as below
Code: Select all
offsetvoltage = Int(Val(Text2(0).Text) * 1000)
pktopk = Int(Val(Text2(1).Text) * 1000)

As a breakpoit was put in the programs, I found the values in the buffer had succesfully flown in to the parameter of waveform
I have capture the screenshots about the problem in the attachment, and the signal reception parts of the program is detected by the build in signal output, proving its well-functioning, which means the problem should happen in the part of signal generating. could you please help me to solve the problem, Almighty Hitesh.
many thanks
yangzhaoshu
Attachments
screenshot.rar
the screenshot about the function problem
(59.66 KiB) Downloaded 90 times
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Fri Jan 11, 2013 1:13 pm

Can you try with the attached modification of your file
Attachments
ysquare1.txt
Changed to text
(852 Bytes) Downloaded 111 times
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2280
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Fri Jan 11, 2013 1:33 pm

I tried and the pktopk reach to 147mv with a 800mv pktopk set, so it still cannot reach my expection
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Next

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

Who is online

Users browsing this forum: No registered users and 0 guests