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
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
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
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!)
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
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.
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
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
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
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?
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