Embedded systems & buses

Sensors, embedded & practical systems · tree view

Getting bits between chips: what makes a wire set a "bus" (a standard, not just copper), serial vs parallel, UARTs and baud, and the reach numbers for RS-232 vs RS-485.

Prerequisites

microcontroller symbol
microcontroller
uart-frame-8n1.svg
uart-frame-8n1.svg
bus-topologies.svg
bus-topologies.svg

This collection of wires that I keep referring to between the tank and the monitoring location can be called a bus or a network. The distinction between these two terms is more semantic than technical, and the two may be used interchangeably for all practical purposes.

— Tony R. Kuphaldt, Lessons In Electric Circuits, Vol. IV (Digital), Chapter 14, section “Networks and busses” source

Names like "Fieldbus" or "Profibus" encompass not only the physical wiring of the bus or network, but also the specified voltage levels for communication, their timing sequences (especially for serial data transmission), connector pinout specifications, and all other distinguishing technical features of the network.

— Tony R. Kuphaldt, Lessons In Electric Circuits, Vol. IV (Digital), Chapter 14, section “Networks and busses” source

Fortunately, there are digital IC chips called UARTs (Universal Asynchronous Receiver-Transmitters) that handle all these details on their own and make the designer's life much simpler.

— Tony R. Kuphaldt, Lessons In Electric Circuits, Vol. IV (Digital), Chapter 14, “Introduction” source

The standard measure of network bandwidth is bits per second, or bps. An obsolete unit of bandwidth known as the baud is sometimes falsely equated with bits per second, but is actually the measure of signal level changes per second. Many serial network standards use multiple voltage or current level changes to represent a single bit, and so for these applications bps and baud are not equivalent.

— Tony R. Kuphaldt, Lessons In Electric Circuits, Vol. IV (Digital), Chapter 14, section “Electrical signal types” source

Because all the bits arrived at their destination simultaneously, we would call BogusBus a parallel network technology.

— Tony R. Kuphaldt, Lessons In Electric Circuits, Vol. IV (Digital), Chapter 14, section “Electrical signal types” source

RS-232C is a prime example of a ground-referenced serial network, while RS-422A is a prime example of a differential voltage serial network. RS-232C finds popular application in office environments where there is little electrical interference and wiring distances are short. RS-422A is more widely used in industrial applications where longer wiring distances and greater potential for electrical interference from AC power wiring exists.

— Tony R. Kuphaldt, Lessons In Electric Circuits, Vol. IV (Digital), Chapter 14, section “Electrical signal types” source

RS-422A/RS-485 Two serial networks designed to overcome some of the distance and versatility limitations of RS-232C. Used widely in industry to link serial devices together in electrically "noisy" plant environments. Much greater distance and speed limitations than RS-232C, typically over half a mile and at speeds approaching 10 Mbps.

— Tony R. Kuphaldt, Lessons In Electric Circuits, Vol. IV (Digital), Chapter 14, “Extended-distance networks” (bus list) source

RS-232C The most common serial network used in computer systems, often used to link peripheral devices such as printers and mice to a personal computer. Limited in speed and distance (typically 45 feet and 20 kbps, although higher speeds can be run with shorter distances).

— Tony R. Kuphaldt, Lessons In Electric Circuits, Vol. IV (Digital), Chapter 14, “Extended-distance networks” (bus list) source

Perhaps the most important consideration of an ADC is its resolution. Resolution is the number of binary bits output by the converter. Because ADC circuits take in an analog signal, which is continuously variable, and resolve it into one of many discrete steps, it is important to know how many of these steps there are in total.

— Tony R. Kuphaldt, Lessons In Electric Circuits, Vol. IV (Digital), Chapter 13, section “Practical considerations of ADC circuits” source
Show alternative explanations

Serial data network frequencies start to enter the radio range, and simple wires begin to act as antennas, pairs of wires as transmission lines, with all their associated quirks due to inductive and capacitive reactances.

— Tony R. Kuphaldt, Lessons In Electric Circuits, Vol. IV (Digital), Chapter 14, section “Electrical signal types” source

A robust alternative to the common ground signal method is the differential voltage method, where each bit is represented by the difference of voltage between a ground-isolated pair of wires, instead of a voltage between one wire and a common ground.

— Tony R. Kuphaldt, Lessons In Electric Circuits, Vol. IV (Digital), Chapter 14, section “Electrical signal types” source

Other networks, such as RS-232C, are almost exclusively point-to-point; and token ring (as you might have guessed) is implemented solely in a ring topology.

— Tony R. Kuphaldt, Lessons In Electric Circuits, Vol. IV (Digital), Chapter 14, section “Network topology” source

Paraphrase (book-adjacent): the universal asynchronous framing that UART chips run — a line idling high, one low start bit, 5–9 data bits LSB first, then a high stop bit — is what the book's "timing sequences" bullet means in practice. The frame layout itself comes from the UART standards, not from the library texts.

— summary of standard UART framing (8N1); no library quote covers it, datasheet/standard fact — flagged gap

UART framing arithmetic (8N1 @ 9600 baud)

A UART sends one byte as: 1 start bit (low) + 8 data bits (LSB first) + 1 stop bit (high), line idles high. That is 10 bit-times per byte. All timing python-verified.

To predict the outcome:

  1. Count the bits in the frame: 1 + 8 + 1 = 10.
  2. At 9600 baud each bit lasts 1/9600 s ≈ 1.042 ms.
  3. Throughput = 9600 / 10 = 960 bytes/s — the baud is not the byte rate (book: baud ≠ bps in general).
  4. A 64-byte message costs 640 bit-times ≈ 66.7 ms on the wire.
elementlevelbit_timestime_at_9600
idlehighanybetween frames
start bitlow10.1042 ms
8 data bits (LSB first)byte value, e.g. 0x55 → 1,0,1,0,1,0,1,080.8333 ms
stop bithigh10.1042 ms
whole byte (framing overhead 2 of 10 bits = 20%)—101.042 ms per byte → 960 bytes/s

Serial reach & speed: RS-232 vs RS-422/485 (book numbers)

The book's own spec lines: RS-232C "typically 45 feet and 20 kbps"; RS-422A/485 "over half a mile and at speeds approaching 10 Mbps". Predict what each does to a 1 kB transfer.

To predict the outcome:

  1. Take the book's limits as the circuit rating.
  2. Compute transfer time for 1000 bytes × 10 bits/byte = 10,000 bits.
  3. 20 kbps → 0.5 s; 10 Mbps → 0.8 ms.
  4. Ask why: RS-232 swings one wire against a shared ground; RS-422/485 use a differential pair that ignores common noise.
busreach_typicalspeed_typicaltime_for_1_kbsignalling
RS-232C≈45 ft (book)20 kbps (book)≈0.5 sground-referenced, single-ended
RS-422A/RS-485> half a mile (book)≈10 Mbps (book)≈0.8 ms — ~600× faster, ~60× fartherdifferential pair, noise rejected as common-mode
RS-232 pushed past ratingbook: 100 kbps worked on a 6 ft cabledistance and speed trade against each other≈0.1 sshort cable keeps the stray capacitance small

Parallel vs serial: wires and wire frequency

The book's BogusBus carries 5 data bits on 7 wires (5 data + 24 V supplies), all bits arriving simultaneously — parallel. Re-send the same 8-bit value serially on one pair and the wire frequency jumps. The book's own example: parallel 0.5 Hz → serial ≈4 Hz, an eightfold increase. Python-verified factor.

To predict the outcome:

  1. Count wires: parallel N data lines vs serial 1 pair (plus ground).
  2. Parallel: wire frequency set by the update rate — 1/2 Hz in the book's example.
  3. Serial: all 8 bits squeeze through one channel per update → ×8 the frequency (8/0.5 Hz/2).
  4. Generalise: bit-per-second grows with width × update rate; the wire starts acting like an antenna (book).
metricparallelserialverdict
wires for 5 bits of data5 data (+2 power) = 7 (BogusBus)2 (pair) or 3 with groundserial trades copper for encoding
wires for 8-bit resolution8 data linessame 2 wires, faster clockserial scales resolution for free in copper, at a cost in speed
wire frequency (book example)0.5 Hz max≈4 Hz (8× more)python-verified: 8 bits / (1 s update) → 8 transitions/s per alternating bit pattern
at 32–64 bits, thousands of updates/simpractical copper countfrequencies reach the radio range — wires behave as transmission lines (book)why real buses care about twisted pairs and differential signalling

Board-level buses: I2C vs SPI verdicts

GAP, loudly: the library has no I2C/SPI text (Kuphaldt Vol IV stops at RS-485-era networks). These rows are standard/datasheet facts, offered book-adjacent for prediction practice — flagged for future sourcing.

To predict the outcome:

  1. Count the wires each needs for n slaves.
  2. Ask who addresses the slaves: in-band address (I2C) vs one CS line each (SPI).
  3. Compare typical clock rates.
  4. Predict the idle level of an open-drain line without a pull-up.
buswires_for_4_slavesaddressingtypical_speedidle_level
I2C2 shared (SDA, SCL) + pull-ups7-bit address inside the packet100–400 kHz (fast-mode 1 MHz, high-speed 3.4 MHz)both lines high — open-drain, pull-ups required; no pull-up = bus stuck low
SPI4 + one CS per extra slave (MOSI, MISO, SCLK, CS)hardware chip-select line per slavemulti-MHz to tens of MHzpush-pull — defined without pull-ups
shared wire, two masters, I2Csame 2 wiresarbitration keeps the bus coherent — address clashes are the failure modesame as single mastercontention detected as a master losing a bit it released
UART vs these2, but strictly point-to-point (book: RS-232 almost exclusively point-to-point)none — one peer each waywhatever both ends agree (book: 20 kbps classic RS-232)high (marking); start bit breaks idle

Candidate projects — awaiting review

  • I2C scanner board: a microcontroller, a couple of sensor breakouts and pull-ups on a small PCB — first project that both scans the bus and is a first layout exercise. (https://www.reddit.com/r/arduino/comments/1t5ehyb/made_my_first_circuit_board_an_i2c_scanner_with/, community)
  • Bus sniffer: a cheap USB logic analyzer (or a microcontroller bit-banged into one) with protocol decoders on I2C, SPI and UART — decode a real sensor transaction bit by bit. (https://www.reddit.com/r/arduino/comments/e7wku7/tip_get_yourself_a_12_logic_analyzer/, community)
  • Spy on an I2C bus with a second microcontroller and print the raw hex to the serial monitor — watch addresses and acknowledgements on a live peripheral. (https://www.reddit.com/r/arduino/comments/1551y63/is_there_a_good_way_to_spy_on_an_i2c_bus_and/, community)
  • BogusBus rebuild: recreate the book's hypothetical 7-wire network — five switches, five lamps, one wire each — then shrink it with a parallel-to-serial converter pair and count the copper saved. (Kuphaldt, Lessons In Electric Circuits Vol. IV ch. 14, “BogusBus”, book)