CAN Message Design
Define CAN identifiers, signals, scaling, offsets, bit allocation, byte order and message update rates.
CAN BUS · MATLAB · SIMULINK · DBC · SIL · DIAGNOSTICS
Designing, validating and fault-testing a multi-ECU motorsport CAN network using a DBC-defined Software-in-the-Loop architecture.
EXECUTIVE SUMMARY
This project develops a motorsport CAN communication architecture from first principles. A communication matrix and DBC database define the signals before the network is implemented within MATLAB and Simulink, expanded across four virtual ECUs and subjected to controlled communication and signal faults.
The objective was not simply to demonstrate CAN message transmission, but to investigate the complete engineering chain from physical vehicle signals to raw CAN data, network timing, signal reconstruction and vehicle-level diagnostic behaviour.
ENGINEERING QUESTION
The investigation considers both normal CAN communication and faulted operation, exploring how engineering signals are encoded, transmitted, reconstructed and monitored for communication or plausibility failures.
01
DEVELOPMENT WORKFLOW
Define CAN identifiers, signals, scaling, offsets, bit allocation, byte order and message update rates.
Validate DBC-based signal encoding and decoding using MATLAB and Simulink.
Combine four virtual ECUs operating at multiple update frequencies into one vehicle architecture.
Inject controlled CAN and signal faults, detect abnormal behaviour and classify diagnostic states.
02
STAGE 1 · CAN MESSAGE DESIGN
Development began with a communication matrix defining the structure of the vehicle network. Each engineering signal was assigned a CAN identifier, start bit, bit length, data type, scaling factor, offset, physical range and byte order.
These definitions were then transferred into a common DBC database, providing a single definition of the communication architecture for both transmitting and receiving systems.
COMMUNICATION MATRIX
| ECU | MESSAGE | CAN ID | SIGNALS | RATE | PERIOD |
|---|---|---|---|---|---|
| Engine ECU | ENGINE_DATA | 0x100 | 3 | 100 Hz | 10 ms |
| Brake ECU | BRAKE_DATA | 0x200 | 2 | 100 Hz | 10 ms |
| Chassis ECU | WHEEL_SPEEDS | 0x300 | 4 | 200 Hz | 5 ms |
| Steering Wheel ECU | DRIVER_INPUTS | 0x400 | 4 | 50 Hz | 20 ms |
MATLAB VALIDATION
Before progressing to the Simulink network, the ENGINE_DATA definition was independently validated in MATLAB using known engineering inputs. Physical values were manually converted to their raw CAN representation, assembled into an 8-byte payload and decoded through the DBC.
TEST CASE
Three representative engine signals were selected to test scaling, offset handling, byte allocation and DBC decoding before the same database was used within the wider CAN network.
Expected 8-byte CAN payload
% Define known engineering values
expectedEngineSpeed = 10000; % rpm
expectedThrottle = 80; % %
expectedCoolant = 95; % degC
% Convert physical values to raw CAN values
% Raw = (Physical - Offset) / Factor
rawEngine = expectedEngineSpeed / 0.25;
rawThrottle = expectedThrottle / 0.4;
rawCoolant = (expectedCoolant - (-40)) / 1;
% Construct expected 8-byte CAN payload
payload = uint8([ ...
hex2dec('40'), hex2dec('9C'), ...
hex2dec('C8'), hex2dec('87'), ...
0, 0, 0, 0]);
msg.Data = payload;
% Decode using DBC signal definitions
decodedEngineSpeed = msg.Signals.EngineSpeed;
decodedThrottle = msg.Signals.ThrottlePosition;
decodedCoolant = msg.Signals.CoolantTemperature;
% Automated validation
tolerance = 1e-6;
enginePass = ...
abs(decodedEngineSpeed - expectedEngineSpeed) < tolerance;
throttlePass = ...
abs(decodedThrottle - expectedThrottle) < tolerance;
coolantPass = ...
abs(decodedCoolant - expectedCoolant) < tolerance;
% Overall validation result
if enginePass && throttlePass && coolantPass
fprintf("OVERALL DBC VALIDATION: PASS\n");
else
fprintf("OVERALL DBC VALIDATION: FAIL\n");
end
03
STAGE 2 · SIMULINK VIRTUAL CAN NETWORK
A Software-in-the-Loop model was developed using CAN Pack and CAN Unpack blocks. Known vehicle signals were encoded using the common DBC definition and then reconstructed at the receiving side.
SIGNAL TIMING
Dynamic signal testing highlighted two independent sources of discretisation within the communication system.
Determined by the scaling resolution specified within the DBC definition.
Determined by the update frequency of the transmitting ECU.
04
STAGE 3 · MULTI-ECU NETWORK
The validated Engine ECU methodology was extended to the Brake, Chassis and Steering Wheel ECUs.
Each virtual ECU operates independently at its assigned update frequency while using the same DBC-defined communication architecture.
INTEGRATED ARCHITECTURE
The integrated model allows all four message groups to operate simultaneously while retaining their independent signal behaviour and specified update periods.
05
STAGE 4 · FAULT INJECTION & DIAGNOSTICS
Once the known-good network had been validated, controlled faults were introduced to investigate how configuration errors, communication loss and implausible signal behaviour affect the receiving system.
Investigated how an incorrect DBC scaling definition can produce an incorrect engineering value while the underlying CAN payload remains valid.
Demonstrated how incorrect byte-order interpretation can reconstruct valid raw data into unrealistic engineering values.
Deliberately interrupted WHEEL_SPEEDS transmission and detected the communication loss using persistence-based monitoring.
Injected an implausible wheel-speed value into an otherwise valid CAN message and detected the failure using cross-signal plausibility.
COMMUNICATION DIAGNOSTICS
WHEEL_SPEEDS operates at 200 Hz, corresponding to a nominal message period of 5 ms.
Transmission was deliberately disabled to reproduce a communication loss. A consecutive missing-message counter monitored the persistence of the failure.
Once the persistence criterion was exceeded, the WHEEL_SPEED_CAN_TIMEOUT diagnostic was asserted. Restoring transmission reset the counter and cleared the diagnostic state.
SIGNAL PLAUSIBILITY
Communication monitoring alone cannot identify every CAN-related failure. A message may remain structurally valid while containing an incorrect engineering value.
Between 4 s and 6 s, the front-left wheel speed was deliberately corrupted to 300 km/h while the remaining three wheel-speed channels continued to follow their nominal profiles.
A reference vehicle speed was estimated using the remaining three wheel-speed measurements.
The absolute residual was compared against the selected plausibility threshold, allowing the corrupted wheel-speed signal to be identified even though the CAN message continued to transmit correctly.
DIAGNOSTIC WORKFLOW
CENTRALISED DIAGNOSTIC MANAGER
The CAN timeout and wheel-speed plausibility diagnostics were consolidated within a central diagnostic manager.
A Boolean FaultActive output identifies whether any monitored condition is present, while a numerical FaultCode distinguishes between the individual and combined fault states.
INTEGRATED VALIDATION
The final validation combined the communication timeout and signal plausibility diagnostics within a central diagnostic manager. Each condition was assigned a numerical contribution, allowing individual and simultaneous faults to be distinguished using a single FaultCode output.
The plausibility and timeout diagnostics were combined into a single numerical output, allowing the diagnostic manager to distinguish between healthy operation, individual faults and simultaneous fault conditions.
FaultCode = PlausibilityFault + 2 × CANTimeout
The integrated validation successfully distinguished healthy operation, an isolated plausibility fault, an isolated CAN timeout and a simultaneous combined fault. Each condition produced the expected FaultCode, confirming correct diagnostic classification across all four test states.
No diagnostic fault active.
Wheel-speed plausibility fault.
Wheel-speed CAN communication timeout.
Plausibility and timeout faults active.
MODEL SCOPE
The project validates logical CAN communication, DBC-defined encoding and decoding, ECU organisation, multi-rate timing and diagnostic behaviour.
The current model does not represent the electrical CAN physical layer, differential CAN High/CAN Low signalling, physical termination, propagation delay, physical bus loading, shared-bus arbitration or hardware transmission and reception.
KEY TAKEAWAYS
Designed a DBC-defined motorsport CAN architecture from a communication matrix.
Validated signal packing, decoding, scaling, quantisation and multi-rate ECU timing.
Integrated four virtual ECUs and 13 engineering signals into a central Vehicle Data Logger.
Implemented controlled fault injection, timeout detection, plausibility monitoring and centralised diagnostic classification.
SOURCE CODE
MATLAB validation scripts, CAN definitions and supporting project files are available within the project repository.