modelPartialRadioModem

Base of the transparent radio modems: serial link with the microcontroller, radio frames on air, buffers, fixed delays, drawn modulated signal

Extends from PartialUartPins (Electrical side of a serial device: TX output and RX input on two pins, common ground, optional VCC pin - shared by the serial devices and the radio modems).

Information

Base class of the transparent radio modems. It cannot be instantiated directly: see Peripherals.Radio.RadioModem.

The modem is connected electrically to two GPx pins of an MCU (machine.UART), and to the other module(s) by one antenna wire. What it receives on its UART leaves on air, and what it hears on air comes out on its UART:

  • a byte received from the microcontroller waits in the transmit buffer (txBufferSize bytes) at least txDelay, then leaves in a radio frame of 8N1 type at airBaudrate, possibly different from the serial speed;
  • a radio frame heard intact waits in the receive buffer (rxBufferSize) at least rxDelay, then leaves on the UART;
  • a byte that finds its buffer full is lost; a corrupted radio frame (different air data rates, for example) is dropped, as by a real module that checks its packets; in half duplex, a frame arriving while the module transmits is lost.

Masked synchronisation. The receiver does not demodulate sTx: the antenna wire also carries the bit being transmitted, which the receiver decodes as a real serial receiver would, at its own air data rate. The modulated signal is drawn for teaching purposes, with a scaled carrier (fDisplay) since a real carrier cannot be drawn; to see it, reduce the output interval of the simulation well below 1/fDisplay. A receiver only hears a transmitter on its channel (fCarrier within half a channelWidth) and with its modulation.

The icon shows the radio frames being transmitted (amber dot) and received (cyan dot) and the filling of the two buffers, while replaying a result with animation in OMEdit. At the end of the simulation, each module writes a summary line in the log: bytes passed, bytes lost and why.

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)
Serial link (microcontroller side)
Integerbaudrate9600Speed of the serial link with the microcontroller, in baud
IntegerdataBits8Number of data bits of a serial frame (5 to 8, as machine.UART bits=)
Interfaces.UartParityparityInterfaces.UartParity.NoneParity of a serial frame (as machine.UART parity=: None, 0 = even, 1 = odd)
IntegerstopBits1Number of stop bits of a serial frame (1 or 2, as machine.UART stop=)
Radio
Interfaces.ModulationmodulationInterfaces.Modulation.FSKModulation of the carrier by the bits of the radio frame - a receiver only hears a transmitter using the same one
Modelica.Units.SI.FrequencyfCarrier434e6Nominal carrier frequency (channel) - a receiver only hears a transmitter whose carrier is within half a channel width of its own
Modelica.Units.SI.FrequencychannelWidth200e3Width of the channel heard around fCarrier
IntegerairBaudrate9600Air data rate, in bit/s - radio frame 8N1, independent of the serial link; both modules must use the same
BooleanhalfDuplextrueDeaf while transmitting: a frame arriving during our own transmission is lost (one radio channel cannot carry both directions at once)
Buffers and delays
IntegertxBufferSize256Transmit buffer (UART -> air), in bytes - a byte arriving from the UART while it is full is lost
IntegerrxBufferSize256Receive buffer (air -> UART), in bytes - a byte arriving from the air while it is full is lost
Modelica.Units.SI.TimetxDelay0.005Fixed delay between the end of a byte on the UART and its earliest transmission on air
Modelica.Units.SI.TimerxDelay0.001Fixed delay between the end of a byte on air and its earliest transmission on the UART
Drawn signal › Drawn carrier
Modelica.Units.SI.FrequencyfDisplay4*airBaudrateScaled carrier used to draw sTx (a real one, hundreds of MHz, cannot be drawn). Default 4*airBaudrate = 4 periods per bit: 4.8 kHz at 1200 bit/s, 38.4 kHz at 9600 bit/s
Modelica.Units.SI.FrequencydeltaFDisplayairBaudrateFSK only: shift of the drawn carrier, fDisplay - deltaFDisplay for a 0, fDisplay + deltaFDisplay for a 1. Default airBaudrate: 3 and 5 periods per bit (28.8 and 48 kHz at 9600 bit/s)
RealaskLowAmplitude0.3ASK only: amplitude of the drawn carrier for a 0 (1 for a 1). 0 looks like OOK, 0.3 is clearly visible, above 0.7 a 0 is hard to tell from a 1
Drawn signal › Simulation
BooleanwarnSamplingtrueWarn in the log when the output interval is too long to draw the carrier: more than 1/(10*(fDisplay + deltaFDisplay in FSK)), i.e. 2.1 us at 9600 bit/s with the defaults
Modelica.Units.SI.TimetickPeriod0.1Period of the minimal sync point: a safety net, the actual pace comes from the engine's deadlines

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
Interfaces.AntennaantennaAntenna: connect it with ONE wire to the antenna of the module(s) to talk to

Components

TypeNameDefaultDescription
RealsTxModulated signal transmitted, drawn with the scaled carrier fDisplay (0 when not transmitting) - reduce the output interval to see the carrier
RealsRxSignal of the other transmitter as received by this module, whatever its tuning (0 when no other module transmits)
BooleancarrierOncarrierOnCA radio frame is being transmitted
BooleanairRxBusyairRxBusyCA radio frame is being received
IntegertxFilltxFillCBytes waiting in the transmit buffer (UART -> air)
IntegerrxFillrxFillCBytes waiting in the receive buffer (air -> UART)
IntegernSentnSentCRadio frames transmitted so far
IntegernReceivednReceivedCRadio frames received intact so far
IntegernDroppednDroppedCBytes lost so far because a buffer was full
IntegernCorruptednCorruptedCRadio frames lost so far: corrupted (air data rate mismatch...), collided, or cut by our own transmission in half duplex
BooleanheardExactly one other module transmits, on our channel and with our modulation: its frame reaches the decoder
BooleancollisionjamTwo other modules or more transmit at once: the frame being received is lost