# MATLAB/SIMULINK Blocksets for Matlab > 6.0

#### To use one of the functions described below, download the zip-file and extract the .c, .dll and the .mdl file. Save the files in your model directory, such that Matlab and dSPACE is able to find them. To include the function in your own model, open the .mdl file and use copy/paste.

#### Note: The zip-files indicated below are for use with Matlab 5.3. Matlab 5.2 users may encounter difficulties with the included Simulink models. Here are Matlab 5.2 versions of the Staircase function, the Smooth function, the Reference Generator.

## · Staircase function.

Generates a staircase reference signal.

o |
Parameters: |

§ |
Number of steps |

§ |
Increment for every step |

§ |
Time for every step |

o |
Inputs: |

§ |
Direction: When 0, the output will go down to zero, otherwise the output goes up to the specified number of steps |

o |
Outputs: |

§ |
The generated signal, staircase-shaped |

§ |
Relative time: The time elapsed since the start of the staircase (this signals resets to zero when the staircase reaches its final value) |

#### Example

Number of steps = 10 Increment per step = 10 Time for every step = 0.2

The figures below show the input signal (in) and the two output signals (Out and RelTime)

## · Smooth function.

Makes an input signal more smooth by generating a sigmoid (skew-sinus). As soon as the input signal changes, a new sigmoid is generated, starting at the old input value, ending in the new input value, over a duration of the specified setup-time.

o |
Parameters: |

§ |
Setup time: This is the time it will take to make the output value equal to the current input value |

o |
Inputs: |

§ |
Reference value: As soon as this input changes, a new sigmoid function is generarted, starting at the old input value, ending in the new input value |

o |
Outputs: |

§ |
The generated signal, sigmoid-shaped |

#### Example

Setup time = 1

The figures below show the input signal (in) and the output signal (Out)

## · Reference Generator for matlab <6.1

## · Reference generator for matlab 6.5

This function can generate a wide variety of reference signals.

o |
Parameters: |

§ |
Setup time: This is the time it will take to make output value from the current value to the new desired value. When this parameter is zero, the specified maximum velocity and maximum acceleration are used to calculate the setup time. |

§ |
Setup function type: |

§ |
0 : Step |

§ |
1 : Ramp |

§ |
2 : Second order |

§ |
3 : Third order |

§ |
4 : Skew-sinus |

§ |
Maximum Acceleration: Only applies for second/third/skewsinus type functions. |

§ |
Maximum Velocity: Only applies for second/third/skewsinus type functions. This parameter is only used when the setup time is specified as 0 (i.e. when the trajectory-time is calculated online) |

o |
Inputs: |

§ |
ActualPos: When a new reference is started, it will start at this value |

§ |
DesiredPos: Desired end value of the refernce signal |

§ |
Start: This signal triggers the generation of the reference signal. When zero, the output will be equal to the 'ActualPos' input. Otherwise the reference trajectory is generated |

o |
Outputs: |

§ |
Position: This is the generated reference signal. When the 'Start' input is zero, this output will be equal to the 'current value' input. |

§ |
Velocity: Derivative of the reference position. When the 'Start' input is zero, this output will be 0. |

§ |
Acceleration: Derivative of the reference velocity. When the 'Start' input is zero, this output will be 0. This signal will also be zero if the acceleration is infinit. |

§ |
Ready: Indicates when the reference trajectory has finished. |

#### Example

Setup time = 0 Type = 4 (skew-sinus) MaxAcc = 5 MaxVel = 1

The inputs are selected as: ActualPos = 0.5 DesiredPos = -0.5

The figures below show the four output signals (Position, Velocity, Acceleration and Ready)

## · PRBS Generator

This function can generate a Pseuco-Random Binary Signal (PRBS), see e.g. the System Identification toolbox. The output is a maximum length PRBS with a periodicity of 2^{18}-1 (in Matlab see: help idinput). Note that for old versions of Matlab (pre-R14SP3) one needs this file.

o |
Parameters: |

§ |
Discrete time step: This parameter specified at which rate output is generated. |

§ |
Mean value: The output is centered around this value. |

§ |
Amplitude: The output equals the mean value plus or minus this amplitude. |

o |
Output: |

§ |
The generated PRBS signal. |

#### Example

Discrete time step = 0.05, Mean value = 0, Amplitude = 4

The figure below shows the output signal.

For comments or questions, please contact J.van Dijk

The PRBS block has been created by Ronald Aarts.