Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

DC_MatlabDataItemPID Class Reference

#include <DC_MatlabDataItemPID.h>

Inheritance diagram for DC_MatlabDataItemPID:

DataItemControlBlock ControlBlock CC_RootObject List of all members.

Detailed Description

Matlab Wrapper for a PID Control Block.

This class assumes that the Real-Time Workshop code generation tool with which the wrapped code was generated using the "RTW Embedded Coder" target file. The storage class of all inputs, outputs and parameters is assumed to have been set to "ExportedGlobal".

This class was tested only with code generated by Real-Time Workshop Embedded Coder version 3.0.

The Matlab-generated code is not part of the OBS Framework. It must be provided by the user. This class assumes that the code is placed in directory: "../MatlabAutocode" where the path is relative to the directory where this class is stored.

Since not all users will be able to provide this code, a compiler switch is provided to disable use of the matlab-generated code. If the macro HAVE_SIMULINK is not defined, then the class behaves like a dummy class that implements a trivial transfer function.

The wrapper is implemented as a form of control block. The control block has 1 inputs and 1 outputs. The control block has the following parameters:

The model "step" and "initialization" functions are: PID_step and PID_init. The model "terminate" function is never invoked (OBS classes are never destroyed). The data item link mechanism is used to link the Matlab inputs and outputs to their external inputs and outputs.

This class should be used as a singleton because the matlab-generated code is not re-entrant.

See also:
HAVE_SIMULINK
Author:
R. Totaro (code template) / A. Pasetti (code generator)
Version:
1.0

Definition at line 69 of file DC_MatlabDataItemPID.h.

Public Member Functions

 DC_MatlabDataItemPID ()
 Configure the PID control block.

virtual void reset ()
 Reset the control block by invoking the matlab-generated initialize function.


Protected Member Functions

virtual void propagateState ()
 Implement the state propagation function.

virtual void updateOutput ()
 Implement the output update function.


Constructor & Destructor Documentation

DC_MatlabDataItemPID::DC_MatlabDataItemPID  ) 
 

Configure the PID control block.

The control block is configured to have one input, one outputs, three parameters. The three parameters represent the proportional, integral and derivative gain. The number of states is set to zero because the state is maintained internally to the Simulink-generated code. The Simulink model is initialized by calling the reset method. The class identifier is set. A pseudo-code implementation of this method therefore is:<PRE> . . . // set up internal data structures to link to matlab code . . . // set class identifier setNumberOfStates(0); setNumberOfInputs(1); setNumberOfOutputs(1); setNumberOfParameters(3); reset(); Note that the number of states is set to zero because the matlab code already provides a data structure to save the propagation state.

This class should only be instantiated once.

Definition at line 21 of file DC_MatlabDataItemPID.cpp.


Member Function Documentation

void DC_MatlabDataItemPID::propagateState  )  [protected, virtual]
 

Implement the state propagation function.

State propagation is performed internally to the matlab-generated code. This method therefore performs only the following two housekeeping tasks:<ul> Copy the values of the parameters from the buffer maintained by the control block class into the parameter buffer maintained by the Matlab code Load the values of the inputs into the input buffer maintained by the Matlab code

See also:
ControlBlockFloatDbPar#propagate

Implements ControlBlock.

Definition at line 57 of file DC_MatlabDataItemPID.cpp.

void DC_MatlabDataItemPID::updateOutput  )  [protected, virtual]
 

Implement the output update function.

This method performs the following two tasks:<ul> Call the matlab-generated step function Write the values of the outputs computed by the matlab-generated code to the control block outputs

See also:
ControlBlock::propagate

Implements ControlBlock.

Definition at line 67 of file DC_MatlabDataItemPID.cpp.


The documentation for this class was generated from the following files:
Copyright 2003 P&P Software GmbH - All Rights Reserved