Test and Measurement Forum

VB arbitrary waveform signal generation problom

Post your .Net discussions here

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Tue Jan 22, 2013 1:05 am

Dear Martyn
There may be sth wrong in the code you sent to me, as I debugging your code, the error of overflow occurs several times, after a serial of modification, there is still an overflow error in the following sentence

Code: Select all
ok = ps2000_set_sig_gen_arbitrary(ps2000_handle, offset, peak, delta, delta, increment, dwell, arbitraryWaveform(0), arbitrarywavesize, sweepType, sweeps)

the parameter of delta=((frequency * arbitrarywavesize) / 4096) * 4294967296.0# * 0.00000002 has also confronted with the overflow error, so I set delta=0, is it valid?
yangzhaoshu
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby yangzhaoshu » Tue Jan 22, 2013 5:00 am

Dear Martyn
There may be sth wrong in the code you sent to me, as I debugging your code, the error of overflow occurs several times, after a serial of modification, there is still an overflow error in the following sentence
Code: Select all
ok = ps2000_set_sig_gen_arbitrary(ps2000_handle, offset, peak, delta, delta, increment, dwell, arbitraryWaveform(0), arbitrarywavesize, sweepType, sweeps)

And I have set delta=0 because it also confronted with the overflow error.
By the way, I figure you have set the parameter of arbitrarywaveform in the function as ‘arbitraryWaveform(0)’, is that means the parameter should be set as a pointer to the sequence instead of the sequence itself?
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Tue Jan 22, 2013 7:10 am

I ran this code without error and produced an 800mV peak to peak stepping wave on my system here at the frequency 10kHz as set by frequency. Can you try creating a brand new Windows Console Project in Visual Studio and cutting and pasting the code into this and trying again.

I have Windows 7 32bit running Visual Studio 2010, what is your setup ?

arbitrarywaveform has to be a pointer to the sequence as defined in the function declaration
Code: Select all
ByRef arbitrarywaveform As Byte
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 » Tue Jan 22, 2013 10:07 am

I'm using VB6.0, does it matters a lot?
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Tue Jan 22, 2013 10:17 am

Yes it does matter, how you define and use parameters will be different between the versions hence the errors with my code. All the support that we have been giving has been for VB.Net which is why it hasn't been working as is. We don't run VB6 so can't produce or test any code.

You could download the free express edition of VB.Net from Microsoft and give that a go using the code we have supplied, otherwise you will need to work through the parameter types yourself to get the correct versions.

I have used Integer in my declarations because this is what .Net requires for Longs so you will need to backtrack a bit and reinstate the Long declarations for the relevant parameters. The key for you will be to pass the reference to the first byte in the waveformbuffer which will be an array of bytes.
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 » Tue Jan 22, 2013 11:18 am

Dear Martyn
I have to use VB 6.0, because the whole system is written by it, do you mean that I have to set the parameter of arbitrarywaveform as the first element of the sequence, and where can I get some professional support of programming pico by VB6.0 on your Forum?
Sorry for the trouble made for you, while,actually I am a very beginner in programming.
Thank you for your patience
yangzhaoshu
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Tue Jan 22, 2013 11:49 am

Try the declaration as
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,
                                                                    ByRef arbitrarywaveform As Byte,
                                                                    ByVal arbitrarywavesize As Long,
                                                                    ByVal sweeptype As Integer,
                                                                    ByVal sweeps As Long) As Integer


and then define the parameters accordingly, and pass the reference to the first byte of the array.
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 » Tue Jan 22, 2013 12:29 pm

hi
i have modified the code, and it seems work, but as i set a sine signal the signal output is just like a serial of sequare wave signal which the envelope forms a part of sine wave
the output signal is tested by another oscillosope, the result is pictured, and attached with the email
thank you
Attachments
test result.JPG
test result
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Tue Jan 22, 2013 1:21 pm

Either change the frequency in the signal generator code, or change the sampling rate on the scope, but change only one of these as it looks a bit like aliasing.
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 » Wed Jan 23, 2013 12:07 am

Dear Martyn
I have change the frequency along in the following codes,
Code: Select all
delta = ((frequency * arbitrarywavesize) / 4096) * 4294967296# * 0.00000002

which makes little difference, as you suggestion the next step should be checking the sampling rate, that confused me a lot: does the sampling rate, as a factor in data reception, make a difference in the problem in signal generating problem? Tested by another oscilloscope, it is definitely a generating problem instead of a reception problem.
Another picture about the signal the pico has generated is attached, hope it helps.
Thank you very much
Your Chinese fellow
yangzhaoshu
Attachments
pic.rar
the signal I get and want
(6.2 KiB) Downloaded 97 times
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Wed Jan 23, 2013 7:02 am

Are you still using your 500 byte waveform buffer ?

What frequency values have you tried ?

What settings do you have your TEK scope set to (timebase / sample interval / no of samples per screen) ?

I will try and replicate the effect here if I can.
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 » Wed Jan 23, 2013 9:43 am

Thank you, I have done a serial of experiments, with different frequencies and buffersize, the results are attached, I hopes it will help.
Attachments
data&pic.rar
(104.03 KiB) Downloaded 100 times
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Thu Jan 24, 2013 10:26 am

Can you try with the maximum size waveform buffer of 4096 bytes, at a few frequencies.
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 » Thu Jan 24, 2013 12:07 pm

the experiments have been done according to your requirement, the result is attached.
Attachments
data&pic.rar
(118.04 KiB) Downloaded 100 times
yangzhaoshu
Newbie
 
Posts: 0
Joined: Sat Jan 05, 2013 12:46 pm

Re: VB arbitrary waveform signal generation problom

Postby Martyn » Thu Jan 24, 2013 12:40 pm

Can you change the scope you are using to look at the trace so that it's sampling interval is much quicker.

At present it appears to be 102.4 usecs per sample, I would like to see the results with it at 1usec if possible, or a timebase of 1ms where it currently shows 100ms.
Martyn
Technical Specialist
Martyn
Site Admin
Site Admin
 
Posts: 2280
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 2 guests