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.
Generates a staircase reference signal.
§Number of steps
§Increment for every step
§Time for every step
§Direction: When 0, the output will go down to zero, otherwise the output goes up to the specified number of steps
§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)
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)
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.
§Setup time: This is the time it will take to make the output value equal to the current input value
§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
§The generated signal, sigmoid-shaped
Setup time = 1
The figures below show the input signal (in) and the output signal (Out)
This function can generate a wide variety of reference signals.
§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)
§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
§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.
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)
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 218-1 (in Matlab see: help idinput). Note that for old versions of Matlab (pre-R14SP3) one needs this file.
§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.
§The generated PRBS signal.
Discrete time step = 0.05, Mean value = 0, Amplitude = 4
The figure below shows the output signal.