arbitrary sig gen

Post general discussions on using our drivers to write your own software here
ARC
Newbie
Posts: 0
Joined: Wed Aug 08, 2012 8:38 am

arbitrary sig gen

Post by ARC »

Hello,

Ive got PicoScope 2206 and i am using the SDK C console application as a DLL which is controlled by a c# windows application.

I have got the built in sig gen working but when i try to run arbitrary sig gen it reads the file fine but there is no output. it returns status 0x0000002e, im not sure what it means, i believe 0 is an error so im presuming its fine.
So i have tried .csv and .txt files of varying layouts and still nothing.

The original file im trying to send is in CSV format my delta with this file is : delta = 3436.3932672000001 any idea if this is a good value?

I have attached the original .CSV and heres a copy to try and make it easier:

Code: Select all

AREA		
8.60E+01	0.00E+00	1.00E+00
		
DATA		
0	1	
0.000001	 0	
10	0	
10.000001	 1	
11.000001	 1	
11.000002	 0	
21.000002	 0	
21.000003	 1	
22.000003	 1	
22.000004	 0	
31.000004	 0	
31.000005	 1	
32.000005	 1
32.000006	 0
40.000006	 0
40.000007	 1
41.000007	 1
41.000008	 0
48.000008	 0
48.000009	 1
49.000009	 1
49.00001	 0
55.00001	 0
55.000011	 1
56.000011	 1
56.000012	 0
61.000012	 0
61.000013	 1
62.000013	 1
62.000014	 0
66.000014	 0
66.000015	 1
67.000015	 1
67.000016	 0
70.000016	 0
70.000017	 1
71.000017	 1
71.000018	 0
73.000018	 0
73.000019	 1
74.000019	 1
74.00002	 0
75.00002	 0
75.000021	 1
76.000021	 1
86.000022	 1
so i cut this down to get rid of the first few lines and theres an arrow symbol on the last line which i removed and still nothing, so i removed the second column of numbers as well and still nothing, so i made a quick .txt file:
0.5
1
1.5
0.5
1
1.5
0.5

which is just this repeated over and over and still nothing happens.

do you know what format my files have to be in?
what does that status code mean?

Many thanks
Attachments
CI260-B.csv
(640 Bytes) Downloaded 552 times

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: arbitrary sig gen

Post by Martyn »

0 is Status OK, so any non zero value is an error as defined in picoStatus.h

Not surprisingly 2e indicates a parameter error with the sig gen call.

The csv file you have looks like the type generated by PicoScope 6, these are not what you need to pass to the SetSigGenArbitrary API call. You need a buffer :-

arbitraryWaveform, a buffer that holds the waveform pattern as a set of samples equally spaced in time. If pkToPk is set to its maximum (4 V) and offsetVoltage is set to 0, then a sample of - 32768 corresponds to -2 V, and +32767 to +2 V.
Martyn
Technical Support Manager

ARC
Newbie
Posts: 0
Joined: Wed Aug 08, 2012 8:38 am

Re: arbitrary sig gen

Post by ARC »

Great that's really helpful thank you. I got it to work with a file in its compile directory but i have tried to fun a file from a different directory and nothing.

I have tried running the below file from the console app and it says its opened the file, status returns 0 but my Oscilloscope is not showing anything.

Does it support full Directories "C:\CIGUi\Functions\test.txt"?

file:

Code: Select all

32768
-32768
-32768
-32768
-32768
-32768
-32768
-32768
-32768
-32768
-32768
32768
-32768
-32768
-32768
-32768
-32768
-32768
-32768
-32768
-32768
32768
and i have tested this in its compile directory and it wont work again?!?
Last edited by ARC on Tue Sep 04, 2012 1:53 pm, edited 1 time in total.

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: arbitrary sig gen

Post by Martyn »

Might need C:\\CIGUi\\Functions\\test.txt
Martyn
Technical Support Manager

ARC
Newbie
Posts: 0
Joined: Wed Aug 08, 2012 8:38 am

Re: arbitrary sig gen

Post by ARC »

Ah ive just spotted what i have done my values are +- 32768 which is 1 more than max :( and ive been copying that everywhere.

sorry i got it wrong. it all works now with single back slash's.

Thanks alot :)

ARC
Newbie
Posts: 0
Joined: Wed Aug 08, 2012 8:38 am

Re: arbitrary sig gen

Post by ARC »

Ok so after testing with different settings and frequencies etc im trying to create a waveform with a specific time base and i am struggling to work out the required frequency for this.

waveform:
-T+T-T+TT-T+TTT-T+TTTT-T+TTTTT-T+TTTTTT-T+TTTTTTT-T+TTTTTTTT-T+TTTTTTTTT-T+TTTTTTTTTT-TTT
so where T = 5ms you can see the simple digital waveform that should be produced my file is structured as shown before:

Code: Select all

+32767
-32767
-32767
-32767
-32767
-32767
-32767
-32767
-32767
-32767
-32767
+32767
-32767
-32767
-32767
-32767
-32767
-32767
-32767
-32767
-32767
+32767
-32767
-32767
-32767
-32767
-32767
-32767
-32767
-32767
+32767
-32767
-32767
-32767
-32767
-32767
-32767
-32767
+32767
-32767
-32767
-32767
-32767
-32767
-32767
+32767
-32767
-32767
-32767
-32767
-32767
+32767
-32767
-32767
-32767
-32767
+32767
-32767
-32767
-32767
+32767
-32767
-32767
+32767
-32767
+32767
+32767
+32767
I thought that because each line is equally spaced in time all i have to get right is the frequency. However i can only get a T of 5.2ms or 4.4ms.
for example:
20Hz = delta of 5.872026 T = 5.2ms
20.5Hz = delta of 6.0.18826 T = 4.4ms
i have gone to 6dp without getting any closer.

How can i increase the precision to get exactly 5ms or any other T?

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: arbitrary sig gen

Post by Martyn »

Whatever data you have in the waveform buffer is considered as 1 cycle so if you are generating at 20Hz this would take 50ms for each cycle so you would only need 10 points in the buffer if they were 5ms each.
Martyn
Technical Support Manager

ARC
Newbie
Posts: 0
Joined: Wed Aug 08, 2012 8:38 am

Re: arbitrary sig gen

Post by ARC »

Great thank you.

Should the PicoScope Sig Gen work with a Delta < 1?
Because whenever the delta drops to below 1 nothing is output from the PicoScope and for 5ms per line of a arbitrary file gives delta of 0.826836 so nothing is output from the PicoScope.

Any ideas?

Many thanks

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: arbitrary sig gen

Post by Martyn »

You should be looking to have an arbitrary file size that gives a delta of greater than 10 to achieve sensible results, as indicated in the console code.
Martyn
Technical Support Manager

ARC
Newbie
Posts: 0
Joined: Wed Aug 08, 2012 8:38 am

Re: arbitrary sig gen

Post by ARC »

I'm sorry to say this but we still can't get this to work has anybody been able to get an exact waveform?

I think the issue is where it is converting from double to unsigned long.

So doing lots of tests and basically as far as we can tell with delta being an integer it works like this:
Delta = 1, 26.2ms per line
Delta = 5, 5.22ms per line
Delta =10, 2.62ms per line
Delta = 20, 1.312ms per line

So how can i get it closer?
70 lines 5ms per line = 350ms per cycle 1/350 = 0.002857Hz

Which is a delta of 0.000779. so this doesn't work.

And it doesn't get any better with a 500 line file at 20Hz is a delta of 41.859 gives 640us per line but a 10 line file with delta set to 40 is 640us per line.

So is the arbfunctiongen set to these delta values and file size etc has no relevance as long as delta is set to 5 each line will always = 5.22ms/5.24ms?


Thanks for any help :)

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: arbitrary sig gen

Post by Martyn »

Have been looking at this and picked up an error in the console code. The delta phase equation is :-

Frequency = 20 MHz x ([Delta Phase] / [2 ^ (32-14)]) / [Waveform Length])

which means that the code should be

Code: Select all

double delta = ((frequency * waveformSize) / 8192.0) * 4294967296.0 * 5e-8; // delta >= 10
and not

Code: Select all

double delta = ((frequency * waveformSize) / 8192.0) * 4294967296.0 * 8e-9; // delta >= 10
Martyn
Technical Support Manager

ARC
Newbie
Posts: 0
Joined: Wed Aug 08, 2012 8:38 am

Re: arbitrary sig gen

Post by ARC »

Yes that has improved the Delta situation but if delta is set to 5 each line is 5.24 ms which is the closest we can get because delta is sent as unsigned long.

Is there anything we can do to control this better?

Many thanks

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: arbitrary sig gen

Post by Martyn »

If you change your sample waveform buffer from above to have exactly 50 values in it, and then set a frequency of 20Hz each sample will be 1ms, 50ms for the total buffer subject to the timing errors in both the 2206 and what you are viewing the signal with.

To improve situations it is better to have a much larger waveform buffer so that the pulse is covered by a number of points, and if possible keeping pulses as 1,2,4,8,16,32...... points.
Martyn
Technical Support Manager

ARC
Newbie
Posts: 0
Joined: Wed Aug 08, 2012 8:38 am

Re: arbitrary sig gen

Post by ARC »

Rite sorry for being an idiot we where concentrating on the equations in the console code and the programmer (API) manual, so now i have a 3805 line file running at 2.64Hz which gives a delta of 263.
Where 50 lines of the file is equivalent to T.
Which produces the T = 5ms that we required.

Can you confirm this is correct?

Thank you so much for all your help.
Attachments
CI260-B10.txt
(28.75 KiB) Downloaded 621 times

Martyn
Site Admin
Site Admin
Posts: 4491
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: arbitrary sig gen

Post by Martyn »

This is not an easy subject, and I have to think about it every time we get asked. It doesn't help when we copy an equation from the example code for one device to the code for another without picking it up, so sorry for that,

I will check your figures when I am back in the office on Monday, but it looks like you are on the right line.
Martyn
Technical Support Manager

Post Reply