[LIN] 2 Schedule table Description

To prevent overload, LIN processes all communications through a schedule table. Let's take a closer look at what this table does.

Related articles

1 Protocol Desciption

3 IP verification

Time base

A frame contains a header and a response, and can transmit up to 8 bytes. The time required for each frame to be transferred is determined based on a time base.

Time base 설명
Time base description

The time it takes for one frame to progress is n times the time base, and the time base is typically 5ms or 10ms. That means LIN is incredibly slow. As I explained in the previous article, the maximum communication speed is 20kbps, which is slower than the 38400 baud rate typically used as a UART.

Also, in the previous post, I mentioned that all communication is controlled via a PID. This PID is predefined via an LDF file. So, based on this LDF file, we create an API and use it to control the controller.

LIN Protocol 제어 과정 설명, LDF
Protocol Control Process Description

LDF format

So, let's see how the table file that controls communication is structured.

<LIN_description_file> ::=
	LIN_description_file ;
	<LIN_protocol_version_def>
	<LIN_language_version_def>
	<LIN_speed_def>
	(<Channel_name_def>)
	<Node_def>
	(<Node_composition_def>)
	<Signal_def>
	(<Diag_signal_def>)
	<Frame_def>
	(<Sporadic_frame_def>)
	(<Event_triggered_frame_def>)
	(<Diag_frame_def>)
	<Node_attributes_def>
	<Schedule_table_def>
	(<Signal_groups_def>)
	(<Signal_encoding_type_def>)
	(<Signal_representation_def>)

An LDF file basically consists of a protocol version, node information, signals and frames, and finally, a schedule table that describes the actual communication sequence. Let's analyze each one in detail.

Global definition

<LIN_protocol_version_def> ::=
    LIN_protocol_version = char_string ;
<LIN_language_version_def> ::=
    LIN_language_version = char_string ;
<LIN_speed_def> ::=
    LIN_speed = real_or_integer kbps ;
<Channel_name_def> ::= 
    Channel_name = identifier ;

The global definition specifies the protocol version, communication speed, and channel name.

LIN_description_file;
LIN_protocol_version = "2.2";
LIN_language_version = "2.2";
LIN_speed = 19.2 kbps;
Channel_neme = "DB";

Looking at the example above, you can see that protocol version 2.2 is being used, the communication speed is 19.2kbps (this is the commonly used communication speed), and it is named DB.

Node definition

<node_def> ::=
    Nodes {
        Master: <node_name>, <time_base> ms, <jitter> ms ;
        Slaves: <node_name>([, <node_name>]) ;
    }

Next, we define a Node, where the Master and Slaves that participate in communication are determined.

Nodes {
    Master: CEM, 5ms, 0.1ms;
    Slaves: LSM, RSM;
}

In the example above, the Master is CEM and two Slaves, LSM/RSM, are used. Since the time base is 5ms, it is expected that each frame will take 5, 10, 15, 20… ms.

<node_attributes_def> ::=
    Node_attributes {
        [<node_name> {
            LIN_protocol = <protocol_version> ;
            configured_NAD = <diag_address> ;
            (initial_NAD = <diag_address> ;)
            <attributes_def> ;
        }]
    }
    
<attributes_def> ::=
    product_id = <supplier_id>, <function_id> (, <variant>) ;
    response_error = <signal_name> ;
    (fault_state_signals = <signal_name>([, <signal_name>]) ;)
    (P2_min = real_or_interger ms ;)
    (ST_min = real_or_interger ms ;)
    (N_As_timeout = real_or_integer ms ;)
    (N_Cr_timeout = real_or_integer ms ;)
    <configurable_frames_20_def> | <configurable_frames_21_def>

Detailed information is described through the Node attribute. In particular, product_id is required for the Diagnostic frame (PID: 0x3C or 0x3D).

Node_attributes {
    RSM {
        LIN_protocol = "2.0";
        configured_NAD = 0x20;
        product_id = 0x4E4E, 0x4553, 1;
        response_error = RSMerror;
        P2_min = 150 ms;
        ST_min = 50 ms;
        configurable_frames {
            Node_Status_Event = 0x000; CEM_Frm1 = 0x0001; RSM_Frm1 = 0x0002;
            RSM_Frm2 = 0x0003;
        }
    }

Here is an example of defining Node attributes for RSM, one of the Slaves.

Signal definition

<signal_def> ::=
    Signals {
        [<signal_name>: <signal_size>, <init_value>, <published_by> 
        [, <subscribed_by>] ;]
    }

All signals used in communication are defined, and master_tx/rxare determined here. I couldn't find this and got in trouble a lot at the seminar;;

Signals {
    InternalLightsRequest: 2, 0, CEM, LSM, RSM;
    RightIntLightsSwitch: 8, 0, RSM, CEM;
    LeftIntLightsSwitch: 8, 0, LSM, CEM;
    LSMerror: 1, 0, LSM, CEM;
    RSMerror: 1, 0, RSM, CEM;
    IntTest: 2, 0, LSM, CEM;
}

The signal called InternalLightsRequest means that the CEM transfers 2 bytes of data to the LSM and RSM, so it is the master_tx signal. The RightIntLightsSwitch signal can be understood as the master_rx signal, which means that the slave RSM sends 8 bytes of data to the master CEM.

Frame definition

<frame_def> ::=
    Frames {
		[<frame_name>: <frame_id>, <published_by>, <frame_size> {
			[<signal_name>, <signal_offset> ;]
		}]
	}

The frames used in LIN communication generally include unconditional frames for transmitting and receiving data, as well as diagnostic frames for exchanging node information. All frames are defined through the LDF frame definition.

Frames {
    CEM_Frm1: 0x01, CEM, 1 {
        InternalLightsRequest, 0;
    }
    
    LSM_Frm1: 0x02, LSM, 2 {
        LeftIntLightsSwitch, 8;
    }
}

Here we get the PID, and again it tells us the frame publisher.

Schedule table

<schedule_table_def> ::=
	Schedule_tables {
		[<schedule_table_name> {
			[<command> delay <frame_time> ms ;] 
		}]
	}

Now, finally, the schedule table determines the order of frames and the time it takes to communicate.

schedule_tables {
    VL1_ST1 {
        VL1_CEM_Frm1 delay 15 ms;
        VL1_LSM_Frm1 delay 15 ms;
        VL1_CPM_Frm1 delay 15 ms;
        VL1_CPM_Frm1 delay 20 ms;
    }
}

The example above shows four frames, each with a delay of 15, 15, 15, and 20ms. But what does this delay mean? Let's look at actual communication.

Delay 설명
Delay Description

You can see that Delay refers to the time it takes for the actual frame communication, not the interval between frames. So, you can see that it is n times the 5ms time delay set earlier.

We've looked at the LDF format and examples so far. I've explained it very simply, so be sure to check the specification document!!

Related articles

1 Protocol Desciption

3 IP verification

References: LIN specification

Similar Posts