modelUartLcd20x2

Serial 20x2 display: shows on its icon the lines received on its RX pin, with scrolling

Extends from Internal.Devices.PartialUartDevice (Base of the external serial devices: electrical link, decoding, two transmission modes, quantities exchanged with the model), Internal.Icons.TwoLineTextIcon (Icon of a 20x2 character display: two-line text rendering, shared by the display peripherals).

Information

The electrically real counterpart of Peripherals.Display. Where Display receives its text in one go through a causal logical link (machine.Display, no simulated baud rate), this one decodes a real serial frame arriving on its RX pin, bit by bit, at its own baud rate. A baud rate mismatch with the microcontroller therefore shows directly on the screen, as wrong characters.

On the embedded program side, writing a line ending with a line feed is enough: the device validates the line and triggers the display, exactly like the terminator of a command.

It extends two classes: Internal.Devices.PartialUartDevice for all the serial mechanics, and Internal.Icons.TwoLineTextIcon for the text rendering — the same 20x2 icon as Display, written only once. Beyond 20 characters, the line is truncated on the screen; the full text remains readable in the simulation log.

Write only: the device never answers nor transmits, nor returns anything to the model. Its TX pin (useTxPin) and its valueOut connector (useValueOutput) are therefore removed, like the settings of the request/response mechanics: only RX (and GND, VCC depending on the Electrical tab) remains to be wired.

Parameters

TypeNameDefaultDescription
Electrical › Supply
BooleanuseSupplyPin (from PartialSupplyPin)falseShow the VCC supply pin: the peripheral is supplied by the circuit (its high levels follow VCC, its consumption IQ is drawn from VCC) - unchecked: ideal internal supply VOH, nothing to wire
Modelica.Units.SI.VoltageVOH (from PartialSupplyPin)Interfaces.VOHLogic high voltage: ideal internal supply, high level of the outputs and of the pull-ups - with the VCC pin, the voltage of VCC is used instead
Modelica.Units.SI.CurrentIQ (from PartialSupplyPin)1e-3Current drawn from VCC by the peripheral (quiescent consumption, outputs excluded)
BooleanuseGroundPin (from PartialSupplyPin)trueShow the GND pin - unchecked: the peripheral is referenced to the simulation ground (0 V), nothing to wire
Electrical › Levels
Modelica.Units.SI.VoltageVOL (from PartialUartPins)Interfaces.VOLLogic low voltage
Modelica.Units.SI.VoltageVIH (from PartialUartPins)Interfaces.VIHThreshold above which an input reads high
Modelica.Units.SI.VoltageVIL (from PartialUartPins)Interfaces.VILThreshold below which an input reads low
Electrical › Impedances
Modelica.Units.SI.ResistanceROut (from PartialUartPins)Interfaces.ROutOutput series resistance
Modelica.Units.SI.ResistanceRPullUp (from PartialUartPins)1e6Pull-up of the RX input to the supply
Electrical › Pins
BooleanuseTxPin (from PartialUartPins)trueShow the TX pin - unchecked for a device that never transmits (its output stage then stays unconnected)
Behaviour
Interfaces.UartBehaviourbehaviour (from PartialUartDevice)Interfaces.UartBehaviour.TableOrigin of the behaviour: command table or Python script
StringscriptPath (from PartialUartDevice)""Script .py describing the behaviour of the device (Script mode)
Serial link
Integerbaudrate (from PartialUartDevice)1200Link speed, in baud
IntegerdataBits (from PartialUartDevice)8Number of data bits of a frame (5 to 8, as machine.UART bits=)
Interfaces.UartParityparity (from PartialUartDevice)Interfaces.UartParity.NoneParity of a frame (as machine.UART parity=: None, 0 = even, 1 = odd)
IntegerstopBits (from PartialUartDevice)1Number of stop bits (1 or 2, as machine.UART stop=)
Stringterminator (from PartialUartDevice)"\n"Character marking the end of a received command (only the first character is kept)
Simulation
Modelica.Units.SI.TimetickPeriod (from PartialUartDevice)0.1Period of the minimal sync point: a safety net, the actual pace comes from the engine's deadlines
Table › Request / response
BooleanrespondEnabled (from PartialUartDevice)trueReply to the recognised commands
StringcommandTable (from PartialUartDevice)""Table "CMD=>REPLY|CMD=>REPLY"; "|" and "=>" are reserved. {vN} inserts valueIn[N] into the reply, {oN} captures a number of the command into valueOut[N]
Modelica.Units.SI.TimeresponseDelay (from PartialUartDevice)0.002Delay between the recognition of a command and the start of the reply
BooleanechoEnabled (from PartialUartDevice)falseSend back every received byte unchanged
Table › Periodic transmission
BooleanperiodicEnabled (from PartialUartDevice)falseTransmit spontaneously, without being asked
Modelica.Units.SI.Timeperiod (from PartialUartDevice)1Period of the spontaneous transmission (in Script mode: call period of on_tick)
StringperiodicTemplate (from PartialUartDevice)""Template of the periodically transmitted frame ({vN} inserts valueIn[N])
Inputs / outputs › Inputs ({vN}, inserted into transmitted frames)
BooleanuseValueInput (from PartialUartDevice)falseTake the quantities from the valueIn connector rather than from a constant
IntegernIn (from PartialUartDevice)1Number of quantities received from the model
RealfixedValue (from PartialUartDevice)0Value used when valueIn is not connected
Inputs / outputs › Outputs ({oN}, captured from received frames)
BooleanuseValueOutput (from PartialUartDevice)trueShow the valueOut connector - unchecked for a device that returns nothing to the model
IntegernOut (from PartialUartDevice)1Number of quantities returned to the model - leave the connector unconnected if unused
RealvalueOutStart (from PartialUartDevice)0Value of valueOut before any capture

Connectors

TypeNameDefaultDescription
Modelica.Electrical.Analog.Interfaces.NegativePinGND (from PartialSupplyPin)Common reference (ground), to be connected to the microcontroller's one - shown when useGroundPin is checked
Modelica.Electrical.Analog.Interfaces.PositivePinVCC (from PartialSupplyPin)Supply of the peripheral (e.g. 3V3(OUT) of a Raspberry Pi Pico) - shown when useSupplyPin is checked
Modelica.Electrical.Analog.Interfaces.PositivePinTX (from PartialUartPins)Transmission of the device - to be connected to the receive pin of the microcontroller - shown when useTxPin is checked
Modelica.Electrical.Analog.Interfaces.PositivePinRX (from PartialUartPins)Reception of the device - to be connected to the transmit pin of the microcontroller
Modelica.Blocks.Interfaces.RealInput[nIn]valueIn (from PartialUartDevice)Quantities supplied by the model, inserted into the transmitted frames by {v1}..{vN}
Modelica.Blocks.Interfaces.RealOutput[nOut]valueOut (from PartialUartDevice)Quantities extracted from the received frames by {o1}..{oN} - the device then becomes an actuator

Components

TypeNameDefaultDescription
BooleantxActive (from PartialUartDevice)A frame is being transmitted
BooleanrxBusy (from PartialUartDevice)A frame is being received
StringlastRx (from PartialUartDevice)Last complete line received
StringlastTx (from PartialUartDevice)Last payload transmitted
Integer[Interfaces.DISPLAY_COLS]line1CharCode (from TwoLineTextIcon)ASCII codes of line 1 (current message) - to be fed by the extending model, typically through Internal.Functions.StringToCharCodes
Integer[Interfaces.DISPLAY_COLS]line2CharCode (from TwoLineTextIcon)ASCII codes of line 2 (previous message), for scrolling