Submitted:
21 May 2025
Posted:
21 May 2025
You are already at the latest version
Abstract
Keywords:
1. Motivation and Related Work
2. System Architecture
3. Core Framework Components
3.1. Real-time Tasks and Control Cycle
- 1.
- During the computation phase (C phase) the control task executes the time-triggered portion of the real-time algorithms, by invoking the control function. The control function operates on input data and stores results into output data held in abstract process image (PI) variables through bi-directional data flow ➁ shown in Figure 2. These variables are stored in their own memory area, denoted as [A] in the figure, and are mapped to local or remote I/O points by the system configuration to be discussed in Section 5.
- 2.
- In the output phase (O phase) the control task commits the value of all output PI variables to the corresponding output points, possibly going through a data format conversion stage specified by the configuration system. The conversion is transparent to the control function and adapts the CPU-dependent representation of memory-resident data to the format required by each specific I/O device. All I/O activities are performed by a real-time communication module, assisted by a set of real-time I/O libraries that provide I/O functions specific to each communication medium RtFw supports.
- 3.
- Finally, in the input phase (I phase) the control task queries input points and stores their values into the corresponding input PI variables, ready to be used during the C phase of the next cycle. Also in this case, data format conversions are performed as required and I/O activities are coordinated by the communication module. During both the O and I phases, input and output data are transferred through data flow ➀ and the control function is kept inactive to avoid race conditions.

3.2. Control Function
- A pointer to the RtFw state. Although simple time-triggered control functions may let RtFw manage it automatically, more complex control functions can query it to get detailed runtime information about all RtFw components. Moreover, during sporadic event handling the control function must inform RtFw of any updates it made to PI variables, so that the control task can refresh them appropriately.
- The current cycle number, which gives the control function information about elapsed time with a granularity of the cyclic executive period. Since this data item has limited width (32 bits in the current implementation), RtFw provides functions for modulo- time calculations. In order to support more sophisticated time-driven execution patterns, RtFw also provides multiple one-shot and periodic timers that the control function can set at will, with the same resolution. Higher-resolution timers for event-driven programming are made available by the underlying operating system and utility libraries.
- The event type that triggered the current invocation. The first and most important information that the control function can derive from this argument is whether it should perform a time-triggered C phase or handle a sporadic event. In the second case, it conveys more information about the event itself.
- A pointer to a user-defined data structure, which the user communicates to RtFw upon system initialization and is then made accessible to the control function upon every invocation. Besides propagating the pointer, RtFw does not use this structure in any other way.
3.3. User Interface and Proxy Access
4. Event-Driven Programming
4.1. Hold-Off Interval and Overload Avoidance
- At any time the event management task can be in one of two possible states, denoted as idle and hold-off in the figure. The task starts in the idle state.
- When idle, the task immediately sends an event notification to the control task when it receives an event from an I/O card and enters the hold-off state. As an example, the figure shows the arrival of an event from I/O card 1 and its delivery to the control task. The notification sent to the control task contains a set of events that has 1 as its only element.
- The hold-off period lasts for , a configurable parameter with a 1 ms granularity. If the event management task receives no further events during the hold-off period, it returns to the idle state without carrying out any further action.

4.2. Selective I/O and Event Processing
5. System Configuration
5.1. Board Instantiation and PI Variable Mapping
- The name of the class of boards it belongs to. This name must match one of the board classes defined in the database just mentioned.
- The name of the board instance being configured, which must be unique in the whole system and is used to resolve any ambiguity among boards belonging to the same class.
- The list of Modbus addresses the board may appear at, given as an argument to the MODBUS_ADDRESSES macro. It is used during initial bus scan to determine whether all boards mentioned in the system configuration are connected and their actual address on the bus.
- A sequence of macro invocations that map a subset of the physical inputs and outputs available on the board being configured to the corresponding PI variables.

- The name of one of the physical inputs or outputs mentioned in the board database for this class of boards.
- The data type of the PI variable that corresponds to it.
- The name of the PI variable. This is an ordinary C-language identifier that the control function can use to refer to the variable.
- The name of a conversion function, to convert the variable from its device-specific representation into a format suitable for the control function (for inputs) and vice versa (for outputs).
- A pointer to additional arguments specific to the conversion functions.
5.2. Data Structure Synthesis
- It becomes possible to save memory by sharing common information. For instance, all variable descriptors pertaining to variables whose value originates from the same board point to the same board descriptor.
- Most data can be stored in read-only Flash memory, reserving RAM (that is often a precious resource in low-cost embedded systems) for the actual read-write portions of the data structure. Referring back to Figure 7, the only read-write structures—to be stored in RAM—are the dark-gray-colored ones.
- The value of PI variables, br in this case.
- Status information about them, for instance, the outcome of the last I/O operation involving them.
- Status information about boards as a whole, for instance, the actual Modbus address of a board that has more than one possible configured address.
5.3. Shared Memory Configuration
- the data type and the name of the variable,
- an indication of whether any update to the variable should trigger a sporadic event directed to the control task,
- the mirroring configuration.
5.4. Proxy Access
- 1.
- The first step determines whether or not a shared variable is accessible to proxy tasks in general. More specifically, only variables mentioned as first argument of a PROXY_VARIABLE macro invocation are made accessible.
- 2.
- The second step specifies which proxy tasks get access, and provides additional mapping and conversion information specific to each access method. Namely, the second argument of PROXY_VARIABLE is a sequence of mapping macro invocations, one for each enabled access method.

6. Internet Access
6.1. Requirements
6.2. Design and Implementation
- 1.
- The controller card and the IMS identify shared variables by means of unique values of an enumerated data type.
- 2.
- When necessary, the IMS resolves symbolic names represented as variable-length strings of characters into the corresponding enumerated values.
6.2.1. Shared Variables Enumeration
6.2.2. Symbolic Name Translation
- The hash function may lead to a hash value that is quite large. Since this value indicates the position of a symbolic name in the hash table, the table itself may use a large amount of memory space, although only a small portion of its elements are filled with real data. On the other hand, a hash function with a smaller range incurs in a higher probability of collisions, thus reducing access efficiency.
- Even though the probability may be low, a hash conflict, which arises when multiple symbolic names are associated with the same hash value, cannot be ruled out. In this case, further checks and the overhead associated with them are needed to avoid operating on the wrong variable.
6.3. Comparison with Single-Step Translation
- Firstly, the maintenance effort of the two-step approach is not significantly higher than the other. Indeed, the only requirement is that the IMS has access to a copy of the shared memory configuration files pertaining to all controller cards it is meant to communicate with, at compile time. Considering that this configuration information is determined very early in the design and development process and is unlikely to change during firmware lifetime, the maintenance effort related to those configuration files can be kept at a reasonable level.
- Furthermore, the method is bandwidth friendly because only enumerated values—represented as small, fixed-length integers in gcc—are exchanged between controller cards and the IMS, as opposed to longer, variable-length character strings. This is especially important when, to reduce system complexity and cost, a single bus is used for both remote access and real-time traffic, because it also limits the interference introduced by remote access.
7. Performance Evaluation and Analysis
7.1. Time-Driven Execution Performance
7.2. Event-Driven Reactivity
- A remote Modbus I/O card generates an event and sends an asynchronous event notification message ➀ to the controller card via a real-time bus.
- The controller card firmware reacts by activating the event handling task and then the control task ➁.
- The control task performs a selective input operation ➂, activates the control function to handle the event ➃, and performs a selective output operation ➄.

7.3. Memory Footprint
- The base modules of the framework, comprising its real-time tasks (Section 3.1) and configuration data structures (Section 5).
- The Modbus and local real-time I/O modules.
- The Modbus RTU, CAN, and TCP proxies (Section 3.3).
- The shared memory management modules, including mirroring.
- Additional utilities, mainly consisting of functions to dump framework data structures in human-readable format as a high-level debugging aid.
- The main program of the application firmware, which initializes RtFw and implements a minimal control function.
| Category | Text + RO data (B) | RW Data (B) | BSS (B) |
|---|---|---|---|
| RtFw base | 6793 | 0 | 136 |
| I/O modules | 5384 | 0 | 0 |
| Proxies | 3112 | 0 | 40 |
| Shared memory management | 868 | 0 | 56 |
| Utilities | 6879 | 0 | 0 |
| Main program | 1481 | 0 | 2272 |
| Total | 24517 | 0 | 2504 |
8. Conclusions
Funding
Data Availability Statement
Conflicts of Interest
References
- Bigler, T.; Gaderer, G.; Loschmidt, P.; Sauter, T. SmartFridge: Demand Side Management for the device level. In Proceedings of the Proc. 16th IEEE Conference on Emerging Technologies and Factory Automation (ETFA), Piscataway, NJ, Sep. 2011; pp. 1–8. [Google Scholar] [CrossRef]
- De Silva, L.C.; Morikawa, C.; Petra, I.M. State of the art of smart homes. Engineering Applications of Artificial Intelligence 2012, 25, 1313–1321, Advanced issues in Artificial Intelligence and Pattern Recognition for Intelligent Surveillance System in Smart Home Environment. [Google Scholar] [CrossRef]
- Lobaccaro, G.; Carlucci, S.; Löfström, E. A Review of Systems and Technologies for Smart Homes and Smart Grids. Energies 2016, 9. [Google Scholar] [CrossRef]
- Choudhary, G.; Jain, A.K. Internet of Things: A survey on architecture, technologies, protocols and challenges. In Proceedings of the Proc. International Conference on Recent Advances and Innovations in Engineering (ICRAIE), Piscataway, NJ, Dec. 2016; pp. 1–8. [Google Scholar] [CrossRef]
- Aouedi, O.; Vu, T.H.; Sacco, A.; Nguyen, D.C.; Piamrat, K.; Marchetto, G.; Pham, Q.V. A Survey on Intelligent Internet of Things: Applications, Security, Privacy, and Future Directions. IEEE Communications Surveys & Tutorials 2024, 1–1. [Google Scholar] [CrossRef]
- Hakiri, A.; Gokhale, A.; Yahia, S.B.; Mellouli, N. A comprehensive survey on digital twin for future networks and emerging Internet of Things industry. Computer Networks 2024, 244, 110350. [Google Scholar] [CrossRef]
- Robinsha, S.D.; Amutha, B. Transportation networks that leverage internet of things architectures: A review. AIP Conference Proceedings 2025, 3162, 020114. [Google Scholar] [CrossRef]
- Fariha, A.; Alwidian, S.; Azim, A. A Systematic Literature Review on Requirements Engineering and Maintenance for Embedded Software. IEEE Access 2024, 12, 114263–114279. [Google Scholar] [CrossRef]
- Mok, W.Y. A Conceptual Model Based Design Methodology for MongoDB Databases. In Proceedings of the 2024 7th International Conference on Information and Computer Technologies (ICICT); 2024; pp. 151–159. [Google Scholar] [CrossRef]
- Umbarkar, S.; Admane, S. Advanced Embedded Software and Systems using MBD for Electrical Grid Stability. In Proceedings of the 2025 IEEE 14th International Conference on Communication Systems and Network Technologies (CSNT); 2025; pp. 1277–1280. [Google Scholar] [CrossRef]
- Benveniste, A.; Caspi, P.; Edwards, S.A.; Halbwachs, N.; Guernic, P.L.; de Simone, R. The synchronous languages 12 years later. Proceedings of the IEEE 2003, 91, 64–83. [Google Scholar] [CrossRef]
- Chen, J.; de Mendonça, J.L.V.; Ayele, B.S.; Bekele, B.N.; Jalili, S.; Sharma, P.; Wohlfeil, N.; Zhang, Y.; Jeannin, J.B. Synchronous Programming with Refinement Types. Proc. ACM Program. Lang. 2024, 8. [Google Scholar] [CrossRef]
- Samek, M. Practical UML Statecharts in C/C++, 2nd ed.; Newnes: Oxford, UK, 2008. [Google Scholar]
- Rempillo, C.; Mustafiz, S. STL4IoT: a statechart template library for IoT system design. SIMULATION 2025, 101, 213–239. [Google Scholar] [CrossRef] [PubMed]
- Navet, N.; Fejoz, L. CPAL: High-level Abstractions for Safe Embedded Systems. In Proceedings of the Proc. of the ACM International Workshop on Domain-Specific Modeling (DSM), New York, NY, USA; 2016; pp. 35–41. [Google Scholar] [CrossRef]
- International Organization for Standardization and International Electrotechnical Commission. ISO/IEC 9899, Information Technology — Programming Languages — C, 5th ed., 2024.
- Cibrario Bertolotti, I.; Hu, T.; Navet, N. Model-based design languages: A case study. In Proceedings of the Proc. 13th IEEE International Workshop on Factory Communication Systems (WFCS), Piscataway, NJ, May 2017; pp. 1–6. [Google Scholar] [CrossRef]
- Hu, T.; Cibrario Bertolotti, I.; Navet, N. Towards Seamless Integration of N-Version Programming in Model-Based Design. In Proceedings of the Proc. 22nd IEEE International Conference on Emerging Technologies and Factory Automation (ETFA), Piscataway, NJ, Sep. 2017; pp. 1–8. [Google Scholar]
- Altmeyer, S.; André, É.; Dal Zilio, S.; Fejoz, L.; Harbour, M.G.; Graf, S.; Gutiérrez, J.J.; Henia, R.; Le Botlan, D.; Lipari, G.; et al. From FMTV to WATERS: Lessons Learned from the First Verification Challenge at ECRTS (invited). In Proceedings of the Leibniz International Proceedings in Informatics (LIPIcs); Papadopoulos, A.V., Ed., Vienne, Austria, Jul. 2023; Vol. 262, 35th Euromicro Conference on Real-Time Systems (ECRTS 2023), pp. 19:1–19:18. [CrossRef]
- Bolton, W. Programmable Logic Controllers, 6th ed.; Newnes: Oxford, UK, 2015. [Google Scholar]
- CODESYS. Industrial IEC 61131-3 PLC programming, 2018. Available online: https://www.codesys.com.
- Strasser, T.; Rooker, M.; Ebenhofer, G.; Zoitl, A.; Sunder, C.; Valentini, A.; Martel, A. Framework for Distributed Industrial Automation and Control (4DIAC). In Proceedings of the Proc. 6th IEEE International Conference on Industrial Informatics (INDIN), Piscataway, NJ, Jul. 2008; pp. 283–288. [Google Scholar] [CrossRef]
- Fu, Y.; Gui, W.; Song, H. Smart Factory Design Based on CoDeSys. In Proceedings of the 2023 6th International Conference on Information Communication and Signal Processing (ICICSP); 2023; pp. 860–865. [Google Scholar] [CrossRef]
- Pinto, G.; Nunes, A.; Silva, L.; Pinto, R.; Pinheiro, J.; Ribeiro, A. Digital Factory: An Industrial Case Study for Function Block-Oriented Development. In Proceedings of the 2023 IEEE 9th World Forum on Internet of Things (WF-IoT); 2023; pp. 01–06. [Google Scholar] [CrossRef]
- International Electrotechnical Commission. IEC 61131-3, Programmable controllers — Part 3: Programming languages, 3.0 ed., 2013.
- Arduino AG. Arduino IDE, 2018. Available online: https://www.arduino.cc.
- Ávila, B.Y.L.; Vázquez, C.A.G.; Baluja, O.P.; Alexandru, M.; Cotfas, D.T.; Cotfas, P.A.; Domínguez, L.A.Q. Protothread and Cooperative Multitasking Scheduler on the Arduino Framework. In Proceedings of the 2024 International Conference on Applied and Theoretical Electricity (ICATE); 2024; pp. 1–5. [Google Scholar] [CrossRef]
- Buonocunto, P.; Biondi, A.; Lorefice, P. Real-time multitasking in Arduino. In Proceedings of the Proc. 9th IEEE International Symposium on Industrial Embedded Systems (SIES), Piscataway, NJ, Jun. 2014; pp. 1–4. [Google Scholar] [CrossRef]
- Restuccia, F.; Pagani, M.; Mascitti, A.; Barrow, M.; Marinoni, M.; Biondi, A.; Buttazzo, G.; Kastner, R. ARTe: Providing real-time multitasking to Arduino. Journal of Systems and Software 2022, 186, 111185. [Google Scholar] [CrossRef]
- Cibrario Bertolotti, I.; Hu, T. Modular design of an open-source, networked embedded system. Computer Standards & Interfaces 2015, 37, 41–52. [Google Scholar] [CrossRef]
- Farina, M.D.O.; Pohren, D.H.; Roque, A.d.S.; Silva, A.; da Costa, J.P.J.; Fontoura, L.M.; Anjos, J.C.S.d.; Freitas, E.P.d. Hardware-Independent Embedded Firmware Architecture Framework. Journal of Internet Services and Applications 2024, 15, 14–24. [Google Scholar] [CrossRef]
- Barry, R. Using the FreeRTOS Real Time Kernel – Standard Edition, 1st ed.; Lulu Press: Raleigh, North Carolina, 2010. [Google Scholar]
- ChaN. FatFs Generic FAT File System Module, 2018. Available online: http://elm-chan.org/fsw/ff/00index_e.html.
- Dunkels, A. lwIP – A Lightweight TCP/IP stack, 2018. Available online: http://savannah.nongnu.org/projects/lwip/.
- ISO. ISO 11898-1:2024 – Road vehicles – Controller area network (CAN) – Part 1: Data link layer and physical signalling. International Organization for Standardization, 2024.
- Cibrario Bertolotti, I.; Hu, T.; Ghafour Zadeh Kashani, G. A Low-Overhead Framework for Inexpensive Embedded Control Systems. In Proceedings of the Proc. 12th International Conference on Digital Telecommunications (ICDT), Wilmington, DE, Apr. 2017; pp. 7–12. [Google Scholar]
- Thondalapally, K.R. Event-Driven Architectures: The Foundation of Modern Distributed Systems. International Journal on Science and Technology 2025, 16. [Google Scholar]
- Pontarolli, R.P.; Bigheti, J.A.; Domingues, F.O.; de Sá, L.B.; Godoy, E.P. Distributed I/O as a service: A data acquisition solution to Industry 4.0. HardwareX 2022, 12, e00355. [Google Scholar] [CrossRef] [PubMed]
- Cena, G.; Cibrario Bertolotti, I.; Hu, T.; Valenzano, A. Design, verification, and performance of a MODBUS-CAN adaptation layer. In Proceedings of the Proc. 10th IEEE International Workshop on Factory Communication Systems (WFCS), Piscataway, NJ, May 2014; pp. 1–10. [Google Scholar] [CrossRef]
- CiA. CiA 301 V4.2.0 – CANopen application layer and communication profile. CAN in Automation e.V., 2011.
- Modbus-IDA. MODBUS Messaging on TCP/IP Implementation Guide V1.0b; Modbus Organization, Inc.: Hopkinton, MA, 2006. Available online: http://www.modbus-ida.org/.
- Modbus-IDA. MODBUS over Serial Line Specification and Implementation Guide V1.02; Modbus Organization, Inc., 2006. Available online: http://www.modbus-ida.org/.
- Walter, C. FreeMODBUS - A Modbus ASCII/RTU and TCP implementation. Available online: http://freemodbus.berlios.de/.
- Embedded Solutions. Modbus Master. Available online: http://www.embedded-solutions.at/.
- Tisserant, E.; Dupin, F.; et al. Free software CANopen framework. Available online: https://canfestival.org/.
- ISO. ISO/IEC/IEEE International Standard: Telecommunications and exchange between information technology systems – Requirements for local and metropolitan area networks – Part 1Q: Bridges and bridged networks. ISO/IEC/IEEE 8802-1Q:2024(en) 2024, pp. 1–2166. [CrossRef]
- Baker, T.P.; Shaw, A. The cyclic executive model and Ada. In Proceedings of the Proc. IEEE Real-Time Systems Symposium (RTSS), Piscataway, NJ, Dec. 1988; pp. 120–129. [Google Scholar] [CrossRef]
- Caccamo, M.; Baker, T.; Burns, A.; Buttazzo, G.; Sha, L. Real-Time Scheduling for Embedded Systems. In Handbook of Networked and Embedded Control Systems; Hristu-Varsakelis, D., Levine, W.S., Eds.; Birkhäuser Boston: Cambridge, MA, 2005; pp. 173–195. [Google Scholar] [CrossRef]
- Modbus-IDA. MODBUS Application Protocol Specification V1.1b; Modbus Organization, Inc.: Hopkinton, MA, 2006; Available online: http://www.modbus-ida.org/.
- Locke, C.D. Software architecture for hard real-time applications: cyclic executives vs. fixed priority executives. Real-Time Systems 1992, 4, 37–53. [Google Scholar] [CrossRef]
- Bloom, G.; Alsulami, B.; Nwafor, E.; Cibrario Bertolotti, I. Design patterns for the industrial Internet of Things. In Proceedings of the Proc. 14th IEEE International Workshop on Factory Communication Systems (WFCS), Jun. 2018; pp. 1–10. [Google Scholar] [CrossRef]
- NXP B.V. LPC1769/68/67/66/65/64/63 Product data sheet, rev. 6, 2010. Available online: http://www.nxp.com/.
- Moxa Inc. Modular I/O product series, 2018. Available online: https://www.moxa.com/product/Modular_IO.htm.
- Chamberlain, S.; Pesch, R.; Red Hat Support.; Johnston, J. The Red Hat newlib C Library, libc 2.2.0. Red Hat Inc., 2014.
- Cibrario Bertolotti, I. RTOS Support in C-Language Toolchains. In Proceedings of the Proc. 18th IEEE International Conference on Industrial Technology (ICIT), Piscataway, NJ, Mar. 2017; pp. 1328–1333. [Google Scholar] [CrossRef]








| Operation | Delay () | ||||
|---|---|---|---|---|---|
| Min | Max | ||||
| Local Operations | |||||
| (timer task activation) | 3.46 | 0.00 | 3.46 | 3.46 | |
| (control function activation) | 18.75 | 0.06 | 18.69 | 18.89 | |
| Output Operations, 1 16-bit I/O point | |||||
| (Gathering) | 11.61 | 0.00 | 11.61 | 11.61 | |
| (Output bus transaction) | 398.58 | 0.83 | 396.81 | 400.82 | |
| (Total) | 410.19 | 0.83 | 408.42 | 412.43 | |
| Input Operations, 1 16-bit I/O point | |||||
| (Input bus transactions) | 276.96 | 1.09 | 274.80 | 279.90 | |
| (Scattering) | 3.59 | 0.00 | 3.59 | 3.59 | |
| (Total) | 280.55 | 1.09 | 278.39 | 283.49 | |
| Number of outputs | Total delay (μs) | |||
|---|---|---|---|---|
| Min | Max | |||
| 1 | 410.19 | 0.83 | 408.42 | 412.43 |
| 2 | 428.00 | 0.64 | 426.56 | 430.15 |
| 4 | 524.22 | 0.62 | 522.87 | 525.78 |
| 8 | 663.05 | 1.45 | 660.05 | 665.68 |
| Number of inputs | Total delay (μs) | |||
| Min | Max | |||
| 1 | 280.55 | 1.09 | 278.39 | 283.49 |
| 2 | 360.54 | 1.59 | 357.83 | 367.03 |
| 4 | 405.67 | 3.41 | 398.87 | 415.32 |
| 8 | 544.20 | 3.91 | 536.81 | 557.93 |
| Number of I/O points | Event to input (μs) | Event to output (μs) | ||||||
|---|---|---|---|---|---|---|---|---|
| Min | Max | Min | Max | |||||
| 1 | 315.19 | 0.67 | 313.75 | 316.77 | 709.32 | 1.15 | 706.86 | 713.53 |
| 2 | 314.12 | 0.72 | 312.72 | 315.71 | 811.35 | 2.24 | 807.33 | 818.12 |
| 4 | 316.20 | 0.65 | 314.69 | 317.74 | 953.94 | 2.73 | 948.61 | 961.69 |
| 8 | 318.46 | 1.36 | 316.69 | 322.67 | 1241.20 | 3.93 | 1232.23 | 1255.63 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).