xPC Target    

Target Application Model Description

xPC Target includes the Simulink model xpctank.mdl. This is a model of a water tank with a pump, drain, and valve controller.

TankLevel -- The water level in the tank is modeled using a limited integrator named TankLevel.

PumpSwitch -- The pump can be turned off manually to override the action of the controller. This is done by setting PumpSwitch = 0. When PumpSwitch = 1, the controller is able to use the ControlValve to pump water into the tank.

ValveSwitch (drain valve) -- The tank has a drain valve that allows water to flow out of the tank. Think of this as water usage or consumption that reduces the water level. This behavior is modeled with the constant block named ValveSwitch, the gain block Gain2, and a summing junction. The minus sign on the summing junction has the effect of producing a negative flow rate (drain) that reduces the water level in the tank.

Although the ValveSwitch is modeled as a constant block, you can later alter its value using the Dials & Gauges Blockset. When ValveSwitch = 0 (closed), the valve is closed and water cannot flow out of the tank. When ValveSwitch = 1 (open), the valve is open and the water level is reduced by draining the tank.

Controller -- The controller is very simple. It is a bang-bang controller and can only maintain the selected water level by turning the control valve (pump valve) on or off. A water level set point is used to define the desired median water level. Hysteresis is provided to enable the pump to avoid high-frequency on and off cycling. This is done using symmetric upper and lower bounds that are offsets to the median set point. As a result, the controller turns the control valve (pump valve) on whenever the water level is below the set point minus the offset. The summing junction compares this lower bound against the tank water level to determine whether or not to open the control valve. If the pump is turned on (PumpSwitch = 1), water is pumped into the tank. When the water level reaches or exceeds the set point plus the upper bound, the controller turns off the control valve. Regardless of whether the pump is on or off, water stops pumping into the tank.

Scope blocks -- A standard Simulink scope block is added to the model to view signals during a simulation. xPC Target scope blocks are added to the model for you to view signals while running the target application. Scope-Id1 displays the actual water level and the selected water level in the tank. Scope-Id2 displays the control signals. Both scopes are displayed on the target PC using a scope of type target. These scope blocks cannot be controlled by the Dials & Gauges Blockset or xPC Target interface blocks.

Notice that the model xpctank.mdl does not contain any Dials & Gauges blocks or xPC Target interface blocks. This model is built entirely from standard Simulink blocks and scope blocks from xPC Target. It does not differ in any way from a model you would normally use with xPC Target and it does not require any changes (except for tagging properties and signals) to use it with a Dials & Gauges interface.


  Introduction to the Dials & Gauges Blockset Creating a Target Application Model