How to filter a linear potentiometer analog input? Simulink Real Time

6 ビュー (過去 30 日間)
Magne Kloster
Magne Kloster 2017 年 5 月 11 日
コメント済み: Jeff Dillon 2019 年 8 月 6 日
Hi, I am using a linear potentiometer to measure distance with Simulink Real Time, via an analog input. I want to find the derivative of the input to measure speed, but the analog input value is too noisy to get a good derivative.
So my question is two-fold, How do I design a smoothing filter for my potentiometer, do I use some kind of average filter? and Can I put an averaging filter after the derivative?

回答 (1 件)

Gautham Sholingar
Gautham Sholingar 2017 年 5 月 16 日
You can use smoothing functions such as 'smoothdata' to create a moving average filter with a specified window length. The following documentation link explains this in detail:
However, it is important to note that when implementing this in a practical setting, you will need to buffer the data which is being streamed in and then apply this smoothing to that data. This will introduce a delay in the measurements of the velocity as the moving average filter will need a set of values from time instant 1 to say time t.
Another useful approach to handle such scenarios is to build an estimator using a Kalman filter. The estimator will estimate the velocity from the distance measured and this will perform well even with measurement noise or at least converge to good measurements over time. Since the relationship between velocity and distance is known you can design a set of equations which will model this behavior.
The following documentation links are a good starting point to understand Kalman filters and tools available for you to design an estimator:
  1 件のコメント
Jeff Dillon
Jeff Dillon 2019 年 8 月 6 日
How would you apply the smoothdata function inside a Simulink Function Block? I'm not clear how to pass in the input array, etc to a MATLAB function being called in Normal mode in Simulink. If I'm smoothing across 5 readings for example from an Arduino, I'm aware of the time delay. I was able to implement my own trivial "timestwo" function for learning but of course operates on each incoming value.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpectral Analysis についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by