Encoder position derivative Simulink

조회 수: 9 (최근 30일)
Marco
Marco 2017년 3월 29일
댓글: Daniel 2024년 12월 2일
Hi, I'm new of simulink and I'm doing some test on a DC motor connected, through a servomechanism, to a disk.The position of the disk is given by an encoder. A block in Simulink gives me out the number of rounds of the disk. How could I derivate this data to obtain velocity? I know the sample time of the encoder; but I do not manage to: -save (online measuraments) the samples, -make a difference between the new sample and the previous one -at the end devide by sample time. What kind of block could I use to save a sample each sample interval? Thank you very much every one.

답변 (2개)

Marco
Marco 2017년 3월 30일
Thanks! this helps a lot! But can I use this values of velocity for a real time control of velocity of the motor? Because I think that in this way I'm introducing a delay that there is not in the real system. Am I wrong?
  댓글 수: 1
Domenico Tuccillo
Domenico Tuccillo 2023년 11월 27일
편집: Domenico Tuccillo 2023년 11월 27일
Did you find out if it's a problem for a controller?

댓글을 달려면 로그인하십시오.


Richard Zappulla
Richard Zappulla 2017년 3월 30일
As for saving the data, I would suggest using a "To File" block (under the "Sinks" folder). In the image below, I used a vector concatenate block to form a vector which goes into the "To File" block. You can also use a Mux block as well in this case.
If you use the "To File" block, make sure you have the right "Save Format" selected. You can either save it as an Array (which automatically add the model time as the first row in the data) or a Timeseries object (link to documentation for Time Series Objects )
To differentiate the encoder position to get its velocity, I first assume you are using a fixed-step or discrete model. (If you are not, there are continuous versions of these blocks that you can use). The velocity can be found by modeling the following equation in Simulink:
velocity = (sample(n) - sample(n-1))/Ts
You can perform this a few ways ( Note: items correspond with the picture below):
  1. Write the equation above using basic Simulink blocks (e.g., Add, Unit Delay, Gain).
  2. Use a Discrete Derivative Block (under the "Discrete" folder). The input to this block would be the samples coming from the encoder. The output would be your velocity.
  3. Use a Difference block (from the "Discrete" Folder) followed by a gain block
Hope this helps!

카테고리

Help CenterFile Exchange에서 Inputs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by