Z-transform and low pass filter

Dear all,
since I was looking for a low pass filter with a simplified equation and I didn't find a "really simple one", I've searched in my rusty mind and I remembered what I was using to implement a generic low-pass filter when using microprocessors with poor mathematical capabilities.
Probably nobody will never have the need to use it, anyway, II've tried to put it in a (re)usable form.
This low-pass filter is not the typical RC filter used in electronics, but a generic one, that can be used to smooth down any type of input affected by ripple or by sudden spikes.
I've seen that there are other topics related to low-pass filters, but I think that the advantage of this implementation is that it uses just the sampling time and the time constant to generate the two gains used into the equation.
I've taken this opportunity also to play with the nice extension from @Juan_Antonio to draw dynamic graphs and the (always present :hugs: ) @Taifun for his keep alive screen and @Ken for his TextBoxTools extension.
Here below the .aia and a "one page document" to explain (without mathematics details because, I believe, out of the scope) the algorithm.
The main (unique) screen shows the sampling time, the time constant, the edge value (delta), the min and max values of the graph.You can play with the values so to see the different responses of the filter when hitting on the "Apply Edge" button. The "Time" output shows the seconds that the filter needs to asymptotically reach the 10% of the final value (i.e. the edge). The counter stops when this value is reached.
I've used this type of filter to smooth down the inputs coming from an Arduino board interfacing analogue Hall sensors to count the RPM of a car wheel(s).and it works.

As I said , most probably no one will never need it, but in the case .... :roll_eyes:
Ciao ciao.

Low_Pass_Filter.aia (123.0 KB)

Block Diagram.pdf (59.5 KB)

1 Like

Hi, Can you explain how to use this app? I try to filter my sense signal from Arduino through BLE connection?

Hello @hdkim ,
as I said in my post, this algorithm is the one I used in the past, when the microprocessors' capabilities were really poor, and the clock frequencies were about 1.5 MHz (!).
Nevertheless it works well and is simple to implement.
As a matter of fact if you want to use this kind of filter to smooth down the signals coming to your app from an Arduino board via BLE, it is better to implement it on Arduino itself.
This filter is particularly suitable for a "C" language implementation, and, physically, you will obtain better results by implementing it directly on the sensor inputs.
Moreover if you implement a filter after a BLE (or whatever serial or RF) transmission you have to consider also the gap between two transmissions and the frame duration as well, The Z transform is a means to pass from the analogue to the digital domain and the BLE tx is already a "time quantization".
Anyway, you can use the app to simulate the behaviour that the algorithm can have on the Arduino board, by putting the various time constants equal to those that you have on Arduino, so to avoid to make many attempts (edit/compile/flash the board/debug/analyse/modify/edit/compile.....) on your board, and you can see also in a graphical way what happens to the output v/s input values.
I hope I have explained a bit better what you can do with the app.
I believe that the 'one page' .pdf document, reporting the block diagram and the equation can be easily converted in a "C" language code by yourself but, if you will encounter some difficulties in doing that, please let me know, and I'll write some Arduino code (sooner or later :grin:).
Cheers.

EDIT Arduino UNO code, compiled error free but NOT tested :slight_smile:
AnalogInput.ino (1.2 KB)