modelRegulation

Control loop closed through the serial link alone: the real output of the sensor drives the plant, whose response comes back on its input

Extends from Modelica.Icons.Example (Icon for runnable examples).

Information

The example that really uses the real output of the serial device. All the rest of the family shows quantities that go into the frames; here a quantity comes out of them and drives the model.

The loop is closed and only goes through the two wires of the serial link:

  1. the microcontroller sends AT+TEMP; the sensor answers with the value present on valueIn[1];
  2. the program computes a command (proportional controller with static gain compensation) and sends SET <command>;
  3. the {o1} marker of the table captures this number and publishes it on valueOut[1];
  4. valueOut[1] drives the first-order plant, whose output comes back on valueIn[1].

Plotting plant.y shows the temperature reaching the 40 °C setpoint, and sensor.valueOut[1] shows the command changing in steps — one step per dialogue cycle, since the control is only refreshed at the pace of the serial exchanges. This is precisely what this circuit lets you study: the effect of the sampling period imposed by the link speed on the loop dynamics. Lowering baudrate spaces the cycles out and visibly degrades the response.

Components

TypeNameDefaultDescription
MCUmcuscriptPath = Resources/Scripts/MCU/uart_regulation.py
MicroPythonMCU.Peripherals.UartTemperatureSensorsensorSensor AND actuator: {v1} publishes the measurement, {o1} captures the command
Modelica.Blocks.Continuous.FirstOrderplantFirst-order thermal plant: input = command (0-100), output = temperature (°C)
Modelica.Electrical.Analog.Basic.Groundground