Hej,
Czy możliwe jest odzyskanie sygnału analogowego na podstawie: posiadanego sygnału skwantyzowanego, błędu kwantyzacji, liczby bitów konwertera A/D i jego zakresu pomiaru? Powiedzmy, że chciałbym na tych założeniach zbliżyć jak najbardziej discrete signal
do analog signal
.
Poniżej kod generujący powyższy plot
:
import numpy as np
import pylab as py
def sin(frequency = 1, time = 1, sampling = 128, phi = 0):
'''
Sinus function for a given frequency in Hz, length in time,
sampling frequency, and phase.
'''
dt = 1.0 / sampling
t = np.arange(0, time, dt)
s = np.sin((2 * np.pi * frequency * t) + phi)
return s, t
s_analog_1, t_analog_1 = sin(frequency = 1, sampling = 1000)
py.plot(t_analog_1, s_analog_1, linewidth = '1.5', color = 'red', label = 'analog signal')
s_analog_2, t_analog_2 = sin(frequency = 1, sampling = 10)
py.plot(t_analog_2, s_analog_2, 'o', color = 'red')
# Calculate the quantization noise, ie "R/2^N"
s_discrete, t_discrete = sin(frequency = 1, sampling = 10)
N = 3 # Number of bits of A/D Converter
R = 2 # Range of A/D Converter
dy = R/2**N # Quantization error
s_quantized = np.floor(s_discrete / dy) * dy + 0.5 *dy
py.plot(t_discrete, s_quantized, color = 'gray', label = 'discrete signal')
py.plot(t_discrete, s_quantized, 'o', color = 'gray')
py.legend(loc = 'upper right', fontsize = '10')
py.show()