Borrar filtros
Borrar filtros

Error/Mismatch in determing impedance using fft in simulink imported data.

8 visualizaciones (últimos 30 días)
Hello Everyone
I need to calculate the impedance of a more or less complex circuit using FFT. I have implemented the circuit in simulink and saved the voltage and current in the workapace using To Workspace block. However, after performing fft , I didnt quite get the expected result. Now to check if my code was right, I was testing it on a simple circuit. I have implemented a simple RC circuit . The model is attached. To determine impedance I am using the theory Z(w)=fft(voltage)/fft(current). R=Real (Z(w), X=Imag(Z(w)).
Now, The snapshot of the circuit--
The code I am using-
clc
% clear
Time = out.tout;
Load_Voltage = out.V_L;
Load_Current = out.I_L;
Fs = 1 / mean(diff(Time));
N = length(Load_Voltage);
fft_Load_Voltage = fft(Load_Voltage);
fft_Load_Current = fft(Load_Current);
fft_Load_Voltage_single_sided = fft_Load_Voltage(1:N/2+1);
fft_Load_Current_single_sided = fft_Load_Current(1:N/2+1);
frequencies = Fs * (0:(N/2)) / N;
frequency_of_interest =13.56e6;
[~, index] = min(abs(frequencies - frequency_of_interest));
Z1 = fft_Load_Voltage_single_sided(index) / fft_Load_Current_single_sided(index);
R1 = real(Z1);
X1 = imag(Z1);
fprintf('R: %.2f ohms, X: %.2f ohms\n', R1, X1);
I have set the value of the resistor as 30 and the value of capacitor such as it would exibit -50 ohm at 13.56 Mhz, which is the driving frequency. But the results are off. The result I get is: R: 25.79 ohms, X: -37.52 ohms.
What is the problem here? Is it the code or anything with the simulink model. However if its just a resistive circuit the code gives correct result. This a very important step in a much bigger project. It is crucial.
Your help will be really appreciated.
Thank You.
  2 comentarios
Pat Gipper
Pat Gipper el 22 de Mayo de 2024
Editada: Pat Gipper el 22 de Mayo de 2024
The model you attached and the picture that you show is a series RL circuit, with R = 50 Ohms and L = 0.587 uH.

Iniciar sesión para comentar.

Respuesta aceptada

Sayan
Sayan el 28 de Mayo de 2024
Hi Md. Golam,
You do not need to use the powergui block here, as the block is only required in the case of solving Specialized Power System blocks. I could resolve the issue by setting the solver type to "Fixed-step". The "Variable-step" solver does not compute the value of the signal at a regular time interval. For FFT analysis, a fixed-step size ensures uniform sampling intervals, which is a prerequisite for standard FFT algorithms. I have got the expected value of resistance and capacitive impedence, as shown below.
I am attaching the updated model here. You can know more about the comparison between "Fixed-step" and "Variable-step" solver in the following documentation.
Hope this resolves your issue.
  5 comentarios
Sayan
Sayan el 28 de Mayo de 2024
Editada: Sayan el 28 de Mayo de 2024
resample internally takes care of the interpolation. Please look at the part of the documentation where an example is shown to resample a non uniformally spaced data.
Md. Golam Zakaria
Md. Golam Zakaria el 28 de Mayo de 2024
@Sayan I have tried interpolation on the original concept of mine and its working. I will surely try resampling . Maybe it will give me more accurate results. Thank you for this. You have helped me big time.

Iniciar sesión para comentar.

Más respuestas (1)

Pat Gipper
Pat Gipper el 28 de Mayo de 2024
@Md. Golam Zakaria You can use the variable step solver and force it to output at fixed intervals by putting a "Sample time" value other than -1 into the "To Workspace" blocks of your simulation as shown in the image below. I tend to use a workspace variable instead of a fixed number for flexibility.

Productos


Versión

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by