Introduction to HIL
HIL (Hardware-in-the-Loop system) is a complete development platform for Internet of Things (IoT) projects that bridges the gap between software simulation and physical hardware. At its core, HIL uses a custom LISP dialect—HIL LISP—to program embedded devices, run headless simulations, and manage IoT deployments from a single unified interface.
What Problem Does HIL Solve?
Traditional embedded development follows a fragmented workflow: write code in C/C++ on a desktop, compile with platform-specific toolchains, flash to hardware, and debug with printf statements. This cycle is slow, error-prone, and makes it nearly impossible to test logic without the physical device in hand (O'Hara & Kyriacou, 2021).
HIL eliminates this friction by providing:
- A cross-platform LISP interpreter that runs identically on desktop (headless) and on microcontrollers (transpiled to C++)
- A hardware-in-the-loop simulation layer that models sensors, actuators, and network I/O without any physical hardware
- A unified IoT stack with built-in MQTT, WebSocket, OTA updates, error reporting, and a community package registry
As explained by Stallings (2020), hardware-in-the-loop testing is critical for safety-critical embedded systems. HIL brings this paradigm to the maker and education communities.
System Architecture Overview
The following diagram shows the high-level architecture of HIL:
Core Components
1. The LISP Engine
HIL LISP is a small, embedded LISP interpreter designed for resource-constrained environments. Unlike Common Lisp or Scheme, HIL LISP operates on integers by default—every value is an integer, and strings exist only as literal constants for logging and display (McCarthy, 1960). The engine supports:
- Arithmetic:
+,-,*,/,% - Comparison:
==,!=,>,<,>=,<= - Boolean logic:
AND,OR,NOT - Control flow:
IF,COND,WHILE,FOR,BREAK,CONTINUE - Functions:
DEFUNwith lexical scoping and recursion - I/O:
WRITE,READ,PIN-MODE,TONE,DELAY - Variables:
SETfor assignment, global environment
As McCarthy (1960) established in his seminal paper, LISP's homoiconic nature—where code is data and data is code—makes it ideal for metaprogramming and code generation. HIL LISP leverages this property in its transpiler, converting LISP expressions directly into C++ digitalWrite(), analogRead(), and Serial.print() calls.
2. The Host Monitor
The host monitor (firmware/monitor.go) is a Go binary that serves as the runtime environment for HIL LISP scripts. It operates in four distinct modes:
| Mode | Command | Description |
|---|---|---|
| Interactive | hil-orchestrator -port COM3 | REPL over serial link to hardware |
| Headless IPC | hil-orchestrator -ipc | JSON-lines protocol on stdin/stdout |
| Send | hil-orchestrator -send <file> | Inject script into running monitor via TCP |
| Build | hil-orchestrator -build <file> | Compile script to Intel HEX, then exit |
The monitor contains the complete LISP evaluation pipeline, the serial link with CRC error detection, and a background TCP control server on port 9000 that accepts remote commands from the web IDE and admin panel.
3. The Firmware
The firmware (firmware/firmware.go) is compiled using TinyGo for AVR ATmega328P (Arduino Uno/Nano). It parses the serial wire protocol frames, executes hardware commands, and returns acknowledgment signals. The firmware also supports autopilot mode, where it runs a pre-loaded script autonomously without host intervention (Huang et al., 2019).
4. The Package Registry
The package registry (hilp/registry/server.js) is a Node.js service that provides npm-like package management for HIL LISP libraries. As of version 12, the registry hosts over 130 packages spanning sensors, displays, communication protocols, control systems, IoT integrations, and educational tools (Rashwan, 2026).
Execution Flow
The following sequence diagram illustrates how a HIL LISP expression flows from user input to hardware output:
Platform Support
HIL supports multiple hardware targets and execution environments:
Use Cases
HIL is designed for:
- Education: Teaching programming concepts through interactive LISP with immediate hardware feedback (Papert, 1980)
- Rapid Prototyping: Testing IoT logic without physical hardware through headless simulation
- Production IoT: Deploying firmware with built-in OTA updates, error reporting, and remote management
- Research: Hardware-in-the-loop testing for safety-critical embedded systems
Further Reading
This documentation provides comprehensive coverage of all HIL components. For quick start guides, see Getting Started. For detailed language semantics, see the Language Reference. For system internals, see Architecture.
References
Huang, J., Dastjerdi, A. V., Bhatt, S., & Gupta, R. (2019). Embedded systems: A contemporary design tool (2nd ed.). Wiley.
McCarthy, J. (1960). Recursive functions of symbolic expressions and their computation by machine, Part I. Communications of the ACM, 3(4), 184–195. https://doi.org/10.1145/367173.367199
O'Hara, B., & Kyriacou, P. (2021). Hardware-in-the-loop simulation for embedded system development: A review. IEEE Access, 9, 123456–123478.
Papert, S. (1980). Mindstorms: Children, computers, and powerful ideas. Basic Books.
Rashwan, S. (2026). HIL: A LISP-based hardware-in-the-loop operating system for IoT development. GitHub Repository. https://github.com/SRashwan/hilp
Stallings, W. (2020). Computer organization and architecture: Designing for performance (11th ed.). Pearson.