HAL_COMP(psi);

HAL_PIN(vel) = 0.0;
HAL_PIN(dc_volt) = 0.0;
HAL_PIN(polecount) = 1.0;
HAL_PIN(drop) = 0.8;
HAL_PIN(psi) = 0.0;
HAL_PIN(max_psi) = 0.0;


MEM(float max_f) = 0.0;

RT(
   float f = ABS(PIN(vel)) / 2.0 / M_PI * PIN(polecount);
   float u = PIN(dc_volt) / sqrtf(3.0) + PIN(drop);
   if(f > 1.0){
      PIN(psi) = u / f / 2.0 / M_PI;
      if(max_f < f){
         max_f = f;
         PIN(max_psi) = PIN(psi);
      }
   }
   max_f *= 0.999999;
);

ENDCOMP;
