Hardware-in-the-Loop (HIL) simulation enables the integration of real hardware components with the BeamNG.tech simulation environment. This approach allows you to test and validate electronic control units (ECUs) and other hardware components in a controlled virtual environment.
HIL testing combines physical hardware components with simulated vehicle dynamics and environments. This enables comprehensive testing of:
The simulation communicates with CAN-Bus attached devices via a PEAK System PCAN USB Adapter that is controlled by PEAK’s custom DLL via FFI (Foreign Function Interface) from vlua.
The relevant code can be found in \lua\vehicle\extensions\tech\CANBus, with CANBusPeak.lua being the central interface to the CAN functionality. The other files implement module-specific features and need to be loaded in order to be used.
Important: The CANBusPeak extension does not need to be loaded manually—it’s a dependency of the other extensions and is loaded automatically.
For implementation details and code examples, see the CAN Bus interface documentation .
Purpose: Connect CAN-Bus devices to a computer and therefore the simulation. Uses USB with a provided closed-source DLL to expose its API to vlua via FFI.
Used Hardware:
Purpose: Connect individual CAN-Bus modules with each other.
4-Wire Loom:
Connectors:
Purpose: Display realtime simulation data on a real-world CAN-connected racing display/logger.
Used Hardware:
Configuration: AiM’s own software called “Race Studio 3” is used to configure the display. The software needs two configuration files:
For official documentation from AiM, see: AiM Sportline Documentation
Purpose: Display real-time CAN-Bus signals and simulation data on external displays or dashboards for monitoring and demonstration purposes.
Implementation Options:
This approach is particularly useful for demonstrations, monitoring system behavior, and providing visual feedback during HIL testing sessions.
To set up HIL testing with BeamNG.tech, you’ll need:
Software Requirements:
Hardware Requirements:
Network Configuration:
Given the unique nature of CAN setups and required software support, we do not provide pre-made support for specific CAN devices. Instead, you will need to write the supporting code in vehicle lua yourself. For an example of communication with a race car dashboard, take a look at \lua\vehicle\extensions\tech\CANBus\RacingDisplay.lua.
Was this article helpful?