I have to control a DC motor. It has an inbuilt encoder that gives 1 Volt per 36 Degrees in angle. So the range is from 0 to 10 volts.
So when the motor runs continuously with a fixed speed, it generates a sawtooth wave with the slope of the triangle depending on the speed of the motor. Like this
Sawtooth Wave from Encoder
Now to find the velocity I differentiate the wave (in Simulink, Matlab) which gives correct values in the triangular part but at the discontinuity where the wave goes from 10 to 0 volts, there is an impulse in the velocity as shown
Differentiation of sawtooth creates impulse at the discontinuity
So my question is how to remove the impulses so that I get a constant velocity(ignore the noises) for a fixed angle sawtooth wave without impulses in the signal?
For that, I will have to make it continuous. How to do that? And any other way for removing impulses?
Best Answer
A simple solution is to introduce a "sample and hold" effect such that you don't let the value of the derivative decrease by just keeping the maximum of the previous and current values.
Of course this solution is not perfect as it will keep the maximum so far and never decrease. So instead of holding a constant value, you can hold a slowly decreasing one (compatible with the time constants of the system.)
The phenomenon you are trying to counteract is a phase jump. In any case, you'd better use nonlinear methods to address it (as opposed to linear filtering).