Buildings.Controls.OBC.CDL.Discrete.Examples

Collection of models that illustrate model use and test models

Information

This package contains examples for the use of models that can be found in Buildings.Controls.OBC.CDL.Discrete.

Package Content

Name Description
Buildings.Controls.OBC.CDL.Discrete.Examples.DayType DayType Example model for the source that outputs the type of the day
Buildings.Controls.OBC.CDL.Discrete.Examples.FirstOrderHold FirstOrderHold Example model for the FirstOrderHold block
Buildings.Controls.OBC.CDL.Discrete.Examples.MovingMean MovingMean Validation model for the MovingMean block
Buildings.Controls.OBC.CDL.Discrete.Examples.Sampler Sampler Example model for the Sampler block
Buildings.Controls.OBC.CDL.Discrete.Examples.TriggeredMax TriggeredMax Example model for the TriggeredMax block
Buildings.Controls.OBC.CDL.Discrete.Examples.TriggeredSampler TriggeredSampler Example model for the TriggeredSampler block
Buildings.Controls.OBC.CDL.Discrete.Examples.UnitDelay UnitDelay Example model for the UnitDelay block
Buildings.Controls.OBC.CDL.Discrete.Examples.ZeroOrderHold ZeroOrderHold Example model for the ZeroOrderHold block

Buildings.Controls.OBC.CDL.Discrete.Examples.DayType Buildings.Controls.OBC.CDL.Discrete.Examples.DayType

Example model for the source that outputs the type of the day

Buildings.Controls.OBC.CDL.Discrete.Examples.DayType

Information

This example generates signals for three different work weeks. The instance dayTypMon outputs a signal with five working days, followed by two non-working days. The instance dayTypSat does the same, except that the first days is a non-working day. The instance dayTypTwoWeeks outputs six working days, followed by 8 non-working days. The instance dayTypMonThr is configured the same as dayTypMon, except that it outputs the type of the day for three days, starting with the current day, then the next day and the day after.

Modelica definition

model DayType "Example model for the source that outputs the type of the day" Buildings.Controls.OBC.CDL.Discrete.DayType dayTypMon "Model that outputs the type of the day, starting with Monday"; Buildings.Controls.OBC.CDL.Discrete.DayType dayTypSat(iStart=6) "Model that outputs the type of the day, starting with Saturday"; Buildings.Controls.OBC.CDL.Discrete.DayType dayTypTwoWeeks(days={ Types.Day.WorkingDay,Types.Day.WorkingDay, Types.Day.WorkingDay,Types.Day.WorkingDay, Types.Day.WorkingDay,Types.Day.WorkingDay, Types.Day.NonWorkingDay,Types.Day.NonWorkingDay, Types.Day.NonWorkingDay,Types.Day.NonWorkingDay, Types.Day.NonWorkingDay,Types.Day.NonWorkingDay, Types.Day.NonWorkingDay,Types.Day.NonWorkingDay}, nout=14) "Model that outputs the type of the day, starting with 6 workdays, then 8 non-working days"; Buildings.Controls.OBC.CDL.Discrete.DayType dayTypMonThr(nout=3) "Model that outputs the type of the day for 3 days, starting with Monday"; end DayType;

Buildings.Controls.OBC.CDL.Discrete.Examples.FirstOrderHold Buildings.Controls.OBC.CDL.Discrete.Examples.FirstOrderHold

Example model for the FirstOrderHold block

Buildings.Controls.OBC.CDL.Discrete.Examples.FirstOrderHold

Information

Validation test for the block Buildings.Controls.OBC.CDL.Discrete.FirstOrderHold.

Modelica definition

model FirstOrderHold "Example model for the FirstOrderHold block" Buildings.Controls.OBC.CDL.Discrete.FirstOrderHold firOrdHol( samplePeriod = 0.2) "Block that first order hold of a sampled-data system"; Buildings.Controls.OBC.CDL.Continuous.Sources.Ramp ramp1( duration=1, offset=0, height=6.2831852) "Block that generates ramp signal"; Buildings.Controls.OBC.CDL.Continuous.Cos cos1 "Block that outputs the cosine of the input"; equation connect(ramp1.y, cos1.u); connect(cos1.y, firOrdHol.u); end FirstOrderHold;

Buildings.Controls.OBC.CDL.Discrete.Examples.MovingMean Buildings.Controls.OBC.CDL.Discrete.Examples.MovingMean

Validation model for the MovingMean block

Buildings.Controls.OBC.CDL.Discrete.Examples.MovingMean

Information

Validation test for the block Buildings.Controls.OBC.CDL.Discrete.MovingMean.

Modelica definition

model MovingMean "Validation model for the MovingMean block" Continuous.Sources.Sine sin( freqHz=1/8, phase=0.5235987755983, startTime=-0.5) "Example input signal"; Buildings.Controls.OBC.CDL.Discrete.MovingMean movMea(n=4, samplePeriod=1) "Discrete moving mean of the sampled input signal"; equation connect(sin.y, movMea.u); end MovingMean;

Buildings.Controls.OBC.CDL.Discrete.Examples.Sampler Buildings.Controls.OBC.CDL.Discrete.Examples.Sampler

Example model for the Sampler block

Buildings.Controls.OBC.CDL.Discrete.Examples.Sampler

Information

Validation test for the block Buildings.Controls.OBC.CDL.Discrete.Sampler.

Modelica definition

model Sampler "Example model for the Sampler block" Buildings.Controls.OBC.CDL.Discrete.Sampler sampler1( samplePeriod = 0.2) "Ideal sampler of a continuous signal"; Buildings.Controls.OBC.CDL.Continuous.Sources.Ramp ramp1( duration=1, offset=0, height=6.2831852) "Block that generates ramp signal"; Buildings.Controls.OBC.CDL.Continuous.Sin sin1 "Block that outputs the sine of the input"; equation connect(ramp1.y, sin1.u); connect(sin1.y, sampler1.u); end Sampler;

Buildings.Controls.OBC.CDL.Discrete.Examples.TriggeredMax Buildings.Controls.OBC.CDL.Discrete.Examples.TriggeredMax

Example model for the TriggeredMax block

Buildings.Controls.OBC.CDL.Discrete.Examples.TriggeredMax

Information

Validation test for the block Buildings.Controls.OBC.CDL.Discrete.TriggeredMax.

Modelica definition

model TriggeredMax "Example model for the TriggeredMax block" Buildings.Controls.OBC.CDL.Discrete.TriggeredMax triggeredMax "Output the maximum, absolute value of a continuous signal at trigger instants"; Buildings.Controls.OBC.CDL.Continuous.Sources.Ramp ramp1( duration=1, offset=0, height=6.2831852) "Block that generates ramp signal"; Buildings.Controls.OBC.CDL.Continuous.Sin sin1 "Block that outputs the sine of the input"; Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul( width=0.5, period=0.2) "Block that outputs cyclic on and off"; equation connect(ramp1.y, sin1.u); connect(sin1.y, triggeredMax.u); connect(booPul.y, triggeredMax.trigger); end TriggeredMax;

Buildings.Controls.OBC.CDL.Discrete.Examples.TriggeredSampler Buildings.Controls.OBC.CDL.Discrete.Examples.TriggeredSampler

Example model for the TriggeredSampler block

Buildings.Controls.OBC.CDL.Discrete.Examples.TriggeredSampler

Information

Validation test for the block Buildings.Controls.OBC.CDL.Discrete.TriggeredSampler.

Modelica definition

model TriggeredSampler "Example model for the TriggeredSampler block" Buildings.Controls.OBC.CDL.Continuous.Sources.Ramp ramp1( duration=1, offset=0, height=6.2831852) "Block that generates ramp signal"; Buildings.Controls.OBC.CDL.Continuous.Sin sin1 "Block that outputs the sine of the input"; Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul( width=0.5, period=0.2) "Block that outputs cyclic on and off"; Buildings.Controls.OBC.CDL.Discrete.TriggeredSampler triSam "Triggered sampler wity y_start = 0"; Buildings.Controls.OBC.CDL.Discrete.TriggeredSampler triSam1(y_start=1) "Triggered sampler with y_start = 1"; equation connect(ramp1.y, sin1.u); connect(sin1.y, triSam.u); connect(booPul.y, triSam.trigger); connect(sin1.y, triSam1.u); connect(booPul.y, triSam1.trigger); end TriggeredSampler;

Buildings.Controls.OBC.CDL.Discrete.Examples.UnitDelay Buildings.Controls.OBC.CDL.Discrete.Examples.UnitDelay

Example model for the UnitDelay block

Buildings.Controls.OBC.CDL.Discrete.Examples.UnitDelay

Information

Validation test for the block Buildings.Controls.OBC.CDL.Discrete.UnitDelay.

Modelica definition

model UnitDelay "Example model for the UnitDelay block" Buildings.Controls.OBC.CDL.Discrete.UnitDelay unitDelay1( samplePeriod = 0.2) "Sample period of component"; Buildings.Controls.OBC.CDL.Continuous.Sources.Ramp ramp1( duration=1, offset=0, height=6.2831852) "Block that generates ramp signal"; Buildings.Controls.OBC.CDL.Continuous.Sin sin1 "Block that outputs the sine of the input"; equation connect(ramp1.y, sin1.u); connect(sin1.y, unitDelay1.u); end UnitDelay;

Buildings.Controls.OBC.CDL.Discrete.Examples.ZeroOrderHold Buildings.Controls.OBC.CDL.Discrete.Examples.ZeroOrderHold

Example model for the ZeroOrderHold block

Buildings.Controls.OBC.CDL.Discrete.Examples.ZeroOrderHold

Information

Validation test for the block Buildings.Controls.OBC.CDL.Discrete.ZeroOrderHold.

Modelica definition

model ZeroOrderHold "Example model for the ZeroOrderHold block" Buildings.Controls.OBC.CDL.Discrete.ZeroOrderHold zerOrdHol( samplePeriod = 0.2) "Output the input signal with a zero order hold"; Buildings.Controls.OBC.CDL.Continuous.Sources.Ramp ramp1( duration=1, offset=0, height=6.2831852) "Block that generates ramp signal"; Buildings.Controls.OBC.CDL.Continuous.Cos cos1 "Block that outputs the cosine of the input"; equation connect(ramp1.y,cos1. u); connect(cos1.y, zerOrdHol.u); end ZeroOrderHold;