04-03-2014 09:47 PM
Hi,
I want to pass my control signal U throught the function 146/(S+276) in order to have U_filtered
How i do it ?
I tried a Low Pass Filter but i donot have the same results in comparison with Matlab .
I mean i want to have :
U_filtered=146/(S+276) * U .
I attached a photo for the signal U(yellow) and U_filtered(pink) in Matlab.
i want to use this in real time application
thanks
Solved! Go to Solution.
04-04-2014 06:18 AM
How are you implementing the transfer function in labview?
I think this will have to be a discrete implementation and may be you are already doing this. So pardon me if this is something you know already.
Please see http://en.wikipedia.org/wiki/Low-pass_filter#Discrete-time_realization for an excellent primer on discrete time lowpass filters.
Essentially, you will have to implement a discrete equation to achieve this. Something like:
y(k+1) = 0.53*alpha*x(k) + (1-alpha)*y(k)
where alpha is related to the lowpass frequency and sampling frequency by alpha = flp/(fs+flp), flp is the low pass frequency and fs is the sampling frequency.
In your case, flp = 276 and fs is whatever you choose to implement - this is the speed at which your loop is running either on the RT or the FPGA or whatever. If speed is not an issue, I recommend 5000 rad/s or higher as a starting point.
The 0.53 factor above is the just the gain of the filter you described 146/276.
04-04-2014 06:49 PM
Hi,
I did as you explained i have a simliar results in what i had in Matlab.
alpha could be between 0.8 and 1,8 ,I donot understand why and what is fs then.
I used in my test Ni-USB6009 to generate a Sine signal and read it by the first input.
The figure is attached with different values of alpha
04-04-2014 06:49 PM
Here another photos
04-05-2014 07:11 PM
I think you need to explain what you think the problem is - your graphs don't tell the whole story.
Some things you might want to think about:
1) With a low frequency input signal into your filter, it will have a gain of 0.53 (=146/276), i.e. the output signal shoudl be about half the size of the input and in phase. For higher frequency input signals, increase the frequency the gain should decrease - i.e. the output signal should get even smaller, and start to have some phase shift (eventually getting to 90deg).
2) With discrete time transfer functions, make sure the sample time you implement it at (e.g. your timed loop) matches that you calculated the transfer function at. If you change the sample time, the transfer function co-effecieints change.
3) If you sample too slowly, you won't get a good approximation of your continuous time filter.
Please understand this sort of stuff from any dyanmics text book or online before wondering about your LV implementation.
04-08-2014 04:10 PM
alpha by definition is <1.
alpha = flp / (flp + fs)
Here flp is the low pass filter frequency that you want to implement and fs is the sampling frequency which is also the loop frequency of your loop in the RT vi in which the transfer fucntion is implemented.
For example, flp = 100Hz, fs = 900Hz => alpha = 0.1