paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [4389] adding a script for computin amplifiers resis


From: antoine drouin
Subject: [paparazzi-commits] [4389] adding a script for computin amplifiers resistor values versus altitude range
Date: Wed, 23 Dec 2009 22:52:02 +0000

Revision: 4389
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=4389
Author:   poine
Date:     2009-12-23 22:52:01 +0000 (Wed, 23 Dec 2009)
Log Message:
-----------
adding a script for computin amplifiers resistor values versus altitude range

Added Paths:
-----------
    paparazzi4/trunk/hw/booz/baro_amp.sce

Added: paparazzi4/trunk/hw/booz/baro_amp.sce
===================================================================
--- paparazzi4/trunk/hw/booz/baro_amp.sce                               (rev 0)
+++ paparazzi4/trunk/hw/booz/baro_amp.sce       2009-12-23 22:52:01 UTC (rev 
4389)
@@ -0,0 +1,94 @@
+clear();
+
+//
+// baro sensitivity 45.9mV/kPa  [\xA0]
+// baro range 15-115 kPa
+//
+
+//
+// amplifier parameters
+//
+R10 = 27e3;
+R5  = 390;
+R6  = 12e3;
+R20 = 560;
+R21 = 680;
+
+function [vo] = amplify(vi, off1)
+  vo = zeros(1:length(vi));
+  for i=1:length(vi)
+    v = vi(i) * ( 1 + R10/R6 + R10/R5 + R10/(R20+R21) ) - 5*R10/R5 - 
off1*R10/(R20+R21);
+    if v > 5
+      vo(i) = 5;
+    elseif v < 0
+      vo(i) = 0;
+    else
+      vo(i) = v;
+    end
+  end
+endfunction
+
+//
+// Compute the pressure from altitude
+// see http://en.wikipedia.org/wiki/Barometric_formula
+// applied in layer 0, ie 0 to 11000m
+//
+function [pressure] = pressure_of_alt(h)
+  Pb = 101325;    // Static pressure : Pascal
+  Tb = 288.15;    // Standard temperature: Kelvin 
+  Lb = -0.0065;   // Standard temperature lapse rate: Kelvin/meters
+  R  = 8.31432;   // Universal gas constant for air: 8.31432 Nm /(mol\xB7K)
+  g0 = 9.80665;   // Gravitational acceleration (9.80665 m/s2)
+  M  = 0.0289644; //Molar mass of Earth's air (0.0289644 kg/mol)
+  hb = 0;
+  
+  pressure = Pb*(Tb/(Tb+Lb*(h-hb)))^(g0*M/R/Lb);
+  
+endfunction
+
+
+sensor_sensitivity = 45.9e-6 ;                        // V/Pa
+
+alt_range = 0:11000;
+pressure_range = zeros(1,length(alt_range));
+for i=1:length(alt_range)
+  pressure_range(i) = pressure_of_alt(alt_range(i));
+end
+sensor_output = pressure_range*sensor_sensitivity;
+
+
+vi = 3.6:0.001:4.5;
+
+clf();
+subplot(3,1,1);
+plot2d(alt_range, pressure_range);
+xtitle('pressure vs alt');
+ylabel('Pascal');
+xlabel('meters');
+
+subplot(3,1,2);
+plot2d(alt_range, sensor_output);
+xtitle('sensor output vs alt');
+ylabel('Volts');
+xlabel('meters');
+
+
+subplot(3,1,3)
+off1 = 0;
+[vo] = amplify(vi, off1);
+plot2d(vi,vo,1);
+
+off1 = 1.65;
+[vo] = amplify(vi, off1);
+plot2d(vi,vo,2);
+
+off1 = 3.3;
+[vo] = amplify(vi, off1);
+plot2d(vi,vo,3);
+xtitle('amp output vs amp in');
+ylabel('Volts');
+xlabel('Volts');
+
+
+gain = 1 + R10/R6 + R10/R5 + R10/(R20+R21)
+





reply via email to

[Prev in Thread] Current Thread [Next in Thread]