Electronics > Beginners

FFT and Signals

<< < (4/4)

bson:
I posited:

--- Quote from: bson on March 15, 2019, 11:30:22 pm ---(Of course, is Z is constant rather than Z(w), then F(1/Z) is constant, but then you also have no reactive current.)

--- End quote ---
On second thought this is not true at all.  Convolution with a fixed, DC kernel (1/Z) still requires convolution.

Langer:
I finally made a working matlab-code.

This can calculate the response of an arbitrary system by using "lsim" code from matlab. Description is here: https://www.mathworks.com/help/control/ref/lsim.html
It is about convolution, which was mentioned before.

One book I found which covers this topic:
https://books.google.de/books?id=wnpTDwAAQBAJ&printsec=frontcover&hl=de

but its quite expensive...

Thanks everyone for his contribution!

matlab code:
=======

clear all;
close all;
clc;

Cap=1e-6;
R1=100;
L=0.01;


s = tf('s');
Z1=R1;
Z2=1/(s*Cap);
Z3=s*L;
%Voltage across R1:
Hs=Z1/(Z1+Z2+Z3);


t = 0:0.00001:0.01;
u = 0.5*(square(t*2*pi*500)+1);
y=lsim(Hs,u,t);
%Calculate current for R1:
y=y/R1;

fig_1=figure(1);
ax_1=axes;
plot(ax_1,t,u)
title('Voltage input')
fig_1.Position = [100,343,560,420];

hold 'on'
yyaxis right
plot(t,y)


pwlps:

--- Quote from: bson on March 15, 2019, 11:30:22 pm ---
--- Quote from: Langer on March 15, 2019, 10:24:42 pm ---Deivding the freq amplitude U by Z sounds reasonable for me

--- End quote ---
Did I miss something important here?  Multiplication in the time domain is equivalent to convolution in the frequency domain and vice versa. In the frequency domain,  I=U*1/Z becomes F(I) = F(U*1/Z) = F(U)**F(1/Z) where ** is the convolution operator.   So instead of dividing Ufft with the impedance, shouldn't you convolve with its reciprocal?  (Of course, is Z is constant rather than Z(w), then F(1/Z) is constant, but then you also have no reactive current.)

--- End quote ---

What you missed is that it is the opposite: here we have convolution in the time domain which is equivalent to multiplication in the frequency domain.  I=U*1/Z  stands for I(f)=U(f)*1/Z(f). 

pwlps:

--- Quote from: rhb on March 16, 2019, 02:23:16 am ---1)  The discrete (sampled) Fourier transform is periodic over [-pi:pi) or [0:2*pi) depending upon your conventions.  The latter is what you actually get out of an FFT.   The negative frequncies appear on the right.

2) To make a signal causal, i.e. zero before T0, the imaginary part needs to be the Hilbert transform of the real part.  In the frequency domain the real part is even and the imaginary is odd.  The usual term is the transform is hermitian.  The transform of a hermitian function is pure real and causal.

Compute the FFT of a zero phase (symmetric about T0) function.  The imaginary part will be uniformly zero.  Multiply the negative frequencies by -1, the positive frequencies by 1 and set zero frequency to zero and store that in the imaginary part of the transform.  then inverse transform.  The result will be causal and minimum phase.

--- End quote ---


It is not the signal that should be causal but the transfer function, which is 1/Z here.
Looking at the code it is obviously hermitian :

Xl=i*2*pi*L.*freq;
Xc=-i./(2*pi*Cap*freq);
Z = R+Xl+Xc; 

therefore there is no problem related to causality here. 

One thing to check is the behavior at zero frequency (Z will diverge for freq=0), I actually don't know how Matlab handles infinite values, but even if it handles them there will be a huge numerical artifact unless you somehow cure the singularity.

I don't have Matlab but I checked with an equivalent code under Igor Pro, it works if I prevent Z from going to infinity at zero frequency, for example adding a big resistance in parallel with C. I post the results and the corresponding code in the pictures below. 


More generally,  calculations using the FFT should give the correct result if the boundary conditions are chosen to not to generate artifacts.  As unitedatoms pointed out:


--- Quote from: unitedatoms on March 15, 2019, 10:35:09 pm ---The Fourier does not care about causality. It also does not care about finite span of observed signal. It thinks that signal was repeated over eternity. So to perform closer to intuitive physics, try to do windowing, and also try to shift phase of pulse to some odd angle. And ignore reconstructed "predicted past", ignore negative frequencies etc.

--- End quote ---

therefore it is important to have in mind that if the signal is not the same at start and at end then  you create an artificial discontinuity at t=0.  The same effect of periodicity appears in the simulation I show. The function U(t) is condidered as periodic and here the period of U(t) is 10, U(0)=1 and U returns to 0 at t=3*pi=9.42 which is equivalent to t=9.42-10=-0.58.  Therefore at t=0 there will be a signal reminiscent from the transient at t=-0.58, as seen in the picture of I(t).

rhb:
 If x(0) != x(n) then things get more complicated.  In filtering operation subtracting a linear function, filtering and adding back the linear function has been my normal practice doing fiddly stuff.  For routine work a cosine taper edge is pretty common.

The most common mistake I have seen is failing to pad the series so that wraparound occurs.

Navigation

[0] Message Index

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod