Chapter 12
scopes have a math function that enables viewing a differential voltage as the
difference between the voltages on the two channels.
Humble components such as LEDs and switches can also be useful. On a
microcontroller, interface LEDs to spare output bits and write code that toggles
the bits to indicate events. For example, firmware can turn on an LED when
the node recognizes its address and turn on another LED after receiving a mes-
sage. Add toggle or slide switches to spare input port bits and have the program
send the values of the bits in its messages.
In a typical network, each node has an assigned address and each message con-
tains the address of the recipient. On receiving a message, a node must detect
the address to determine whether to process or ignore the message.
A node address is a value unique to the node and can be any number of bits.
Some networks use addresses that correspond to ASCII codes.
If there are fewer than 128 nodes, you don’t need 8 bits to specify the node and
can get the most use out of a transmitted byte by assigning extra bits to other
uses. For example, in a 16-node network, bits 0–3 can specify the node number,
with bits 4–7 holding a command or other information.
$
One challenge in sending addresses is that the nodes have to distinguish
between addresses and other information. For example, imagine a network
where each transmitted message begins with a byte containing the address of
the recipient. On recognizing its address, a node knows that the bytes that fol-
low are intended for it.
If Node 05h receives the byte 03h followed by 05h, how does Node 05h know
whether the second byte is part of a message meant for another node or an
address that begins a new message?
There are several ways to distinguish between addresses and other data:
- The addresses can use a reserved set of values that messages never use.
- The network can define a message format that specifies where the address is
stored in messages.