Skip to content

Commit a22599c

Browse files
author
JLJu
committed
Deltap zeroing data test in Scilab
Deltap zeroing data test in Scilab
1 parent bd6c5d0 commit a22599c

1 file changed

Lines changed: 158 additions & 0 deletions

File tree

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
//Zerodp.sce Calculate zerodpvalue that is the true sensor zero reading
2+
//ADC Asgard CSV Loader. JLJ . Basicairdata
3+
exec('rhoair.sci')
4+
exec('viscosityair.sci')
5+
exec('ISAaltitude.sci')
6+
clc
7+
//Q = csvRead("LG3-50HZ.CSV") //Field data <- Buono
8+
Q = csvRead("LG57600.CSV") //Field data
9+
[r c]=size(Q);
10+
ngroups=20;//Number of data sets
11+
fsample=0; //Averaged value of fsample
12+
basetime=Q(1,17); //Starting mills
13+
RH=0; //Relative humidity
14+
//Define columns -> data correspondence
15+
//Raw sensor data
16+
deltapcol=3; //Deltap column is #3;
17+
abscol=4; //Abspressure column is #4;
18+
exttempcol=5; //External temp is #5;
19+
tempdeltapcol=6; //Temp from deltap sensor #6;
20+
tempabscol=7; //Temp from Abs pressure sensor #7;
21+
//Measurements
22+
absmcol=9;
23+
IASmcol=13;
24+
TASmcol=14;
25+
ExtTempmcol=10;
26+
tempdeltapmcol=11;
27+
tempabsmcol=12;
28+
altitude=15;
29+
OAT=16;
30+
rhoairmcol=22;
31+
vair=23;
32+
Re=24;
33+
cfactor=25;
34+
//Define tollerance band
35+
airdensityeband=0.5; //Air Density Percent of rho
36+
viscosityeband=2;//Viscosity %
37+
altitudeeband=0.5;//Altitude %
38+
fsamplev=zeros(1,ngroups);
39+
40+
//Calculate the average sample frequency from the samples
41+
//Divide the data in ngroups
42+
[pippo maxcount]=size(1:r/ngroups:r)
43+
for ng=1:ngroups
44+
for i=1: maxcount
45+
fsamplev(ng)=fsamplev(ng) + 1000/((Q(3+ng*maxcount+i,17)-Q(2+ng*maxcount+i,17)))
46+
end
47+
fsamplev(ng)= fsamplev(ng)/ngroups;
48+
end
49+
fsample=mean(fsamplev)
50+
//FFT Plot
51+
N=r; //Number of ADC Samples
52+
sample_rate=fsample;
53+
f=sample_rate*(0:(N/2))/N; //associated frequency vector
54+
n=size(f,'*')
55+
fig=scf(1);
56+
clf(1);
57+
fig.figure_name='Fast Fourier Transform of ADC Samples';
58+
//Deltap
59+
subplot(2,2,1)
60+
xtitle('Deltape Sensor, Frequency [Hz] vs FFT')
61+
y=fft(Q(:,deltapcol)-mean(Q(:,deltapcol)));
62+
plot(f',abs(y(1:n)))
63+
//External Temperature
64+
subplot(2,2,2)
65+
xtitle('External Temp Sensor, Frequency [Hz] vs FFT')
66+
y=fft(Q(:,exttempcol)-mean(Q(:,exttempcol)));
67+
plot(f',abs(y(1:n)))
68+
//Temperature from deltap sensor
69+
subplot(2,2,3)
70+
xtitle('Temp from Deltap Sensor ,Frequency [Hz] vs FFT')
71+
y=fft(Q(:,tempdeltapcol)-mean(Q(:,tempdeltapcol)));
72+
plot(f',abs(y(1:n)))
73+
//Average of sample frequency
74+
subplot(2,2,4)
75+
xtitle('Average value of sample frequency vs #different data sets')
76+
[r c]=size(fsamplev)
77+
cla=1:c
78+
plot(cla,fsamplev,'-')
79+
80+
//Time plot
81+
//Need time
82+
figtime=scf(2);
83+
clf(2);
84+
timetic=Q(:,17)-basetime
85+
figtime.figure_name='Measurements and Calculations';
86+
//IAS [m/s]
87+
subplot(3,2,1)
88+
xtitle('Indicated Air Speed [m/s] vs Time [ms]')
89+
plot(timetic,Q(:,IASmcol),2)
90+
//TAS [m/s]
91+
subplot(3,2,2)
92+
xtitle('True Air Speed [m/s] vs Time [ms]')
93+
plot(timetic,Q(:,TASmcol),2)
94+
//External temperature [°K]
95+
subplot(3,2,3)
96+
xtitle('External Temperature [°K] vs Time [ms]')
97+
plot(timetic,Q(:,ExtTempmcol),2)
98+
//Temperature deltapsensor [°K]
99+
subplot(3,2,4)
100+
xtitle('Temperature from deltap pressure sensor [°K] vs Time [ms]')
101+
plot(timetic,Q(:,tempdeltapmcol),2)
102+
subplot(3,2,5)
103+
xtitle('Deltap sensor counts vs Time [ms]')
104+
plot(timetic,Q(:,deltapcol),2)
105+
106+
//Time plot compensated measurement
107+
//8192 is the nominal zero for the sensor
108+
//1 psi to 6894.75729
109+
csensor=6894.75729/8191
110+
zerodatasheet=8192;
111+
zerodpvalue=zerodatasheet-mean(Q(:,deltapcol))
112+
compdeltap=Q(:,deltapcol)+zerodpvalue
113+
figtime=scf(3);
114+
clf(3);
115+
//Raw from sensor
116+
subplot(3,2,1)
117+
xtitle('Deltap sensor counts vs Time [ms]')
118+
plot(timetic,Q(:,deltapcol),2)
119+
//Compensated sensor
120+
subplot(3,2,2)
121+
xtitle('Conditioned deltap sensor counts vs Time [ms]')
122+
plot(timetic,Q(:,deltapcol)+zerodpvalue,2)
123+
//Non compensated IAS [m/s]
124+
subplot(3,2,3)
125+
xtitle('Non conditioned Indicated Air Speed [m/s] vs Time [ms]')
126+
[r c]=size(Q);
127+
for no=1:r
128+
ISAnocond(no)=sign(Q(no,deltapcol)-zerodatasheet)*(2*(abs(Q(no,deltapcol)-zerodatasheet)*csensor/1.225)^0.5);
129+
end
130+
plot(timetic,ISAnocond,2)
131+
//Compensated IAS [m/s]
132+
//8192 is the nominal zero for the sensor
133+
//1 psi to 6894.75729
134+
[r c]=size(Q);
135+
for no=1:r
136+
IAScond(no)=sign(compdeltap(no)-zerodatasheet)*(2*(abs(compdeltap(no)-zerodatasheet)*csensor/1.225)^0.5);
137+
end
138+
subplot(3,2,4)
139+
xtitle('Conditioned Indicated Air Speed [m/s] vs Time [ms]')
140+
plot(timetic,IAScond,2)
141+
//Oversampled output , with oversampled time
142+
nosamples=10;
143+
noover=1;
144+
for nap=1:nosamples:(r-nosamples)
145+
somme=0;
146+
for iz=0:(nosamples-1)
147+
somme=somme+IAScond(nap+nosamples)
148+
end
149+
IASoversampled(noover)=somme/nosamples
150+
timeoversampled(noover)=timetic(nap)
151+
noover=noover+1
152+
end
153+
subplot(3,2,6)
154+
xtitle('Oversampled Conditioned Indicated Air Speed [m/s] vs Time [ms]')
155+
plot(timeoversampled,IASoversampled,2)
156+
157+
158+

0 commit comments

Comments
 (0)