Hi, I bought my PCSU1000 to measure phase between two signals, measuring result I want to use in my application. How can i do it, thanks in advance!
[quote]Hi, I bought my PCSU1000 to measure phase between two signals, measuring result I want to use in my application. How can i do it, thanks in advance![/quote]I’m sorry this is not possible with the supplied DSOLink.DLL.
The Phase is a calculation result. No calculation results are exported by the DSOLink.DLL.
There are only two functions to retrieve the oscilloscope data: ReadCh1 and ReadCh2.
These functions can be used to retrieve the raw oscilloscope data in A/D converter counts (0…255), Sample rate, Full scale and GND level values.
[quote=“VEL255”][quote]Hi, I bought my PCSU1000 to measure phase between two signals, measuring result I want to use in my application. How can i do it, thanks in advance![/quote]I’m sorry this is not possible with the supplied DSOLink.DLL.
The Phase is a calculation result. No calculation results are exported by the DSOLink.DLL.
There are only two functions to retrieve the oscilloscope data: ReadCh1 and ReadCh2.
These functions can be used to retrieve the raw oscilloscope data in A/D converter counts (0…255), Sample rate, Full scale and GND level values.[/quote]
VEL255, your software using DSOLink.DLL to calculate phase? May be you can give advice how in my application I can get phase (function or library) from PCSU1000. Thank you for your answer!
[quote]VEL255, your software using DSOLink.DLL to calculate phase?[/quote]I’m sorry, I do not have any software to calculate the phase from the DSOLink.DLL output.
[quote]May be you can give advice how in my application I can get phase (function or library) from PCSU1000.[/quote]Calculating the phase is not an easy task. The principle is to multiply the CH1 and CH2 waveforms sample by sample together. Then shift the other waveform and multiply again. When the resulting amplitude of the multiply result is highest the waves are ‘aligned’. Based on the shift needed to ‘align’ the waveforms you can calculate the phase.
Here an example of the phase calculating procedure used in the PCSU1000 software.
The original CH1 and CH2 data is in data1 array.
[size=85]data1:array [0..4096*2] of integer;
phasedata:array [0..4096*10] of integer;
[code]function Tform1.calculate_phase: real;
var i, j, a, b, d, x, nx1, nm1, tulos, av1, av2, av3:longint;
ph, ph1, ph2:real;
results: array[0…300] of longint;
kudata: array[0…2000] of longint;
minfound1, maxfound1:boolean;
maksimi1,minimi1, imax1, imin1: array[0…10] of longint;
a_data, p_data:pointer;
label 1;
begin
b:=0;
for i:=0 to 4095 do
begin
b:=b+data1[i+4096];
a:=(data1[i+1]-data1[i]);
for j:=0 to 9 do phasedata[i*10+j]:=(10data1[i]+ja);
end;
b:=b div 4096;
for i:=0 to 2000 do
begin
if i<1001 then kudata[i]:=(i*(data1[4096+i]-b)) // div 1000)
else kudata[i]:=((2000-i)*(data1[4096+i]-b)); // div 1000);
end;
minfound1:=false;
maxfound1:=false;
for i:=0 to 10 do maksimi1[i]:=$7fffffff;
for i:=0 to 10 do minimi1[i]:=$7fffffff;
for i:=0 to 10 do imax1[i]:=0;
for i:=0 to 10 do imin1[i]:=0;
nx1:=0;
nm1:=0;
p_data:=@phasedata[0];
a_data:=@kudata[0];
for i:=0 to 20000 do
begin
tulos:=0;
asm
push esi
push edi
push ecx
push ebx
push edx
mov edi,p_data
mov esi,a_data
add edi,i
add edi,i
add edi,i
add edi,i {phasedata start point shifted}
mov ecx,2000
@looppi2:
mov eax,ds:[esi]
mov ebx,ds:[edi]
imul ebx
sar eax,11 //div 2000
add esi,4
add edi,40
add eax,tulos
mov tulos,eax
loop @looppi2
pop edx
pop ebx
pop ecx
pop edi
pop esi
end;
results[0]:=tulos;
for j:=299 downto 0 do results[j+1]:=results[j];
av1:=0;
for j:=0 to 9 do av1:=av1+results[j];
av2:=0;
for j:=145 to 154 do av2:=av2+results[j];
av3:=0;
for j:=290 to 299 do av3:=av3+results[j];
if (i>300) and (av1<av2) and (av3<av2) then //high peak
begin
if not maxfound1 or (abs(av3-av1)<maksimi1[nx1]) then
begin
maksimi1[nx1]:=abs(av3-av1);
imax1[nx1]:=i-150;
maxfound1:=true;
if minfound1 then inc(nm1);
minfound1:=false;
end;
end;
if (i>300) and (av1>av2) and (av3>av2) then //low peak
begin
if not minfound1 or (abs(av1-av3)<minimi1[nm1]) then
begin
minimi1[nm1]:=abs(av1-av3);
imin1[nm1]:=i-150;
minfound1:=true;
if maxfound1 then inc(nx1);
maxfound1:=false;
end;
end;
if (nx1>2) and (nm1>2) then goto 1;
end;
1:
d:=imax1[1]-imax1[0];
a:=imax1[0];
b:=imax1[1];
if imax1[0]<200 then
begin
d:=imax1[2]-imax1[1];
a:=imax1[1];
b:=imax1[2];
end;
if a>d then
repeat
a:=a-d;
until a<=d;
x:=a-d;
if abs(x)>abs(a) then x:=a;
ph1:=0;
if d>0 then ph1:=360*x/d;
d:=imin1[1]-imin1[0];
a:=imin1[0]+d div 2;
b:=imin1[1]+d div 2;
if imin1[0]<200 then
begin
d:=imin1[2]-imin1[1];
a:=imin1[1]+d div 2;
b:=imin1[2]+d div 2;
end;
if a>d then
repeat
a:=a-d;
until a<=d;
x:=a-d;
if abs(x)>abs(a) then x:=a;
ph2:=0;
if d>0 then ph2:=360*x/d;
if ph1*ph2>0 then ph:=(ph1+ph2)/2 else ph:=ph1;
if ph1=0 then ph:=ph2;
if ph2=0 then ph:=ph1;
result:=ph;
end;[/code][/size]
Hi, VEL255.
thanks for the advice,
But, a week I suffer with Delphi, I actually have not turned out to connect your code. I’ll be very grateful if you create a program that would be exported result of calculation phase to DLL, as DSOLink. With DSOLink I have no problems. I very need to use in my application phase. I can pay you for your work.
Sorry for my English (Google Translate)
Here you can download a working “Waveform Monitor” demo written in Delphi:
app.box.com/s/d25yxeyv82zwd495hcwnl6cb2qt1xyvh
It displays the waveforms and calculates the phase.
You just need to have the PCSU1000 running.
Here an example screenshot:
If you do not need the waveform display but only the phase, you can modify the procedure TForm1.Timer1Timer to look like this:[code]procedure TForm1.Timer1Timer(Sender: TObject);
var i,x,y,n: integer;
p: pointer;
begin
if DataReady then
begin
Timer1.enabled:=false;
p:= @data[0];
ReadCh1§;
for i:=0 to 4095 do
data1[i+4096]:=data[i+3];
p:= @data[0];
ReadCh2(p);
for i:=0 to 4095 do
data1[i]:=data[i+3];
label2.caption:=floattostr(calculate_phase);
Timer1.enabled:=true;
end;
end;[/code]