Optimal offset calculation for cyclic CAN BUS message scheduling

Calculate optimal offset for cyclic CAN bus message scheduling
140 Downloads
Updated 19 Feb 2016

View License

The function calculates optimal (best balanced transmission queue load) transmission offset for a single CAN bus node given a vector of transmitted messages cycle times (in milliseconds) with a given time-quantum granularity (i.e. microcontroller CANBUS task periodic routine).
Please see test_canbus_msg_opt_offset.m for some examples.
The algorithm places next message at the maximum distance from the other allocated messages, within the longest contiguos sequence of time slots with lowest load.
No toolbox required.
% CANBUS_MSG_OPT_OFFSET Calculate optimal offset for cyclic CAN bus message scheduling
%
% [ Offset_ms, Load, MsgAllocation ] = canbus_msg_opt_offset( T_msg_ms, granularity_ms )
% calculates optimal (best balanced transmission queue load) transmission
% offset for a single CAN bus node given a vector of transmitted messages
% cycle times (in milliseconds) with a given time-quantum granularity
% (i.e. microcontroller CANBUS task periodic routine).
%
% INPUT
% T_msg_ms vector of message cyclic times [ms], orderered by
% increasing cycle time and decreasing priority
% granularity_ms resolution of cyclic message handler routine
%
% OUTPUT
% Offset_ms optimal time offset for message in milliseconds,
% same order as T_msg_ms
% Load size of queue at time-quantum
% MsgAllocation matrix visualizing message scheduling
% where MsgAllocation(row,col) is the message index
% as per T_msg_ms input vector transmitted at
% time-quantum "col" and at queue position "row"
%
% Based on paper:
%
% Scheduling messages with offsets on Controller
% Area Network - a major performance boost
% Mathieu Grenier1, Lionel Havet2, Nicolas Navet2
% August 9, 2008
%
% Available at: http://nicolas.navet.eu/publi/offsetsCAN_RTaW.pdf
%

Cite As

Guido Albertin (2024). Optimal offset calculation for cyclic CAN BUS message scheduling (https://www.mathworks.com/matlabcentral/fileexchange/55506-optimal-offset-calculation-for-cyclic-can-bus-message-scheduling), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0