Browse Source

Fix Ripples runaway feedback bug

- Constrain the tanh approximation input to monotonic range
- Clamp filter cell voltages
tags/v1.4.0
Tyler Coy 5 years ago
parent
commit
597d8a6f16
1 changed files with 9 additions and 2 deletions
  1. +9
    -2
      src/Ripples/ripples.hpp

+ 9
- 2
src/Ripples/ripples.hpp View File

@@ -108,6 +108,9 @@ static const float kVCAOutputR = 100e3f;
// Saturation voltage at BJT collector // Saturation voltage at BJT collector
static const float kVtoICollectorVSat = -10.f; static const float kVtoICollectorVSat = -10.f;


// Opamp saturation voltage
static const float kOpampSatV = 10.6f;



class RipplesEngine class RipplesEngine
{ {
@@ -280,6 +283,8 @@ protected:
return dvout; return dvout;
}); });


cell_voltage_ = simd::clamp(cell_voltage_, -kOpampSatV, kOpampSatV);

float lp1 = cell_voltage_[0]; float lp1 = cell_voltage_[0];
float lp2 = cell_voltage_[1]; float lp2 = cell_voltage_[1];
float lp4 = cell_voltage_[3]; float lp4 = cell_voltage_[3];
@@ -344,10 +349,12 @@ protected:
const float kTemperature = 40.f; // Silicon temperature in Celsius const float kTemperature = 40.f; // Silicon temperature in Celsius
const float kKoverQ = 8.617333262145e-5; const float kKoverQ = 8.617333262145e-5;
const float kKelvin = 273.15f; // 0C in K const float kKelvin = 273.15f; // 0C in K
const float kVt = kKoverQ * (kTemperature + kKelvin);
const float kVt = kKoverQ * (kTemperature + kKelvin);
const float kZlim = 2.f * std::sqrt(3.f);


T vi = vp - vn; T vi = vp - vn;
T z = vi / (2 * kVt);
T zlim = kZlim;
T z = math::clamp(vi / (2 * kVt), -zlim, zlim);


// Pade approximant of tanh(z) // Pade approximant of tanh(z)
T z2 = z * z; T z2 = z * z;


Loading…
Cancel
Save