Home Learning Paths ECU Lab Assessments Interview Preparation Arena Pricing Log In Sign Up

STIM Purpose: Driving ECU Input Variables

STIM (Stimulation) is the inverse of DAQ. Instead of the ECU sending data to the tool, the tool sends data to the ECU — writing values to specific ECU RAM variables at a configured event rate. This enables a bypass architecture where a Simulink model on the PC drives an ECU algorithm input, replacing what the ECU would normally compute.

STIM Bypass Architecture
  Normal operation:
  ECU computes: torque_demand = f(throttle, rpm, temp)
  ECU writes:   torque_demand → actuator

  STIM bypass mode:
  Simulink model on PC: torque_demand_model = StimulusFunction(inputs)
  Tool sends STIM packet → XCP writes → torque_demand_stim (ECU RAM)
  ECU reads torque_demand_stim instead of its own computed value
  (controlled by bypass_flag MEASUREMENT variable)

  Benefits:
  - Test new algorithm on real ECU before code integration
  - Validate plant model accuracy against real hardware response
  - Rapid algorithm iteration without ECU reflash

💡 STIM vs DOWNLOAD

STIM writes ECU RAM variables at a real-time rate (synchronised to an ECU event channel, e.g., every 10ms). DOWNLOAD is a one-shot write used for calibration parameters. Use STIM when the PC model must continuously update an ECU variable at the task cycle rate; use DOWNLOAD for static parameter changes.

STIM List Configuration

STIM ConfigurationDescriptionExample
STIM listSame structure as DAQ list — named group of ECU RAM addresses to receive data from toolstim_torque_bypass: torque_demand_stim at 0x20004B00
Event channelECU task that reads STIM data — must match the task that reads the bypass variableevent_10ms: reads torque_demand_stim every 10ms
STIM packet sizeSum of all stimulated variable sizes per ODT (must fit in MAX_DTO)8 bytes = 2 × float32 (8 bytes on CAN) or more on ETH
STIM rateDriven by tool's model execution rate — must match event channel period10ms model → event_10ms
A2Lstim_config.a2l
/begin IF_DATA XCP
  /begin STIM
    STIM_EVENT 0x00        /* event_10ms channel number */
    STIM_TIMESTAMP_UNIT TIMESTAMP_UNIT_1MS
  /end STIM
/end IF_DATA

/* The stimulated variable — declared as MEASUREMENT (readable AND stimulatable) */
/begin MEASUREMENT
  torque_demand_stim
  "PC model torque demand for bypass"
  FLOAT32_IEEE
  CM_NM
  1
  0.001
  -500.0
  500.0
  ECU_ADDRESS 0x20004B00
/end MEASUREMENT

Bypass Pattern in ECU Code

Cbypass_implementation.c
/* ECU bypass flag: calibration tool sets this CHARACTERISTIC to 1 */
volatile uint8 bypass_torque_active = 0u;  /* CHARACTERISTIC VALUE */

/* Stimulated value: STIM writes this every 10ms */
volatile float32 torque_demand_stim = 0.0f; /* MEASUREMENT (also STIM target) */

/* Normal computed value */
static float32 torque_demand_computed = 0.0f;

/* Torque demand selection function - called every 10ms */
float32 Get_TorqueDemand(void)
{
    if (bypass_torque_active != 0u) {
        /* STIM mode: use PC model value (written by XCP STIM) */
        return torque_demand_stim;
    } else {
        /* Normal mode: use ECU algorithm result */
        torque_demand_computed = Compute_TorqueDemand();
        return torque_demand_computed;
    }
}

STIM Latency Budget

Latency ComponentXCP/CAN at 500 kbpsXCP/ETH UDPImplication
PC model execution0.5–2 ms0.5–2 msSame regardless of transport
USB/PCIe to CAN/ETH adapter0.1–0.5 ms0.05 msETH lower jitter
CAN frame transmission0.128 msN/ACAN adds fixed delay
ECU XCP receive handler0.05–0.1 ms0.05 msMinimal
ECU task reads STIM variable0–10 ms0–10 msUp to one full task cycle jitter
Total worst case (CAN)~13 ms~3 msOnly ETH usable for <5ms loops

⚠️ CAN STIM Not Suitable for Fast Loops

XCP/CAN STIM has worst-case latency of 10–15ms. For algorithms with 10ms or shorter control loops, this latency is larger than the control period — the bypass signal arrives stale and the control loop becomes unstable. Use XCP/ETH for STIM-based bypass of any algorithm with a period <20ms. XCP/CAN STIM is only suitable for slow algorithms (>=50ms cycle time).

Summary

STIM enables PC-model bypass on a live ECU without code changes, using only an A2L bypass flag CHARACTERISTIC and a STIM-target MEASUREMENT variable. The bypass_flag pattern is the standard AUTOSAR-compatible implementation. Latency budget analysis is critical: XCP/ETH is mandatory for any control loop faster than 20ms; XCP/CAN STIM is only suitable for slow algorithms.

🔬 Deep Dive — Core Concepts Expanded

This section builds on the foundational concepts covered above with additional technical depth, edge cases, and configuration nuances that separate competent engineers from experts. When working on production ECU projects, the details covered here are the ones most commonly responsible for integration delays and late-phase defects.

Key principles to reinforce:

  • Configuration over coding: In AUTOSAR and automotive middleware environments, correctness is largely determined by ARXML configuration, not application code. A correctly implemented algorithm can produce wrong results due to a single misconfigured parameter.
  • Traceability as a first-class concern: Every configuration decision should be traceable to a requirement, safety goal, or architecture decision. Undocumented configuration choices are a common source of regression defects when ECUs are updated.
  • Cross-module dependencies: In tightly integrated automotive software stacks, changing one module's configuration often requires corresponding updates in dependent modules. Always perform a dependency impact analysis before submitting configuration changes.

🏭 How This Topic Appears in Production Projects

  • Project integration phase: The concepts covered in this lesson are most commonly encountered during ECU integration testing — when multiple software components from different teams are combined for the first time. Issues that were invisible in unit tests frequently surface at this stage.
  • Supplier/OEM interface: This is a topic that frequently appears in technical discussions between Tier-1 ECU suppliers and OEM system integrators. Engineers who can speak fluently about these details earn credibility and are often brought into critical design review meetings.
  • Automotive tool ecosystem: Vector CANoe/CANalyzer, dSPACE tools, and ETAS INCA are the standard tools used to validate and measure the correct behaviour of the systems described in this lesson. Familiarity with these tools alongside the conceptual knowledge dramatically accelerates debugging in real projects.

⚠️ Common Mistakes and How to Avoid Them

  1. Assuming default configuration is correct: Automotive software tools ship with default configurations that are designed to compile and link, not to meet project-specific requirements. Every configuration parameter needs to be consciously set. 'It compiled' is not the same as 'it is correctly configured'.
  2. Skipping documentation of configuration rationale: In a 3-year ECU project with team turnover, undocumented configuration choices become tribal knowledge that disappears when engineers leave. Document why a parameter is set to a specific value, not just what it is set to.
  3. Testing only the happy path: Automotive ECUs must behave correctly under fault conditions, voltage variations, and communication errors. Always test the error handling paths as rigorously as the nominal operation. Many production escapes originate in untested error branches.
  4. Version mismatches between teams: In a multi-team project, the BSW team, SWC team, and system integration team may use different versions of the same ARXML file. Version management of all ARXML files in a shared repository is mandatory, not optional.

📊 Industry Note

Engineers who master both the theoretical concepts and the practical toolchain skills covered in this course are among the most sought-after professionals in the automotive software industry. The combination of AUTOSAR standards knowledge, safety engineering understanding, and hands-on configuration experience commands premium salaries at OEMs and Tier-1 suppliers globally.

← PreviousDAQ (Data Acquisition) ModeNext →Page Switching & Calibration Concepts