User Tools

Site Tools


lego_rip_prog_simulink

This is an old revision of the document!


Getting the angles and calculating the velocities from the encoders:

  • Motor Encoder Logic: We can get the angle from the encoder using the “Encoder” block, the encoder block returns an integer value in degrees.However for our calculations is better to use a variable with better precision, so we use a “Data Type Conversion” block to convert the angle from integer to double precision. After , we need to convert this angle in degrees to radians , so a “Gain” block is used for this task. Using a “Discrete State – Space” block we can derive the velocity , using the angle as input.

1) Drag the following blocks to the work area: 1x Encoder / 1x Data Type Conversion / 1x Gain / 1x Discrete State Space / 2x Output (Out1).

2) Double click on the following blocks to modify its parameters:

  • Encoder : Change the port to port A, reset mode as no reset, and sample time to -1.
  • Data Type Conversion : Output type to double , Integer rounding mode to Simplest.
  • Gain: change the value to pi/180 with element wise multiplication.
  • Discrete State Space: Change the A,B,C,D matrix to the name of your A,B,C,D matrix that represents your discrete state space model stored on the workspace. Use the Sample time as you want ,can be 0.010. ( Be sure to use the same Sample time on the pendulum encoder and on the model configuration – will be explained later)
  • Output: Change the name for Motor Angle and Motor Velocity.
lego_rip_prog_simulink.1460962775.txt.gz · Last modified: 2016/04/17 23:59 by joaomatos