Calculating impedance of device under test

Hi, The aim of my project is to calculate the impedance of a DUT(device under test) over a wide frequency range (100 hz-10000 hz). I am using a microcontroller to digitize the input and output sine wave signal from the DUT and send the data to matlab. I am able to determine the following information about both waveform using matlab: frequency, mean, amplitude, and phase shift. What would be the most effective way to calculate the impedance? Any help/suggestion would be great! Thanks in advance.

 Accepted Answer

I may be missing something in your description, but the information you are recording (amplitude and phase angle) seem sufficient to calculate a Bode plot. If you want to determine the resistance and reactance at the frequencies you measure, if I remember correctly, with Z=R+jX, where H is amplitude and phi is phase angle:
R = H * cos(phi)
X = H * sin(phi)
You would calculate both of these at each frequency.
Is this what you want?

10 Comments

Hey Star Stider, Thanks for the response. I tried calculating z using the formula you mentioned, but the results are all over the place. The real vs img graph should be a neat curve that increases and then decreases. I also tried implementing sine correlation methods in matlab and it did not work. Oh, and I am using an impedance divider circuit with a known resistor and the DUT. I am still trying to debug where the problem is; any suggestions?
My pleasure.
For the phase angles, consider using the built-in MATLAB function unwrap. It does its best to make them smooth and consecutive. Unfortunately, I have no other suggestions, other than to de-noise or smooth your signals with a lowpass digital filter, if noise is causing significant problems. You could not do this in real time, unless you implemented a Gaussian filter in hardware (no phase distortion). Otherwise, use a digital filter and the filtfilt function (no phase distortion) on your recorded time-domain signals for ampltude and phase angle. (My filter design procedure is here if you need it.)
It’s been a while since I did anything remotely like what you’re doing, so I had to imagine it and take my best guess.
Star strider, it was the error from the phase angle calculation! Thanks for pointing that out. Using the unwrap function makes the data looks much better, although the code is still having trouble with some data points. This is what the code does now, It looks at 5 periods of two sine waves and calculates the phase difference between the sine waves. The result looks something like this: measured_phase = [-1.88 1.56 2.34 -304.38 1.80]; corrected = unwrap(measured_phase); corrected = [-1.8 -4.7 -3.9 -2.78 -4.4]
but when the measured_phase = [-304.38 1.8 2.3 2.16 -1.8]; corrected = [-304 -306 -305 -305 -303]; In this case I want the result to be ~2 How do I fix this? Thanks in advance.
My pleasure.
I don’t understand ‘I want the result to be ~2’. I’m lost.
In both the examples, the phase difference measured by the oscilloscope is around -2 to 2 degrees. In the first case, although -304 degree is one of the measured phase value, unwrap function is able to fix the anomaly. In the second case, the unwrap function is not able to fix it.
I’m still lost. I don’t understand what you’re subtracting to get the -2 values.
I am sorry for not being clear. Let me start over :) I have two sine wave signals with same frequency; one signal has a small phase difference. I want to use matlab to determine the phase difference between the signals with reasonable accuracy (+-5 degrees).
Instead of obtaining the phase difference once, the Matlab code calculates the phase difference between the two sine waves 5 times. I do this to average out the error. For a sanity check, I also use an oscilloscope to check the phase values.
Case 1:
Osc measure phase = -2 deg
matlab measured_phase = [-1.88 1.56 2.34 -304.38 1.80];
corrected = unwrap(measured_phase);
corrected = [-1.8 -4.7 -3.9 -2.78 -4.4]
mean_corrected = -3.56 deg
In this case, the unwrap function works well
Case 2:
Osc measured phase = -2 deg
Matlab measured_phase = [-304.38 1.8 2.3 2.16 -1.8];
corrected = [-304 -306 -305 -305 -303];
mean_corrected = -305.02
How do I fix this?
In this vector:
Matlab_measured_phase = [-304.38 1.8 2.3 2.16 -1.8];
it would seem that the element -304.38 is the outlier. If you know that valid data are always ±5, then one possibility is to reject the values outside that range:
Matlab_measured_phase = [-304.38 1.8 2.3 2.16 -1.8];
corrected_phase = Matlab_measured_phase((Matlab_measured_phase > -5) & (Matlab_measured_phase < 5));
Then take the mean of ‘corrected_phase’.
That is the only suggestion I have. (It seems valid, but I don’t know your constraints.) You will probably need to include logic in your script that makes the appropriate selections.
Yeah, I guess I can measure the range manually and add a condition in the code. Thanks for all your suggestions and time!
My pleasure!
It was interesting for me, too.

Sign in to comment.

More Answers (0)

Asked:

on 19 Oct 2015

Commented:

on 22 Oct 2015

Community Treasure Hunt

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

Start Hunting!