i have seen example of controlling output dc voltage of DC to DC buck converter using PID controller. I want to implement DC to AC converter. I tried using PID controller. Since i am comparing output AC signal(continuously varying) with reference sinusoidal signal, PID controller is not providing expected output. In case of DC to DC, both reference signal was constant. In my case, it is continuously varying sine wave. Can anyone suggest any way to get accurate DC to AC conversion? i changed kp and ki parameters to get needed response. it is working well. but, when i change frequency of input reference signal, output signal amplitude drops and again i have to change PID parameters.
P.S. when i change frequency of input reference signal, again i have to change PID gain parameters. Can PID controller work with continuously varying reference signal(in terms of amplitude and frequency both) ?
Check the answer I gave to your other question:
PID working with sine wave as reference in simulink
If you need varying frequence for your reference, you can use a dq0 controller where the dq0 transform angle comes from a frequency reference (that you can change) passing through an integrator. Then set your d reference to the amplitude you wish.
Related
I have a model of the form:
All I am doing here is mixing the two sine waveforms based on the random bits.
I set the signal frequency of first sign wave to:
Second sign wave:
The output is :
But it works well when the signals are of low frequency.
How can I make it to work even at high frequencies ?
80*10^3*t and 12*10^4*t are both always an integer for all values of t=0:0.01:100. Hence the sin is always being evaluated at an integer multiple of 2*pi. Hence the value of the plot is always zero (or near enough to it down in the 10^-8 or 10^-9 range.
You need to change the sample rate so that you get points where sin is not zero.
I have designed a low-pass filter with cut-off frequency at 4.82 kHz. The script below contains the transfer function, creates a periodic triangular pulse and passes it through the filter.
h=tf([8.06 *10^22],[1 9.801*10^4 4.803*10^9 1.455*10^14 2.723*10^18 2.549*10^22])
T = 10*(1/2000);
Fs = 80000;
dt = 1/Fs;
t = 0:dt:T-dt;
x = sawtooth(2*pi*2000*t,0.5);
lsim(h,x',t')
My question is: shouldn't the output also be a triangular pulse,since this is a linear system? If no,can someone explain to me theoritically why this is an accepted output? If yes, is there some adjustment to the code I can make to get the correct output?
No, an LTI real rational system necessarily smooths its input. You can convince yourself by thinking that in time domain an LTI system is a convolution operator. Alternatively, you can see that your system is a low-pass filter with roughly 6kHz bandwidth.
So you can multiply the frequency response of your system with the sawtooth spectrum to see what the answer would look like in the frequency domain.
Linearity is not a "shape" preserving property. It says if I get r1 as the response to i1 input signal and r2 to i2 then I will get 3*r1 + 5*r2 if I supply the input signal 3*i1 + 5*i2.
What you might be looking for is reference tracking for a control system that requires a controller to drive the system such that the difference between the input and the output is minimized.
I have seen example of controlling output dc voltage of DC to DC buck converter using PID controller.
I want to implement DC to AC converter.
I tried using PID controller.
Since i am comparing output AC signal(continuously varying) with reference sinusoidal signal, PID controller is not providing expected output.
In case of DC to DC, both reference signal was constant.
In my case, it is continuously varying sine wave.
Can anyone suggest any way to get accurate DC to AC conversion?
P.S. Can PID controller work with continuously varying reference signal with high frequency(100Hz)?
If you want to have zero error for a sine wave reference you have two alternatives:
DQ0 Controller
You need to transform (using the dq0 transform also known as Park transform) your reference signal and controlled (measured) values to a rotating frame with the same frequency of your sine wave (in this case 100Hz).
When doing that, your reference signal and measured values will become constant values at 100 Hz and you can use a regular PID controller (actually you will need two - one for the d frame and other for the q frame).
Then you use the inverse transform of the PID controller output that will drive the duty cycle of your converter modulator.
Just notice that if your system is single-phase, there will be 2nd order harmonics in the result of the dq0 transform that have to be filtered out.
Resonant Controller
In the PID controller, the integral action is responsible for zero error constant reference tracking, because it is effectively a infinite gain at zero frequency (i.e. constant). In the transfer function using Laplace form the integral part corresponds to 1/s in the controller function.
To track sine waves, you need a controller in the form of (1/w²+s²), that will guarantee a infinite gain at the frequency of the reference sine wave, where w=2*pi*f.
In fact, we can proof mathematically that a DQ0 PID Controller is equivalent to the Resonant Controller.
I would like to get only one number (maximum) from sinusoid in Matlab Simulink scope. I have a voltage measurement to measure AC voltage and current measurement. I need to find max. In my example the voltage is 231V and current is 0.26. the result number is 231*0.26 = .. to multiple it I need to get the max number from sinusoid.
Thanks a lot.
Based on your description, I think that the MinMax Running Resettable block would be more appropriate for your application.
The MinMax block will take multiple scalar value inputs (or a vector input) and output the minimum or maximum value (depending on your settings) of those inputs at the current instant in time. This would be better used to compare two signals, not to find the maximum value of a particular "stream" of signal data.
So, for example, let's say that you have a Sine Wave block that is feeding into a MinMax block (which has been set to output the max value). The MinMax block will look at all of its inputs at the current instant in time and output the maximum value. However, in this case, MinMax only has one input -- the sine wave. So the output of MinMax will actually be the same as the output of the Sine Wave block.
On the other hand, MinMax Running Resettable outputs the minimum or maximum of all past inputs. So for example, if you had a sine wave with a peak value of 231 that was being fed into the u input of a MinMax Running Resettable block, then by the end of the simulation, this block will output 231. This is, of course, provided that your simulation has run long enough that the sine wave has reached its peak value.
Note that the MinMax Running Resettable block was an R input that can be used to reset the block. If you simply want to find the max value of your signal over time and do not need to reset the block, then you can go ahead and just leave this input disconnected.
i once studied matlab at engineering school and i think you need to link the output of your sinusoid to a box called minmax
http://www.mathworks.com/help/simulink/slref/minmax.html
Is there some process that can determine / remove an unknown DC offset from a non-periodic discrete time signal?
The signal in in question has a sample rate of 25Hz and has harmonics of interest between 0.25 and 3 Hz.
I have tried using highpass filters mixed results, first I used a 10th order guassian with Fc = 0Hz, this did a good job of removing the offset but it severly attenuated the AC aswell although it did leave the signal shape intact, next I used a 168th order equilripple with a stopband at 0Hz and passband at 0.25Hz, the phase shift was too severe and the signal shape too distorted, the distortion could probably be reduced if the pass-band was brought down to 0.1Hz but this would just further increase the phase shift which I need to keep to the very minimum.
Before and after applying x - LPF(x), as suggested by Paul R
I recommend using a notch filter at DC and using filtfilt to make it zero phase.
a = [1 , -0.98]; b = [1,-1];
y = filtfilt(b,a,x);
The closer the second value of a gets to -1 the narrower your notch will be.
A DC offset means that some constant value was added to the signal (the name originates from adding a DC voltage to an analog AC signal). If the DC component is really constant (and not changing really slowly), then you don't have to design some high-order (and potentially unstable) high-pass filters - you can just subtract the average of your signal from the signal - which is, of course, a high-pass filter as well (averaging is a type of a low-pass, and '1 minus the average' is high-apss) --- but a very simple one.
If, on the other hand, you have a reason to believe that the DC component is not really a DC, but rather an AC with very low frequency, then you'd better average segments of your signal and not the signal as a whole, which is the same as using a low-pass filter with impulse response which is shorter then the length of the signal. In this case you have to make some assumptions about the "DC" component.
Rather than implementing a high pass filter directly (which can be rather tricky for very low frequencies - you end up with a large number of coefficients and various issues with stability and passband ripple etc), you might instead want to consider implementing a low pass filter which will give you an estimate of the DC offset value, and then subtract this filtered offset from your signal, i.e. rather than:
y = HPF(x)
do this:
y = x - LPF(x)
The low pass filter can probably just be quite a simple filter with a relatively small number of terms. The big advantage of this implementation is that your higher frequency components should not have any unwanted artefacts due to phase, ripple, etc, since all you are doing is subtracting an almost stationary DC value from the samples.
The only potential downside is that if the DC offset is large you may have quite a long initial settling time before the estimate of the DC offset is accurate (although this is also true of any other implementation such as a direct high pass filter of course). If you have any a priori knowledge of what the offset value is likely to be (e.g. if it doesn't change very much from run to run, and you know the value from the previous run) then you can use this to optimise the settling time, by initialising the LPF state variables to a suitable value rather than 0.
As others have said, to remove a DC offset, you can simply subtract the mean. Your signal does not need to be periodic, but it does need to be long enough to get a good estimate of the DC component.
If you still wish to go with a filtering approach, you can eliminate the severe distortion due to phase lag by using filtfilt. This function filters your timeseries once in the forwards direction and then once in the reverse direction, so that phase distortions cancel out.
You can design a symmetric FIR filter as the low-pass filter that estimates the DC and then subtract the output from your input signal. This filter has constant group-delay.