Search code examples
timedelaymodelica

Modelica Hysteresis model with Time_delay


Please I want to modify the existing hysteresis model in modelica such that in addition to using deadband to cause a delayed start in my control, it also considers the duration since the last off cycle. If the off cycle is less than my set threshold, even if the 'canSwitch' condition goes to true, y would be returned as false (i.e., not canSwitch). The idea is to mimic AC behavior where for some ACs, even if the setpoint exceeds the deadband, if the AC has been off for less than 5 mins, it would not come on until after 5 mins.

Below is the code I wrote. It adds a delay, but just for the first cycle. After it turns to true, it remains true for the rest of the simulation even when canSwitch changes to false. I figured out that this problem is due to the when clause only being active when there is an event. So, I edited the line "when canSwitch" to "when initial()", but now it gives error that the problem is overspecified. Please any ideas on how I can fix this problem would be greatly appreciated.

Code snippet


Solution

  • This is an alternative way to make the AC controller, so forgive me for not answering your question directly.

    I would design the controller model graphically, using blocks from Modelica.Blocks.Logical. I often find it easier to break down a problem in this way. The figure below shows an example implementation.

    Exemplary implementation

    The AC is turned on/off by the RS flip-flop which acts as a memory, replacing the hysteresis block. The reset condition is that the temperature is below or equal to 20 °C (T_off). The set condition is that the temperature is above or equal to 25 °C (T_on) AND that the controller has been off (Q!) for at least 300 seconds. Obviously, you could wrap the controller model in a SISO block for reuse.

    The circuit to the right represents the AC and process (room beeing cooled heated). When the AC is on the room temperature is lowered by 1 °C per minute. When it is off, the room temperature increases by 0.3 °C per minute.

    The values are chosen arbitrarily.

    The simulation results are shown below

    Plot of simulation