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

5 visualizaciones (últimos 30 días)
Magne Kloster
Magne Kloster el 11 de Mayo de 2017
Comentada: Jeff Dillon el 6 de Ag. de 2019
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?

Respuestas (1)

Gautham Sholingar
Gautham Sholingar el 16 de Mayo de 2017
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 comentario
Jeff Dillon
Jeff Dillon el 6 de Ag. de 2019
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.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by