modelSensor

The microcontroller queries a serial temperature sensor, reads two changing measurements, then sends it a setpoint that comes out on a real output

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

Information

A complete request / response dialogue, in both directions, over an electrical serial link.

What the input port brings. The temperature is not a constant frozen in the sensor: it comes in through the valueIn connector, here from a ramp. The microcontroller queries the sensor twice, 100 ms apart, and reads two different values — any thermal model can be connected instead of the ramp.

And in the other direction. The program ends with SET 42.5. The sensor recognises this pattern thanks to the capture marker {o1} of its table, and the number comes out on sensor.valueOut[1]. Plotting this variable shows the setpoint appearing at the exact instant the frame finishes arriving. For a complete loop where this output really drives a plant, see Examples.Uart.Regulation.

Components

TypeNameDefaultDescription
MCUmcuscriptPath = Resources/Scripts/MCU/uart_sensor.py
MicroPythonMCU.Peripherals.UartTemperatureSensorsensorAnswers AT+TEMP with the temperature present on its input, and SET with a setpoint on its output
Modelica.Blocks.Sources.RamptemperatureThe measured quantity rises from 20 to 40 °C: the two queries must therefore give two different values
Modelica.Electrical.Analog.Basic.Groundground