Hi, Could somebody help and advice how I estimate the velocity from the position output of an incremental shaft encoder (two outputs, 90 deg. shifted). I use Simulink and xPC target to control an actuator with DC motor. The easiest way would be to take the difference between the last two sampled positions divided by the sampling period. But I don't know where I should get the sampling period from? Is there another way which I could try to perform speed control?
Thanks Jerry and Tim for your discussion. I managed to create a model which simulates a DC motor with encoder feedback. The reference speed changes at a predefined time interval (e.g. 0.5 sec). A counter counts the pulses coming from the shaft encoder to get the position of the actuator. This counter is then reset to obtain the position at the end of the predefined time interval. Multiplying the final counter content with a constant should give me then the exact position at the end of the time interval (0.5 sec.). This value is then divided by the time interval to get the average speed of the actuator for the predefined time interval.
My problem is now how to get only the final content out of the counter at the end of predefined time interval?
At the moment, I subtract the counter content from the previous time step from the current content to get the position. By the end of the time interval, the counter is reset and this gives me then the final counter content for the particular time step. However, this is done always based on the sampling rate of the simulation (0.001 sec) and not only at the end of the time interval (0.5 sec). To send only the final speed at the end of the time interval to the comperator, I use a zero order hold but I'm not sure if this is the right solution.
PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.