LIN Basics For Beginners en
LIN Basics For Beginners en
Slide-1 11.05.2022
LIN-Basics
LIN
Master Slave1
Slide-2 30.03.2022
LIN Single Wire Hardware
LIN
Master Slave1
Slide-3 30.03.2022
LIN-bus dominant / recessive states
A LIN bus with one master and 3 slaves can be reduced to the
simplified circuit diagram shown on the left.
As soon as one of the nodes activates its output switch, the bus
12V board supply will have a low level, only if all output switches are open, the bus
will be pulled up to its high level.
Since a single node is sufficient to determine the low level by
closing its switch, this is called the dominant level.
LIN bus
Accordingly, the High level, for which all nodes must have their
switches open, is called recessive level.
All pull-up resistors are connected in parallel, so the effective
Ground
pull-up resistance value corresponds to the parallel connection of
all pull-up resistors.
Slide-4 30.03.2022
LIN-Bus Signal Flanken
Slide-5 30.03.2022
LIN Bus Hardware
LIN node
Most LIN nodes contain the following 2 components:
Node specific
➢ Mikrocontroller with integrated UART
hardware
➢ LIN-Transceiver
The UART converts data bytes into asynchronous serial patterns for Microcontroller
transmission and decodes data bytes from the received serial data
stream.
UART
It also generates break and wake-up signal patterns; this can either
be implemented by special LIN functions of the UART or must be 3V/5V
implemented by sending a binary 0x0 at a different baud rate or by
TXD RXD Enable
bit-banging the TXD port under timer control.
The LIN transceiver translates the logic levels of the microcontroller LIN Tranceiver
(typ. 3...5V) into the LIN voltage range (8...18V) and converts the full- LIN
duplex RXD/TXD interface into a 1-wire half-duplex interface.
8...18V
LIN bus
Baby-LIN systems
(Generation 2) use a
NXP MC33662
LIN Transceiver
Slide-6 30.03.2022
LIN Bus Hardware
UART
LIN signal trace with slope control:
3V/5V
LIN Tranceiver
LIN
8...18V
LIN bus
Slide-7 30.03.2022
LIN-bus communication primitives
Slide-8 30.03.2022
LIN Frame Bestandteile
Frame Header:
➢ Break field Indicates the beginning of a new frame, at least 13 bit times long, in
order to be able to distinguish it reliably from all other characters
➢ Sync field Allows the resynchronization of slave nodes with imprecise clock sources
by measuring the bit times and reconfiguring the UART baud rate. Sync
field is always sent by the master.
➢ Protected Identifier A character with the frame ID. The 8-bit character contains 2 parity bits to
protect the identifier, resulting in a total frame id range of 0...63.
Data Section
➢ Data1…Data N 1...8 Data bytes which contain the information that will be transmitted.
➢ Checksum byte Contains the inverted 8 bit sum with Carry handling over all data bytes
(Classic checksum) or over data bytes and Protected Id (Enhanced checksum)
LIN V.1.x => Classic Checksum
LIN V.2.x => Enhanced Checksum
Slide-9 30.03.2022
LIN frame security - Protected Id
Protected Id
The frame ID identifies the frame. It is 8 bits in size,
but 2 bits are used as parity bits, leaving only 6 bits
for frame identification. Thus there are only 64 different frames on a LIN bus.
Id dec Id hex PID Id dec Id Hex PID Id dec Id hex PID Id dec Id hex PID
C-sample code:
uint8_t checksum_calc (uint8_t ProtectedId, uint8_t * pdata, uint8_t
len, uint8_t mode){
uint16_t tmp;
uint8_t i;
if (mode == CLASSIC)
tmp = 0; The 8 bit sum with overflow treatment
corresponds to the summation of all
else
tmp = ProtectedId; values, with 255 being subtracted each
for (i = 0; i < len; i++)
{
time the sum >= 256.
tmp += *pdata++;
if (tmp >= 256)
tmp -= 255;
}
Master Slave1
Slide-12 30.03.2022
LIN frame transmission / reception
Master Slave1
Of course, there are also frames that transfer data from the master
to a slave, e.g. to transmit a command to a slave. In these cases the
master is defined as publisher for this frame.
Here the master sends the frame header and the data section.
Slave2
The master cannot recognize whether the addressed slave has
received the frame or not.
Therefore, there is no confirmation mechanism for the LIN frame
transmission, which can be found, for example, on the CAN bus.
Of course, the whole concept only works if every node
(Master/Slave) connected to the bus knows whether it is the publisher LIN
for a certain frame (=ID) or not. Slave3
Slide-13 30.03.2022
LIN description file LDF
LIN_description_file ;
LIN_protocol_version = "1.3" ;
LIN_language_version = "1.3" ;
LIN_speed = 19.200 kbps ;
Nodes {
Master: MasterECU,1.0000 ms,0.1000 ms ;
Slaves: Slave1Motor,Slave2Sensor;
LDF header }
Slide-15 30.03.2022
Sample LDF file
Frames {
MasterCmd: 0x10, MasterECU, 4
{ MessageCounter, 0;
Ignition, 8;
WiperSpeed, 9;
Temperature,16; }
MotorFrame: 0x20, Slave1Motor, 4
{WiperActive, 0;
ParkPosition,1;
CycleCounter,16; }
Frame section SensorFrame: 0x30, Slave2Sensor, 2
{StatusSensor, 0;
ValueSensor, 8; }
Schedule table }
Schedule_tables {
Signal encoding section Table1 { MasterCmd delay 20.0000 ms ;
MotorFrame delay 20.0000 ms ;
SensorFrame delay 20.0000 ms ;}
Encoding to signal mapping }
Signal_encoding_types {
EncodingSpeed { logical_value, 0, "Off" ;
logical_value, 1, "Speed1" ;
logical_value, 2, "Speed2" ;
logical_value, 3,“ Interval" ;}
EncodingTemp { physical_value, 0, 253, 0.8, -35, "degrees C" ;
logical_value, 254, "Signal not supported" ;
logical_value, 255, "Signal has error" ;}
}
Signal_representation {
EncodingSpeed: WiperSpeed;
EncodingTemp: Temperature;
}
Slide-16 30.03.2022
LIN application frames
LDF definition:
MasterECU = master
Slave1Motor = slave (wiper motor) Frame with ID 0x20 has 4 data bytes
Frame with ID 0x10 has 4 data bytes Publisher = Slave1Motor Frame with ID 0x30 has 2 data
Publisher = MasterECU (master) Databyte1.bit 0 wiper active bytes
Databyte1.bit 0...7 message counter Databyte1.bit 1 park position Publisher = Slave2Sensor
Databyte2.bit 0 IgnitionOn (Klemme15) Databyte2.bit 0...7 CycleCounter LSB Databyte1 Sensor Status
Databyte2.bit 1...3 wiper speed Databyte3.bit 0...7 CycleCounter MSB Databyte2 ValueSensor
Break Sync Identifier Databyte1 Databyte2 Databyte3 Databyte4 CheckSum Break Sync Identifier Databyte1 Databyte2 Databyte3 Databyte4 CheckSum Break Sync Identifier Databyte1 Databyte2 CheckSum
With the information from an LDF, you can assign all frames that
appear on the bus to your publisher using the PID.
You can also interpret the data regarding the signals it contains…
Slide-17 30.03.2022
LIN application frames
LDF definition:
MasterECU = master
Slave1Motor = slave (wiper motor)
Frame with ID 0x20 has 4 data bytes
Frame with ID 0x10 has 4 data bytes Publisher = Slave1Motor Frame with ID 0x30 has 2 data
Publisher = MasterECU (master)
Databyte1.bit 0 wiper active bytes
Databyte1.bit 0...7 message counter Databyte1.bit 1 park position Publisher = Slave2Sensor
Databyte2.bit 0 IgnitionOn (Klemme15) Databyte2.bit 0...7 CycleCounter LSB Databyte1 Sensor Status
Databyte2.bit 1...3 wiper speed Databyte3.bit 0...7 CycleCounter MSB Databyte2 ValueSensor
Break Sync Identifier Databyte1 Databyte2 Databyte3 Databyte4 CheckSum Break Sync Identifier Databyte1 Databyte2 Databyte3 Databyte4 CheckSum Break Sync Identifier Databyte1 Databyte2 CheckSum
With the information from an LDF, you can assign all frames that
appear on the bus to your publisher using the PID.
You can also interpret the data regarding the signals it contains…
Slide-18 30.03.2022
LIN Scheduling
Schedule_tables {
The order in which the frames are sent to the LIN bus
Table1 {MasterCmd delay 20.0000 ms ;
is defined in a so-called Schedule Table. One or MotorFrame delay 20.0000 ms ;
more Schedule Table(s) are defined in each LDF. SensorFrame delay 20.0000 ms ;}
SensorFast {MasterCmd delay 10.0000 ms ;
Each table entry describes a frame by its LDF name SensorFrame delay 10.0000 ms ;
and a delay time, which is the time that is made MotorFrame delay 10.0000 ms ;
SensorFrame delay 10.0000 ms ;}
available to the frame on the bus. MotorFast {MotorFrame delay 10.0000 ms ;}
A Schedule Table is always selected as active }
Slide-19 30.03.2022
LIN Frame Typen
In der Beispiel LDF haben wir die Unconditional Frames gesehen. Diese haben genau einen Publisher und
erscheinen dann auf dem Bus, wenn sie gemäß dem aktuell laufenden Schedule wieder dran sind.
Unconditional frame (UCF) The data always comes from the same node (Publisher) and are transmitted with a
constant time grid (Deterministic timing).
Event triggered frame (ETF) A kind of alias FrameId, which combines several Slave UCF's to an own FrameId.
If there is such an ETF in the schedule, only one node with changed data will put it
on the bus. This saves bandwidth - but with the disadvantage of possible collisions.
Due to the collision resolution, the bus timing is no longer deterministic.
Sporadic frames (SF) This is actually more a schedule entry type than a frame type, because this SF
combines several UCF's, which all have the master as publisher, in one schedule
entry. The master then decides which frame to actually send, depending on which
frame has new data
Diagnostic frames A pair of MasterRequest (0x3C) and SlaveResponse (0x3D) frames. Used to send
information that is not described in the LDF. No static signal mapping as with UCF,
ETF and SF.
Slide-20 30.03.2022
Frame type Event triggered Frame
Master LIN
ETF's were introduced to save bus bandwidth. Slave1
Example: 4 slave nodes in the doors detect the states of PID DB0 DB1
ETF 50 11 status
Each node has a frame definition (unconditional UCF) to publish its key
state, and it also has a second event triggered frame definition (ETF) to Slave2
publish the same frame data via another FrameId. PID DB0 DB1
With UCF, the slave always sends the data. UCF 92 92 status
With ETF, the slave only sends data if there is changed data. ETF 50 92 status
In addition, the slave places the PID of the associated UCF in the first data Slave3
byte. PID DB0 DB1
UCF / ETF have identical signal mappings, whereby in both frames the UCF D3 D3 status
first byte is not occupied with a signal, but is always filled with the PID of ETF 50 D3 status
Via UCF frames, always works, but needs 4 frames. UCF 14 14 status
ETF 50 14 status
same ETF.
The master recognizes such a collision 1 Answer
by an invalid checksum.
In Lin 1.3/2.0 collision resolution
Collision
without own collision table is defined.
Here the master will now fill the running
schedule, the ETF slot, with the UTF ID's
one after the other until it has queried
Switching
all publishers possible for this ETF. to UCF
frames in
After that the master uses the ETF in this
ETF slot
schedule slot again.
Slide-22 30.03.2022
Frame type Event triggered Frame
Slide-23 30.03.2022
Frame type Event triggered Frame
Slide-24 30.03.2022
Frame type sporadic Frames
A sporadic frame group shares the same frame slot. When it is ready
for transmission, it first checks whether there has been a signal
update. This results in 3 scenarios:
The prioritisation of the frames results from the order in which the frames are
defined in the LDF.
Slide-25 30.03.2022
LIN diagnostic frames 0x3C/0x3D
Break Sync Identifier Databyte1 Databyte2 Databyte3 Databyte4 Databyte5 Databyte6 Databyte7 Databyte8 CheckSum
ID=0x3C ID=0x3D
MasterRequest SlaveResponse
Slide-26 30.03.2022
LIN Protokolle mit Diagnoseframes
The MasterRequest - SlaveResponse mechanism can be used to transmit a wide variety of data
because it is a universal transport mechanism.
A main application is the diagnosis and End of Line (EOL) configuration of nodes.
In the field there is a whole range of different protocols, depending on the vehicle and ECU
manufacturer.
• A lot of proprietary diagnostics or EOL protocols
• DTL based protocols (Diagnostic Transport Layer)
Other protocols are typically based on the DTL layer:
• Standard LIN Diagnostics
• UDS (Unified Diagnostic Services) (ISO 14229-1:2013)
These protocols are not part of the LDF definition.
Only the two frames 0x3C (MasterRequest) and SlaveResponse (0x3D), which serve as
transport containers for the actual protocol data, are defined in the LDF.
More details about the Diagnostic Frames and related protocols will be discussed in the 2nd
part of the LIN Workshop.
Slide-27 30.03.2022
LIN frame security – In data CRC (optional)
Currently, the use of an additional security/safety feature for LIN frames can be observed with an
increasing tendency.
It is an 8 bit CRC, which is formed by a certain block of data (e.g. Data2..Data7) and then also placed
in the data section (e.g. in Byte Data1).
In addition to numerous proprietary implementations, a standard according to the Autosar E2E
Specification is currently establishing itself, whereby there are several profiles here. However, first
implementations deviating from the standard have already been viewed (e.g. BMW).
In contrast to the LIN Checksum calculation, which is disclosed in the LIN specification, the special
parameters for these InData CRC's are usually only available against NDA (non disclosure agreement)
from the manufacturer.
The CRC not only ensures transmission security, but is also a security feature because it can be defined
in such a way that certain functions of a system can only be accessed by authorized remote peers.
All CRC Autosar implementations share an additional 4 bit counter in the data. This counter is
incremented every time a frame is sent.
Slide-28 30.03.2022
LIN frame security – Autosar E2E Profile1
Slide-29 30.03.2022
LIN frame security – Autosar E2E Profile 2
Slide-30 30.03.2022
LIN frame security – In data CRC
The definition of the parameters for a particular Indata CRC's definition is not part of the LDF
specification.
In practice, there are different ways of documenting the CRC parameter specifications in a
concrete project.
Sometimes they are stored as comments in an LDF file.
Or they are given in a description of the signals and frames (message catalog) of a vehicle
manufacturer (PDF/HTML file).More recent description formats for bus systems such as Fibex
(Asam) or ARXML (Autosar) already contain syntax elements for defining such Indata CRCs.
If necessary, a file in one of these formats can be obtained from the client.
Here one must observe the market further, in order to see what establishes itself here as
mainstream.
With the LINWorks PC software the necessary parameters for the CRC's can be included in a
simulation description.
The LINWorks extension for importing new description formats such as Fibex or ARXML is
planned for the future.
Slide-31 30.03.2022
How to create a LIN application
Tasks
LDF
Operate LIN-node for
➢ functional test
➢ endurance run
➢ software validation
➢ demonstration
➢ production,
EOL (End of Line)
Slide-32 30.03.2022
How to create a LIN application
Tasks
LDF
Operate LIN-node for
➢ functional test
➢ endurance run
Signal ➢ software validation
description
➢ demonstration
➢ production,
EOL (End of Line)
Slide-33 30.03.2022
How to create a LIN application
Tasks
LDF
Operate LIN-node for
➢ functional test
➢ endurance run
Signal ➢ software validation
description
➢ demonstration
➢ production,
EOL (End of Line)
Specification
Diagnosis
Services
Slide-34 30.03.2022
Lin Workflow in LINWorks
Slide-35 30.03.2022
LINWorks components
LDF-Editor:
LINWorks View LDF
LDF LDF- Create LDF
Editor
Customize LDF
Session-Configurator:
LINWorks Which nodes should be simulated?
SDF
Session-
Configurator
Which signals are to be displayed?
Macros, events and actions to define
LINWorks the functional logic
SimpleMenu
Definition of signal functions
Baby-Lin Definition of diagnostic services
DLL USB
Own
Applikation
Slide-36 30.03.2022
LINWorks SessionConf
Minimal setup:
➢ Import LDF file into Session
Configurator.
➢ Define emulation setup.
Slide-37 30.03.2022
LINWorks SessionConf
Slide-38 30.03.2022
LINWorks Simple Menu
LIN-Bus running!
Slide-39 30.03.2022
LINWorks Simple Menu
Switching to
another schedule
Section properties
Here you can enter a name and a
description for the section.
The flag "Store SDF in device persistently"
is important for stand-alone operation.
If it is set, the SDF is automatically stored in
the dataflash of the device during the
download.
If it is not set, the SDF is stored in the RAM of the device and
is then deleted again after a Power-OFF-ON cycle.
Speed[Bit/s]
Here the LIN baud rate is displayed, which was taken over from the LDF, you can
overwrite this baud rate with another value if necessary.
The baud rate must be entered here in a CAN section, since it cannot be taken over from
the DBC and is therefore set to 0 after the DBC import.
Slide-41 30.03.2022
SessionConf – Bus Description
Bus description
This area is used to display all objects taken over from the LDF such as nodes, frames,
signals, schedules, etc.
You can also change some of them here. Frame id's or slot times can be adjusted in
Schedule Tables.
Slide-42 30.03.2022
SessionConf - Emulation Setup
Emulation setup
Here you define which of the
nodes defined in the LDF is to be
simulated by the Baby-LIN.
Depending on which nodes are
connected, you should only select
nodes that are not physically
present.
In our SimpleWiper example we
have not connected any real
nodes, so we simulate all three
nodes.
Slide-43 30.03.2022
Session Conf – Tables
The new SDF feature 'Tables' allows to define data for the
functional logic in tabular form.
1.) Creating a table
2.) Enter a name for the table
3.) Definition of columns
A column can contain text (String) or
numbers (Signed/Unsigned Integer).
For numbers, the size (1...64 bit) can be
defined for memory space optimization.
Format defines the display or input
format for number columns.
Decimal Number 32 => 32
Hexadecimal Number 32 => 0x20
Binary Number 32 => 0b100000
Here is an example table for defining test
variants for a wiper endurance run.
Column 0 contains the name of the test,
columns 1...3 define specific time specifications
for the individual test variants.
Slide-44 30.03.2022
Session Conf – Tables
Here the completed example table with 5 test variants, column 0 contains the name
of the test, columns 1...3 define certain time specifications for the individual test
variants.
Virtual signals can be defined in addition to the signals defined in the LDF. These do not
appear on the bus, but can be used in macros and events.
These signals are very useful for implementing functional logic.
They can also be mapped to Protocol Frames (Protocol Feature).
The size of a virtual signal is 1...64 bit adjustable - important when used in the protocol
feature.
Each signal has a default value that is set when the SDF is loaded.
Checkbox Reset on Bus start
Allows to emulate the behavior
of SDF-V2 files.
There all signals (also the virtual
ones) were loaded with the
default values at every bus start.
Check box signed
By default, a signal is always
treated as unsigned.
With this checkbox you can turn
it into a signed signal.
The comment column allows you to enter notes and explanations about the variable.
Slide-46 30.03.2022
Session Conf – Virtual signals
Slide-47 30.03.2022
SessionConf – System signals as spezial virtual signals
@@SYSTIMER_UP generates an up counter that counts as soon as its value is not equalto 0. The
counter tick is one second.
@@SYSTTIMER_DOWN creates a down counter that counts every second until its value is 0.
@@SYSTIMER_FAST_UP like SYSTIMER_UP or _DOWN, but the timer tick here is 10 ms.
@@SYSTIMER_FAST_DOWN
Slide-48 30.03.2022
SessionConf – Virtual signals system variables
For example, the @@SYSDIGIN1...x and the @@SYSPWMIN1..2 system signal can be combined with
an ONCHANGE event.
So the input value a digital input can be transferred to a LIN bus signal with only one event definition.
To avoid having to remember all the reserved names for the system signals and their notation,
SessionConf provides a system signal wizard in the virtual signal section.
Slide-49 30.03.2022
SessionConf – System variables wizard
Slide-50 30.03.2022
Signal functions - Counter
If the Baby-LIN replaces the LIN bus master, it should generate the frames and signals
exactly as the original control unit in the vehicle does (residual bus simulation).
There are signals in real applications that need special handling, e.g. message counters
that increment their value every time they are sent on the bus, and when they reach their
maximum value, they start at 0 again.
This function can be automated in the SDF via a signal function.
Another example of signal functions are CRC's in the data.
Slide-51 30.03.2022
Signal functions - CRC
The CRC algorithm can be freely configured with initial value, polynomial and XOR value.
For the standard Autosar variants the correct default values are suggested.
Slide-52 30.03.2022
Signal functions – CRC example Checksum
Here the checksum is formed in a frame with a length of 4 bytes (= length of Frame
MasterCmd) over the second to fourth data byte (Param *1 = 1 => block starts with 2nd
data byte, Param *2 = 3 => block length 3, block thus comprises 2nd data byte...4th data
byte) and then stored in the first data byte (Param *3 = 0 => 1st data byte).
The parameters *4 to *7 define an optional prepend and postpend buffer with up to 8 byte
values, which are then prepended or appended to the data of the real frame before the
calculation.
This is used to implement special cases in which, for example, the FrameId is to be
included in the CRC calculation.
Slide-53 30.03.2022
Signal functions – CRC example Autosar
Here an Autosar CRC according to profile 2 is formed in a frame with 4 bytes length
(= length of Frame MasterCmd) over the second to fourth data byte. Here too, the
data block over which the CRC is formed comprises the 2nd data byte to the 4th data
byte.
For Autosar CRC there is then a whole series of parameters.
Slide-54 30.03.2022
Session Conf - Macros
Slide-55 30.03.2022
Session Conf - Macros
Slide-56 30.03.2022
Session Conf - Macros
Command
The operation to be performed by the Macro command.
Condition
Here you can define a condition that must be fulfilled to actually
execute the command.
Slide-57 30.03.2022
Macro Local signals/Local variables
All Macro Commands can use signals from the LDF (bus signals)
and signals from the Virtual Signal section (in the Command or in
the Condition).
In addition, there is another group of signals that only exists in the
context of a macro: the local signals.
Each macro always provides 13 local signals:
_LocalVariable1, _LocalVariable2, ..., _LocalVariable10,
_Failure, _ResultLastMacroCommand, _Return
The last 3 provide a mechanism to return values to a call context
(_Return, _Failure) or to check the result of a previous macro
command. (_ResultLastMacroCommand).
The signals _LocalVariableX can be used e.g. as temporary
variables in a macro.
E.g. to save intermediate results when performing a calculation with
several calculation steps.
Slide-58 30.03.2022
Macro Parameter Passing
Slide-59 30.03.2022
Macro Result return
Important note: The value of _ResultLastMacroCommand is only valid in the Macro command line directly
after the Gosub command, because this signal always contains the result of the previous command.
The _Failure variable has a different behavior. It is automatically transferred to the calling macro when
setting in the called macro when returning if it has a value unequal to 0.
Slide-60 30.03.2022
Macro Signal commands
Slide-61 30.03.2022
Macro Bus commands
Slide-62 30.03.2022
Macro Bus commands
Set frame mode Deactivate and activate LIN frames in a schedule or toggle between no, single
shot or periodic transmission (CAN)
Slide-64 30.03.2022
Macro Flow Control commands
Slide-65 30.03.2022
Macro Macro commands
Macroselection Starts a macro from a Macro Selection (group of macros) There are several
options for selecting the
macro from the Selection group.
Print Output of texts, signal values on the debug channel in the Simple Menu.
Very helpful for troubleshooting macro programming.
Further information and output to additional channels in the future.
Slide-66 30.03.2022
Macro Exception commands
Throw Triggers an exception with the given exception code anywhere (in the try
block or outside the try block).
Ignore Allows you to ignore certain exceptions for the following command.
For example, if an Execute Service error is the expected situation due to a
missing response.
Slide-67 30.03.2022
Macro Table commands
Store Value Stores a signal value in a Table Cell (Table : Row : Col) Table, column and row
selection as constant or signal reference.
Table Count Sets the specified signal with the number of tables in this SDF section.
Row Count Sets the specified signal with the number of rows in the requested table.
This allows you to iterate over all lines of a table in a macro, for example.
Column Count Sets the specified signal with the number of columns in the requested table.
Slide-68 30.03.2022
Macro Table example
Slide-69 30.03.2022
SessionConf – Macro selection
Macro selection
A macro selection defines a group of macros
from which a macro can be selected for
execution.
Example: A macro selection to choose
between the macros RunSpeed1, RunSpeed2
and StopMotor.
The selection can then be made using a GUI
Element, Event Action or Macro Command
(SDF-V3).
Slide-70 30.03.2022
SessionConf – Device specific options
There are also setting options for custom variants (e.g. WDTS).
Slide-71 30.03.2022
SessionConf – Device section
The Device Section (only in SDF-V3 files) allows to store the Target Configuration directly
in the SDF file.
It is still possible to configure the target device in the SimpleMenu, as it was only possible
in LINWorks V1.x.
If a SDF-V3 file contains a target configuration it is automatically transferred to the device
during the download.
Previous problems with forgotten Target Configuration at the customer are now a thing of
the past.
Slide-72 30.03.2022
Baby-LIN DLL
Labview
Python
etc.
Slide-73 30.03.2022
Baby-LIN DLL
The list of all API commands can be found in the BabyLINDLL.chm help file.
Slide-74 30.03.2022
Baby-LIN DLL
There are a large number of commands that can be issued using the API call
BLC_sendCommand(...).
start Starts the bus communication; for LIN with optional Schedule index
The list of all commands can be found in the BabyLINDLL.chm help file
Slide-75 30.03.2022
Baby-LIN DLL
➢ By accessing all signals, frames, macros etc. defined in the SDF, the distribution of tasks
between your own application and the Baby-LIN device can be freely defined to a large
extent.
➢ In addition to the SDF-based API, the DLL also offers a purely frame-based API (Monitor
API). Contrary to its name, this API also supports writing operations such as sending
frames.
➢ The Monitor API is also used for the new UDS protocol support..
Slide-76 30.03.2022
LIN diagnostic frames 0x3C/0x3C
Break Sync Identifier Databyte1 Databyte2 Databyte3 Databyte4 Databyte5 Databyte6 Databyte7 Databyte8 CheckSum
ID=0x3C ID=0x3D
MasterRequest SlaveResponse
Slide-77 30.03.2022
LIN Diagnostic Frames 0x3C/0x3D
Since a MasterRequest is received by all Slave nodes, but only one Slave is to respond to the
following SlaveResponse Frame, the data in the MasterRequest must contain a kind of addressing
so that the Slave can recognize that it is meant.
The connected nodes must then have different addresses according to this addressing method.
In addition, the data of the request must describe which action the master wants to execute with
the addressed slave.
In order to reduce the effort for specification and implementation of these mechanisms in a LIN
application, a general definition was created that is part of the LIN specification.
The protocol called DTL (DiagnosticTransportLayer) also allows larger data packets with more
than 8 bytes (maximum frame size for LIN) to be transported.
The use of the Diagnostic Transport Layer (DTL) is also referred to as Cooked Mode.
However, there are still applications today that operate diagnostics without DTL; these are usually
manufacturer-specific, which is referred to as raw mode.
Slide-78 30.03.2022
Diagnostic transport layer DTL in detail I
➢ NAD and PCI are 2 elements that occur in each frame and provide information about
the frame and its destination or origin.
Slide-79 30.03.2022
Diagnostic transport layer DTL in detail II
Slide-80 30.03.2022
Special case MasterRequest: Sleep
Even in systems that use DTL mode, a certain MasterRequest Frame can occur that
differs from the DTL Frame Layout Schema.
This is the Sleep Command Frame, which can be sent by the master.
It requests all connected nodes to go into sleep mode.
Usually the sleep mode in the slave is also linked to a power saving mode, depending on
the slave implementation.
After sending this frame, the master stops sending further frames.
To wake up the bus again, the master sends a wakeup event and continues with the
scheduling (start, restart, wakeup).It is also permissible for a slave to wake up a sleeping
bus with a wakeup event.
This is also the only situation on the LIN bus where a slave can show activity on the bus
without being requested to do so by the master.
Slide-81 30.03.2022
Standard Diagnostic Services
Slide-82 30.03.2022
DTL standard payload layout
PAYLOAD Request
DTL-Request Service
Id SID always in 1. DB0 DB1 DB2 DB3 DB4 DB5 DB6 …… DBn
byte of payload SID P1 P2 P3 P4 …. …. …. ….
Slide-83 30.03.2022
Lin product identification
According to LIN specification, each LINV.2x node has a unique product identification.
The product identification consists of 3 values:
Supplier Id 16 bit number (most significant bit always 0), the Supplier Id is assigned to the
manufacturer by the CIA (formerly LIN Consortium).
Function Id 16 bit Manufacturer-specific number that identifies a specific product. Products that
differ in LIN communication or in their properties at the interfaces should have
different Function Ids.
Variant 8 bit number, which should always be changed if the node does not experience
functional changes.
Supplier Id and Function Id are required in some diagnostic services as parameters in the
MasterRequest.
Wildcards have been defined so that these services can Wildcards
also be executed without knowledge of this ID. NAD 0x7F
Every node should support this wildcard, in practice this is
Supplier Id 0x7FFF
not always the case.
Wildcards usually only work with a single connected slave. Function Id 0xFFFF
However, there are exceptions, e.g. auto-addressing, but no
response is evaluated.
Slide-84 30.03.2022
Diagnostic Services Read data by ID
Slide-85 30.03.2022
Diagnostic Services Assign Nad
Slide-86 30.03.2022
Diagnostic Services Assign FrameId
If the service was successful, the slave gives a positive response as far as the
master requests it by sending a slave response header.
When using the wildcard NAD, the response is the real NAD. source: LIN specification V.2.2.
Slide-87 30.03.2022
Diagnostic Services Assign FrameId II
Each configurable frame of a LIN node is listed in the Configurable Frames section of the
node attributes in the LDF. There the corresponding Message Id is also assigned to each
frame. The message id is only unique within a node, but nodes of the same type have the
same message id for the same frame.
Slide-88 30.03.2022
Diagnostic Services Assign FrameId range
Positive response
Slide-89 30.03.2022
Diagnostic Service Assign FrameId range (0xB7)
The positive response for both service would look like this:
Slide-90 30.03.2022
Diagnostic Services Data Dump
Positive Response
RSID corresponds again to the rules of the DTL (0xB4 | 0x40 = 0xF4); all further
data in the payload are defined manufacturer specifically.
Slide-91 30.03.2022
LIN Diagnostic Service Save Configuration (0xB6)
Upon successful execution of the service and correct NAD, the slave should respond
with the following frame. It should be noted that there is no wait for the configuration to
be saved
Slide-92 30.03.2022
Raw mode interactive Simple Menu
Slide-93 30.03.2022
Raw mode interactive in Simple Menu
For this function a Schedule with MasterRequest and SlaveResponse Frames must
be activated.
After entering the request data and setting RequestCount to 1, we see the answer
when we press Send.
Slide-94 30.03.2022
Cooked mode interactive Simple Menu
Slide-95 30.03.2022
Raw mode MacroCommand MasterReq
Diag Schedule
necessary, therefore
start bus first
Slide-96 30.03.2022
Raw mode MacroCommand Inject
Slide-97 30.03.2022
Raw mode MacroCommand Inject
When sending a diagnostic request via Macro Command Inject you get the
identical data.
In the Frame Monitor, Inject Frames are marked separately.
Slide-98 30.03.2022
SDF Feature Protocol Service
1. add
protocol here
Slide-99 30.03.2022
Raw mode MacroCommand Execute service
Slide-100 30.03.2022
Raw mode MacroCommand Execute service
Slide-101 30.03.2022
Cooked mode MacroCommand Execute service
Slide-102 30.03.2022
Cooked mode MacroCommand Execute service II
Slide-103 30.03.2022
Advantages SDF Protocol Services
The use of protocol services offers many advantages, so that the older Macro commands
SendMasterRequest or Inject will not be used anymore.
➢ Macro execution is synchronous to bus communication
If a command "Execute Protocol Service" is finished, the frames were also on the bus.
➢ Any problems that occur when sending / receiving protocol frames are detected and
reported back.
➢ Support of DTL/ISO TP Multiframe messages (Request and Response).
➢ With DTL/ISO-TP the negative return codes are evaluated and returned.
➢ A temporary NCR 0x78 is also handled correctly and the response request is repeated
until a final positive or negative response is received.
➢ Return value of the Macro commands Execute Protocol Service allows error handling in
the SDF.
➢ Access to the return value via the local signal __ResultLastMacroCommand.
➢ The protocol mechanism is not limited to diagnostic frames, it also allows the creation of
applications with dynamic schedules, because then the frame dispatch is triggered by
macro and not by schedule.
➢ The FrameId of a protocol service can also be defined via a signal.
Slide-104 30.03.2022
Result Codes command Execute Protocol Services
Here is a list of the most common error codes that are available as
__ResultLastMacroCommand after an Execute Protocol Service Command.
A complete list can be found in the respective user manual of the product.
10 Too many services have been started (possibly from macros running in parallel).
14 The length of the slave response does not match the SDF protocol definition
256…511 With DTL/ISO-TP the slave can give a negative response. This contains an 8 bit error code. This
error code is returned here with an offset of 0x100.
e.g. 0x12 => 0x112 => 274
Slide-105 30.03.2022
Result Codes command Execute Protocol Services
In LIN Standard Diagnostics and UDS the same Negative Response Codes are usually applied in
the negative response. (0x7F <SID> <ErrorCode=NRC>
Here is a list of the most important NCR's.
Slide-106 30.03.2022
Diagnostic Frames-Auto-addressing
Auto addressing is needed if you have a LIN bus with several similar slaves, as is often
the case with air-conditioning actuators or ambient LEDs.
Auto addressing uses different methods to make the identical slaves individually
addressable for the master by a certain procedure, in order to be able to assign them a
specific NAD and FrameId.
The 2 most common methods are the daisy chain and the bus shunt method.
Both methods use a bus wiring with a LIN-IN and LIN-Out pin at each slave.
Slide-107 30.03.2022
Diagnostic Frames-Auto-addressing
SNPD Subfunction ID
Slide-108 30.03.2022
Auto Addressing Daisy Chain Method
Slide-109 30.03.2022
Auto Addressing Bus Shunt Method
Slide-110 30.03.2022
Macro programming - debugging
When programming more complex operations in macros, it is helpful to be able to track the
operation of a macro to find programming or operation errors.
This is where the Macro Command Macro Print helps (example SDF TestPrintDebug.sdf).
Slide-111 30.03.2022
Macro programming – error handling
Even in a correctly programmed sequence, errors can occur during execution, for example
because a defective test object does not respond at all. A carefully developed SDF application
should be able to detect and handle these errors.
The result values of the individual Macro Commands (_ResultLastMacroCommand) already
show whether a command worked or not. The prerequisite for this is that the command, if
selectable, is executed blocking.
A TRY-CATCH mechanism has been implemented to avoid having to introduce an error
handling after every command in a macro.
Every error in the try block (green marking) automatically branches to the catch block (red).
Without errors the catch
block is skipped.
Slide-112 30.03.2022
Macro programming – Try-Catch
You can specify several Catch Block Start Commands one after the other, so you can
define areas in the Catch Block that are responsible for certain exceptions.
Therefore there is the option to define an Exception Value as filter in the Catchblock
Start Command.
If two Catch Block Start Commands are directly behind each other, the area after the
second CatchStart is executed for both Exception Values.
Slide-113 30.03.2022
Macro programming– Try-Catch
Slide-114 30.03.2022
MB-II Log functions
After installing a micro-SD card, the MB-II can create log files which can be accessed via the
integrated website of the device.
Slide-115 30.03.2022
MB-II Log functions
Slide-116 30.03.2022
Stay up-to-date
The Baby-LIN firmware and the LINWorks software are constantly being further developed.
Both can be obtained free of charge in the current version directly from our customer portal.
(https://www.lipowsky.de/downloads/ )
For the firmware update of the Baby-LIN devices the application blprog.exe is included in the
download package.
This application takes over the update process largely automatically if the files have been unpacked
from the ZIP into a separate directory.
If you have any questions or suggestions, please feel free to contact us at any time by phone: 06151-
93591-0 or by email: [email protected]
We are also happy to visit your computer via TeamViewer to support you on site in case of problems.
Slide-117 30.03.2022
Baby-LIN feature matrix
LINWorks compatible
SDF transfer USB 2.0 USB 2.0 USB 2.0 USB 2.0 Ethernet
SDHC card web interface
RS-232
Digital Outputs 1 x Digital Output 6 x Digital Output 1 x Digital Output 2 x Digital Output
Special features Option for SD Card Digital In – and LIN voltage switch, Logging on internal
support outputs, analogue 12 V node supply micro-SD card,
inputs, generator logdata accessed by
device webpage
Typical applications PC-Interface PC-Interface and PLC-coupling or Hand-held control PC/PLC coupling via
hand-held stand-alone bus with bus data display LAN or RS-232
commander simulator
Slide-118 30.03.2022