Rounding up, the frame slot numbers tell us that we
can set the frame slot time between 14.0 and 20.0 ms.
A safe bet on the minimum side would be 17.0 ms, which
will still be a bit high for frames that don’t carry the full
load of eight data bytes. We could get really persnickety
about all of the frame slot stuff and implement what the
LIN Specification calls a schedule table which defines a
unique frame slot for every frame that will be published by
the master and slave nodes.

Routing the frame involves yet another LIN element
called the message identifier. The message identifier is
a 16-bit message number that is associated with a
protected identifier. A protected identifier is simply an
identifier along with its pair of parity bits in the most
significant bit positions. A LIN slave node that adheres to
the recommendations of the LIN Specification stores
message identifiers in ROM and their associated protected
identifiers in SRAM.

Data within a frame is categorized as signals or

44 SERVO 07.2009

diagnostic messages. Signals are no more than arrays of
one to eight bytes or a scalar value. For instance, a
Boolean signal is a one-bit scalar while a 16-bit signal is
treated as an unsigned integer. A signal is always located
in the same position in the frame relative to a specific
identifier. Diagnostic messages are found within frames
with two reserved identifiers (decimal 60 and 61). The
data within a diagnostic message determines how the
message is interpreted. Slave tasks publish (place a
response on the bus) and subscribe to (receive and act
upon) the diagnostic message according to their current
state and programming. Master request frames (identifier
= 60) and slave response frames (identifier = 61) are
examples of diagnostic frames.

At this point, we could continue this LIN standards
discussion all the way through the contents of diagnostic
frames and how each data field within a diagnostic frame is
defined and used. For example, standardized LIN nodes
must include manufacturer information called a function ID
in addition to a LIN Consortium assigned supplier ID.
However, we’re not here to design LIN standard ECUs
(electronic control units) for automobiles. So, we can
bypass the supplier ID requirement and choose only the
LIN disciplines we wish to include into our robotic LIN
driver. Let’s begin our LIN coding work by improving upon
the transmit code we wrote last time.

Updated LIN TX Driver

The first byte sent in a master published LIN frame
is the Auto-Baud chirp (0x55). After subscribing to the
chirp, slave units on the bus wait for the protected
identifier byte (PID) which is the identifier merged with
its pair of parity bytes. Thus, the very first action that
our send_lin_frame function must take is to calculate the
PID using the supplied identifier. Before we fire off the
send_lin_frame function, let’s place a call to a function
called load_ 8 which assembles the maximum number
of bytes a LIN frame can legally handle into an array
called lin_buf: