MAVRIC

Odor Gradient Determination

Each of the odor detection channels (4) will provide information on the changing concentration of the odorant (changing volume of the pitch).    We will be using a temporal difference estimator. The odor sensor system should be set up as an array of four items, odor_sensor[i], 0<=i<=3. The gradient determination will be computed in the following way:

Thread: Odor_grad
Constants:
alpha = 0.40;
one_alpha = 1.0 - alpha;

Variables:
// internal
byte  x_old,    // filtered old input value
      x_new;    // new olfactory sensor data
int   chng;     // utility variable

/* External: These variables are actually in an array for the odor detector
      incrs[i],    // increasing gradient for odor 0 <= i <= 3
      decrs[i],    // decreasing gradient
      nochng[i];   // non-changing gradient

Initialize:
x_old = 0;
x_new = odor_sensor[i]

Algorithm:
loop forever
   x_new = odor_sensor[i]                        // get current sensor reading
   chng = x_new - x_old;                         // compute temporal difference
   incrs[i] = decrs[i] = nochng[i] = 0;          // init variables
   if (chng > 0) incrs[i] = chng;                // positive means increase
   else if (chng == 0) nochng[i] = 100;          // zero means no detectable change
   else if (chng < 0) decrs[i] = (byte) -chng;   // negative means decrease

/* filter x_old for stability */
   x_old = ((int)(alpha * x_new + 0.5)) + ((int)(one_alpha * x_old + 0.5));
end loop
 



created 3/1/99
Copyright, 2000. George Mobus.  All rights reserved.