From: Soeren Apel Date: Thu, 29 Jun 2017 17:16:18 +0000 (+0200) Subject: SignalBase: Adjust Schmitt-trigger thresholds X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=5e95d3d980490ce37d3ae404998b8c89089391e3;p=pulseview.git SignalBase: Adjust Schmitt-trigger thresholds Currently, the thresholds are determined by the minimum and maximum values of a signal. From those, we derive the high and low thresholds by using a 10% margin to min/max. However, this approach doesn't work very well when the measurement includes reset conditions or similar, causing spikes that raise the min/max significantly. Example: sigrok-dumps/i2c/eeprom_24xx/microchip_24lc64/sainsmart_dds120_powerup_scl_sda_analog.sr This patch changes the thresholds margins to 35%. However, they are expressed differently: (max-min)/2 is used as the center line, from which 15% of the amplitude (max-min) is used as the margin. This way seems a little more intuitive for me since the percentage given (15) is directly proportional to the hysteresis. --- diff --git a/pv/data/signalbase.cpp b/pv/data/signalbase.cpp index ee1112d5..b43e5bb0 100644 --- a/pv/data/signalbase.cpp +++ b/pv/data/signalbase.cpp @@ -310,8 +310,9 @@ void SignalBase::conversion_thread_proc(QObject* segment) if (conversion_type_ == A2LConversionBySchmittTrigger) { const float amplitude = max_v - min_v; - const float lo_thr = min_v + (amplitude * 0.1); // 10% above min - const float hi_thr = max_v - (amplitude * 0.1); // 10% below max + const float center = min_v + (amplitude / 2); + const float lo_thr = center - (amplitude * 0.15); // 15% margin + const float hi_thr = center + (amplitude * 0.15); // 15% margin uint8_t state = 0; // TODO Use value of logic sample n-1 instead of 0 // Convert as many sample blocks as we can