Ramp Generator - Generate ramp output

Library

c28xdmclib in Target Support Package™ TC2 software

Description

This block generates ramp output (out) from the slope of the ramp signal (gain), DC offset in the ramp signal (offset), and frequency of the ramp signal (freq) inputs. All of the inputs and output are 32-bit fixed-point numbers with Q values between 1 and 29.

Algorithm

The block's output (out) at the sampling instant k is governed by the following algorithm:

out(k) = angle(k) * gain(k) + offset(k)

For out(k) > 1, out(k) = out(k) - 1. For out(k) < -1, out(k) = out(k) + 1.

Angle(k) is defined as follows:

angle(k) = angle(k-1) + freq(k) * Maximum step angle

for angle(k) > 1, angle(k) = angle(k) - 1

for angle(k) < -1, angle(k) = angle(k) + 1

The frequency of the ramp output is controlled by a precision frequency generation algorithm that relies on the modulo nature of the finite length variables. The frequency of the output ramp signal is equal to

f = (Maximum step angle * sampling rate) / 2m

where m represents the fractional length of the data type of the inputs.

All math operations are carried out in fixed-point arithmetic, where the fixed-point fractional length is determined by the block's inputs.

Dialog Box

Maximum step angle

The maximum step size, which determines the rate of change of the output (i.e., the minimum period of the ramp signal).

Examples

The following model demonstrates the Ramp Generator block. The Constant and Scope blocks are available in Simulink® Commonly Used Blocks.

In your model, select Simulation > Configuration Parameters. On the Solver pane, set Type to Fixed-step and Solver to discrete (no continuous states). Set the parameter values for the blocks as shown in the following table.

Block

Connects to

Parameter

Value

Constant

Ramp Generator - gain

Constant value

Sample time

Output data type

Output scalig value

1

0.001

sfix(32)

2^-9

Constant

Ramp Generator - offset

Constant value

Sample time

Output data type

Output scalig value

0

inf

sfix(32)

2^-9

Constant

Ramp Generator - freq

Constant value

Sample time

Output data type

Output scalig value

0.001

inf

sfix(32)

2^-9

Ramp Generator

Scope and Floating Scope (Simulink block)

Maximum step angle

1

When you run the model, the Scope block generates the following output (drag a zoom box around a portion of the output to change the display).

The expected frequency of the output is

f = (maximum step angle * sampling rate) / 2m

f = (1 * 1000) / 2^9 = 1.9531 Hz

The expected period is then

T = 1/f = 0.5120 s

which is what the above Scope output shows.

See Also

Ramp Control

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS