I am trying to demodulate a FM signal with a RTL-SDR and python using the arctan method. From here I know that $$ \frac{d}{dt}\arctan(\frac{q(t)}{i(t)}) = \frac{i(t)\frac{d}{dt}q(t)-q(t)\frac{d}{dt}i(t)}{[i(t)]^2} $$
and so far I have successfully been able to demodulate using the RHS and the following python code
def discrim(x):
X=np.real(x) # X is the real part of the received signal
Y=np.imag(x) # Y is the imaginary part of the received signal
b=np.array([1, -1]) # filter coefficients for discrete derivative
a=np.array([1, 0]) # filter coefficients for discrete derivative
derY=signal.lfilter(b,a,Y) # derivative of Y,
derX=signal.lfilter(b,a,X) # " X,
disdata=(X*derY-Y*derX)/(X**2+Y**2)
return disdata
However I would also like to get the same results using the LHS and naively assumed that python code as follows would do that
def discrim_bad(x):
X=np.real(x) # X is the real part of the received signal
Y=np.imag(x) # Y is the imaginary part of the received signal
b=np.array([1, -1]) # filter coefficients for discrete derivative
a=np.array([1, 0]) # filter coefficients for discrete derivative
x = np.arctan2(Y,X)
der=signal.lfilter(b,a,x) # derivative
return der
Unfortunately this is not the case. I assume it has something to do with the discretization and most likely the discrete derivative approximations but I am not quite able to figure it out.