# CarTwin--Development of a Digital Twin for a Real-World In-Vehicle CAN Network
## 4 System Level Implementation Based on Simulink Models
Otherwise, the rear camera is turned off. 7. **Remote Function Actuator (RFA):** In Figure 11, we show the Simulink model for the calculation of door status based on a signal acquired from a button. If the door lock button is continuously pressed and the door is unlocked, after 1 s, the door status is updated to locked. If the door is locked, the status is updated to unlocked after another second. Some of these signals were encoded into 15 bits. We extend them to 16 bits in order to use 2 bytes from the data field for easing data manipulation in software. A detailed description of all signals used and their need is elaborated upon in what follows next. In order to transmit the input data required by the Simulink models, we have developed a tool in C# that incorporates the XL Driver Library from Vector ([[https://www.vector.com/int/en/products/products-a-z/libraries-drivers/xl-driver-library/](https://www.vector.com/int/en/products/products-a-z/libraries-drivers/xl-driver-library/)]([https://www.vector.com/int/en/products/products-a-z/libraries-drivers/xl-driver-library/](https://www.vector.com/int/en/products/products-a-z/libraries-drivers/xl-driver-library/)), accessed on 26 November 2022). This library allows a CAN frame transmission on the vehicle bus using the Vector hardware device and parses the frame content for all received frames. Using a configurable micro-second level timer, CAN frames are transmitted periodically from the tool using the USB device from Vector with CAN Interface, i.e., VN5610. Our tool allows the user to initialize the communication with the Vector device, select specific values for the CAN signals from combo-boxes (default values are already set at tool startup), which are transmitted on CAN based on the mapping of real values to CAN raw data bytes. Transmission can be started or stopped at any time. The signals transmitted from the C# tool together with their bit size are shown in the first part of Table 1 and are as follows: vehicle speed target, vehicle direction to specify if the vehicle is driven straight or in reverse, brake status to command the brake, steering wheel angle to compute the vehicle steering and buckle status for airbag control and audible alert for the driver. The tool allows the user to see real-time CAN frames, i.e., labeled as \"Received frames\", as well as the relevant signal interpretation, e.g., \"Vehicle Speed\", \"Gear\" or \"Trip distance\". The user interface for the C#-based tool is depicted in Figure 3:4  
As models of legitimate ECUs, we employed seven development boards with software applications that transmit model outputs as signals in CAN frames on the real vehicle bus. The boards are Infineon TC275 like kits with USB support for the PC. They embed an AURIX  
Figure 3:5 User interface for the transmission and visualization of CAN signals. TC275 microcontroller together with a TLE9251 VSJ CAN Transceiver and include a CAN connector interface with a 120\(\Omega\) resistor between CANH and CANL. The AURIX TC275 controller has three cores running at 200 MHz, 4 MB of Flash memory and 472 KB of SRAM. Furthermore, according to information from its datasheet, this microcontroller variant is designed to be used in various automotive safety applications, such as braking control units, airbag control units, powertrain control units and electric power steering control units. One of the AURIX TC275 like kits used in our experiments is shown in Figure 13i. For transmission and reception of messages from the CAN bus, we configured P20.8 and P20.7 pin as CAN TX and CAN RX since they are already connected via PCB traces to the existing CAN transceiver on the evaluation kits. We configured P20.6 pin as an output with LOW state to enable the normal operation of the CAN transceiver since this pin is connected to the standby input of the transceiver. In order to preserve the required CAN bus impedance, we kept the 120 \(\Omega\) resistor only on the boards that are terminal nodes, i.e., the first and the last, and removed the resistors from the other five boards.