modelRegulation
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:
- the microcontroller sends
AT+TEMP; the sensor answers with the value present onvalueIn[1]; - the program computes a command (proportional controller with static gain compensation) and sends
SET <command>; - the
{o1}marker of the table captures this number and publishes it onvalueOut[1]; valueOut[1]drives the first-order plant, whose output comes back onvalueIn[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
| Type | Name | Default | Description |
|---|---|---|---|
| MCU | mcu | scriptPath = Resources/Scripts/MCU/uart_regulation.py | |
| MicroPythonMCU.Peripherals.UartTemperatureSensor | sensor | Sensor AND actuator: {v1} publishes the measurement, {o1} captures the command | |
| Modelica.Blocks.Continuous.FirstOrder | plant | First-order thermal plant: input = command (0-100), output = temperature (°C) | |
| Modelica.Electrical.Analog.Basic.Ground | ground |