Beispiel #1
0
    def __init__(self):
        super(MainWindow, self).__init__()

        self.ui = Ui_MainWindow()

        self.ui.setupUi(self)

        self.generator = Generator()
        self.components = Component()
        self.filter = Filters()
        self.signals = []
        for i in range(6):
            self.signals.append(Signal())


        ##Aca van los callbacks

        self.ui.pushButton_configure.clicked.connect(self.update_signals)
        self.ui.pushButton_1.clicked.connect(lambda: self.plot(0))
        self.ui.pushButton_2.clicked.connect(lambda: self.plot(1))
        self.ui.pushButton_3.clicked.connect(lambda: self.plot(2))
        self.ui.pushButton_4.clicked.connect(lambda: self.plot(3))
        self.ui.pushButton_5.clicked.connect(lambda: self.plot(4))
        self.ui.pushButton_6.clicked.connect(lambda: self.plot(5))

        self.ui.checkBox_1.stateChanged.connect(lambda: self.checkboxes(1))
        self.ui.checkBox_2.stateChanged.connect(lambda: self.checkboxes(2))
        self.ui.checkBox_3.stateChanged.connect(lambda: self.checkboxes(3))
        self.ui.checkBox_4.stateChanged.connect(lambda: self.checkboxes(4))
Beispiel #2
0
    def asign_signals(self):
        for i in range(6):
            self.signals.append(Signal())

        sinput = str(self.ui.comboBox.currentText())

        sin_amp = float(self.ui.lineEdit_amplitude_sin.text())
        sin_freq = float(self.ui.lineEdit_frequency_sin.text())
        clock_freq = float(self.ui.lineEdit_frequency_control.text())
        clock_dc = float(self.ui.lineEdit_dc_control.text())



        if sinput == 'Sin()':
            for i in range(5):
                self.signals[i] = self.generator.generate_sin(sin_amp, sin_freq, 4/sin_freq, 100000)
            self.signals[5] = self.generator.generate_square(5, clock_freq, clock_dc, 4/sin_freq, 100000)
        elif sinput == 'Cos()':
            for i in range(5):
                self.signals[i] = self.generator.generate_cos(sin_amp,sin_freq, 4/sin_freq, 100000)
            self.signals[5] = self.generator.generate_square(5, clock_freq, clock_dc, 4/sin_freq, 100000)
        elif sinput == '3/2Sin()':
            for i in range(5):
                self.signals[i] = self.generator.generate_32_sin(sin_amp, sin_freq, 4/sin_freq, 100000)
            self.signals[5] = self.generator.generate_square(5, clock_freq, clock_dc, 4/sin_freq, 100000)
        elif sinput == 'Sinc()':
            for i in range(5):
                self.signals[i] = self.generator.generate_sinc(sin_amp, sin_freq, 4/sin_freq, 100000)
            self.signals[5] = self.generator.generate_square(5, clock_freq, clock_dc, 4/sin_freq, 100000)
        elif sinput == 'AM()':
            for i in range(5):
                self.signals[i] = self.generator.generate_AM(sin_amp, sin_freq, 5 * 4/sin_freq, 100000)
            self.signals[5] = self.generator.generate_square(5, clock_freq, clock_dc, 5 * 4/sin_freq, 100000)

        self.filter.set_frequency(float(self.ui.lineEdit_frequency_filter.text()))
Beispiel #3
0
    def Low_pass(self, original_signal):
        signal = Signal()
        spectrum = Spectrum()

        length = len(original_signal.get_time_data()[0])

        x_1, y_1 = original_signal.get_original_frequency_data()
        y = y_1

        for i in range(len(x_1)):
            if x_1[i] <= -self.fa or x_1[i] >= self.fa:
                y[i] = 0

        signal.set_originial_frequency_data(x_1, y)

        signal = spectrum.Original_Fourier_transform(signal, length)
        signal = spectrum.Inverse_Fourier_transform(
            signal,
            original_signal.get_time_data()[0][-1],
            len(original_signal.get_time_data()[0]))
        return signal
Beispiel #4
0
    def generate_cos(self, Vmax, frequency, T, length):
        signal = Signal()
        spectrum = Spectrum()

        signal.set_frequency(frequency)

        x_t = np.linspace(0, T, length)
        y_t = np.multiply(Vmax, np.cos(np.multiply(2 * np.pi * frequency,
                                                   x_t)))

        signal.set_time_data(x_t, y_t)
        S = spectrum.Fourier_transform(signal)
        return signal
Beispiel #5
0
    def generate_sinc(self, Vmax, frequency, T, length):
        signal = Signal()
        spectrum = Spectrum()

        signal.set_frequency(frequency)

        x_t = np.linspace(0, T, length)
        y_t = []

        var = 0
        for i in range(len(x_t)):
            if x_t[i] >= (var + 1) / frequency:
                var = var + 1
            y_t.append(Vmax * np.sinc(8 * frequency *
                                      (x_t[i] - var / frequency) - 4))

        signal.set_time_data(x_t, y_t)
        signal = spectrum.Fourier_transform(signal)
        return signal
Beispiel #6
0
    def generate_square(self, Vmax, frequency, DC, T, length):
        signal = Signal()
        spectrum = Spectrum()

        signal.set_frequency(frequency)

        x_t = np.linspace(0, T, length)
        y_t = []

        var = 0
        for i in range(len(x_t)):
            if x_t[i] >= (var + 1) / frequency:
                var += 1
            if (x_t[i] - var / frequency) >= DC / (100 * frequency):
                y_t.append(0)
            else:
                y_t.append(Vmax)

        signal.set_time_data(x_t, y_t)
        signal = spectrum.Fourier_transform(signal)

        return signal