mirror of
https://github.com/xdsopl/robot36.git
synced 2025-12-06 07:12:07 +01:00
added Schmitt trigger
This commit is contained in:
parent
b8c98317b1
commit
8a1d7ca7ba
|
|
@ -12,6 +12,7 @@ public class Demodulator {
|
|||
private final ComplexMovingAverage scanLineFilter;
|
||||
private final ComplexMovingAverage baseBandLowPass;
|
||||
private final FrequencyModulation scanLineDemod;
|
||||
private final SchmittTrigger syncPulseTrigger;
|
||||
private final Phasor syncPulseOscillator;
|
||||
private final Phasor scanLineOscillator;
|
||||
private final Phasor baseBandOscillator;
|
||||
|
|
@ -50,6 +51,7 @@ public class Demodulator {
|
|||
syncPulseDelay = new Delay(syncPulseDelaySamples);
|
||||
int scanLineDelaySamples = (powerWindowSamples - 1) / 2 + (syncPulseFilterSamples - 1) / 2 - (scanLineFilterSamples - 1) / 2;
|
||||
scanLineDelay = new Delay(scanLineDelaySamples);
|
||||
syncPulseTrigger = new SchmittTrigger(0.17f, 0.19f);
|
||||
baseBand = new Complex();
|
||||
syncPulse = new Complex();
|
||||
scanLine = new Complex();
|
||||
|
|
@ -64,7 +66,7 @@ public class Demodulator {
|
|||
float scanLineValue = scanLineDelay.push(scanLineDemod.demod(scanLine));
|
||||
float syncPulseLevel = Math.min(Math.max(syncPulseValue, 0), 1);
|
||||
float scanLineLevel = Math.min(Math.max(0.5f * (scanLineValue + 1), 0), 1);
|
||||
if (syncPulseLevel > 0.1)
|
||||
if (syncPulseTrigger.latch(syncPulseLevel))
|
||||
buffer[i] = -syncPulseLevel;
|
||||
else
|
||||
buffer[i] = scanLineLevel;
|
||||
|
|
|
|||
28
app/src/main/java/xdsopl/robot36/SchmittTrigger.java
Normal file
28
app/src/main/java/xdsopl/robot36/SchmittTrigger.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Schmitt Trigger
|
||||
|
||||
Copyright 2024 Ahmet Inan <xdsopl@gmail.com>
|
||||
*/
|
||||
|
||||
package xdsopl.robot36;
|
||||
|
||||
public class SchmittTrigger {
|
||||
private final float low, high;
|
||||
private boolean previous;
|
||||
|
||||
SchmittTrigger(float low, float high) {
|
||||
this.low = low;
|
||||
this.high = high;
|
||||
}
|
||||
|
||||
boolean latch(float input) {
|
||||
if (previous) {
|
||||
if (input < low)
|
||||
previous = false;
|
||||
} else {
|
||||
if (input > high)
|
||||
previous = true;
|
||||
}
|
||||
return previous;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue