Supplier photo of an assembled infinity mirror light cube illuminated on a dark background.
Supplier photo
Temu affiliate offer · Project idea

Build an infinity light cube

Listing specifies 5-volt direct current. Soldering required; battery and glue not included.

View kit on Temu

Tricky Circuit may earn a commission through these links. Product ideas have not been bench-tested by Tricky Circuit and are not verified lesson parts lists.

THVD1450: A Short Differential Link and the Turnaround Trap

A serial write can finish accepting bytes before the final bit has left the pin. On a shared two-wire link, releasing the transmitter at that moment can cut off the end of the message. Build a short two-node experiment that separates three things: a requested transmission, a completed wire transmission, and a matching reply.

Here V means volt, the unit of voltage; Ω means ohm, the unit of resistance; kΩ means kiloohm or 1000 ohms; nF means nanofarad, one billionth of a farad of capacitance; and W means watt, the unit of power. Length in cm is in centimetres. Time in ms is in milliseconds, thousandths of a second; µs means microseconds, millionths of a second. VCC labels the positive supply, and GND labels the shared ground return.

The exact interface is a pair of Texas Instruments THVD1450DR transceivers in eight-pin small-outline integrated circuit (SOIC) packages. An integrated circuit (IC) combines the transmitter and receiver electronics. Each endpoint uses an original Raspberry Pi Pico with RP2040 and official MicroPython1.26.0. RS-485, Recommended Standard485, names the differential electrical interface: the receiver compares two bus wires, rather than treating either one as an ordinary3.3V logic pin.

Verification: host tests run the delivered packet, parser, direction-control and request/reply code with injected peripherals. The diagrams show a proposed20cm bench link and a timing model. No physical link, collision experiment, cable waveform, target execution or firmware build has been performed.

Choose a half-duplex part and a narrow experiment

Half duplex means both nodes share one pair and take turns transmitting. THVD1450 is the50megabits-per-second family member, not the slower THVD1410 or the full-duplex THVD1451/1452. We use only9600bits per second, but that setting does not turn its fast electrical edges into slow ones. Keep the cable short, endpoint stubs very short, ground paths clear and the decoupling capacitor close to each IC. A successful bench exchange would not certify a long industrial cable installation.

The currently served manufacturer document is SLLSEY3E, May2019, with the exact DR ordering page identifying the D/SOIC8 package and reel carrier. The operating supply range is3–5.5V; both endpoints use3.3V. The7V absolute supply limit is a damage boundary, not a design voltage. Current product documentation and a targeted manufacturer errata search did not reveal a separate applicable sheet; that is not proof none can exist for a particular revision.

Parts, reference and local supplies

  • Two THVD1450DR parts on continuity-checked passive SOIC8 adapters; two original Pico RP2040 boards with MicroPython1.26.0.
  • Two120Ω,1%,0.25W terminators, one at each physical end; two100nF ceramic bypass capacitors rated at least10V, one at each IC.
  • One47kΩ direction pulldown and one10kΩ receiver-output pullup per endpoint. Use1% resistors rated at least0.125W.
  • Approximately20cm of nominal120Ω twisted-pair cable for A/B, plus a separate short common-ground conductor; a fixture with negligible branches and inspected solder joints.
  • Two USB data cables and consoles. USB means Universal Serial Bus. A logic analyzer or oscilloscope is useful for a real turnaround check, but no such measurement is assumed.

Join the endpoint grounds, but keep each Pico’s3V3 regulator output local. Do not join the two3V3 outputs. This circuit is not galvanically isolated: the common-ground conductor is part of the stated bench topology. A bus common-mode rating does not replace a reference connection or qualify arbitrary ground differences.

Every used pin has a purpose

A UART, universal asynchronous receiver/transmitter, converts bytes into start, data and stop bits. The Pico UART0 uses GP0 for transmit and GP1 for receive. GP means a numbered general-purpose input/output (GPIO) pin. We connect GP2 to both direction controls: DE is active-high driver enable; /RE is active-low receiver enable. A slash means that a low voltage enables that function.

Exact THVD1450DR endpoint pins to Pico UART and direction, with a 100 nF bypass, 47 kΩ direction pulldown and 10 kΩ receiver pullup. Two 120 Ω end terminators connect across a 20 cm common-ground pair.
Original connection schematic. The upper circuit is repeated at both endpoints; the lower bus drawing names the two separate ICs. Dots join wires; undotted crossings do not. Open full-size schematic.
THVD1450DR D-package pin Endpoint connection Function
1 R Pico GP1, physical2;10kΩ to local3.3V Receiver output to UART input. Pullup keeps this input at idle while the receiver is disabled.
2 /RE;3 DE Both to GP2, physical4;47kΩ to ground Low listens with driver off; high drives with receiver off. Pulldown establishes listening while the controller starts.
4 D Pico GP0, physical1 UART output into the line driver.
5 GND;8 VCC Pico GND physical38;3V3 OUT physical36 Local supply/reference;100nF directly across the IC supply pins.
6 A;7 B A-to-A and B-to-B on the twisted pair Differential bus. Fit120Ω across A/B at each endpoint, not in series with either wire.

Use the manufacturer’s A/B definitions and exact pin numbers; module labels in other product families are not a compatibility promise. With the driver enabled, D high makes A more positive than B and the corresponding receiver produces high. Reversing A/B is not a harmless software renaming. Make wiring changes with both supplies disconnected.

Termination, idle and a peer are different facts

Two120Ω terminators appear as approximately60Ω across the pair in the static model. At a hypothetical2V differential level, each dissipates2²/120≈33mW; even using3.3V as a conservative resistor-voltage bound gives about91mW per part. These are nominal resistor calculations, not a measured line voltage or total supply-current result. The datasheet specifies driver behavior with a54Ω test load; our two-end topology is a60Ω nominal load before tolerances and receiver effects.

Termination matches cable impedance to reduce reflections. It is placed at the ends, rather than at every node or on a branch. This lesson does not infer a general distance/data-rate limit from a20cm build. A slow byte rate can still have fast edges, and a loose breadboard jumper network is not an impedance-controlled cable.

The THVD1450’s integrated failsafe receiver returns a defined high output for open, shorted or idle bus conditions described by its datasheet. This fixture does not add an external bias-resistor network. A high receiver output is also the UART idle state: it does not tell the program that the other Pico exists or can reply. The transaction timeout must remain unknown/unanswered, not “link healthy.” Do not deliberately short a powered pair to demonstrate the catalogue fault claim.

Wait for the transmitter, then allow the other node to speak

Our UART framing is8N1: eight data bits, no parity and one stop bit. Including the start bit gives ten bits per character, about1.0417ms at9600bits/s. The12-byte PING frame therefore occupies about12.5ms; the11-byte ACK occupies about11.46ms. ACK means acknowledgement. These are timing calculations; interpreter and device delays add work around the wire frames.

Two nonoverlapping driver-enable waveforms and PING/ACK payload intervals on a nominal serial timeline, separated by the chosen 3.5 ms reply guard.
Original calculated serial bit-time and driver-ownership diagram. Software processing is omitted; the 20 µs allowances and 3.5 ms reply guard are choices, not measured timings. Error cleanup remains explained in the article. Open full-size timing model.

UART.write() reports accepted bytes; on the RP2 port, UART.flush() waits until transmission is complete and raises an exception on timeout. The program enables the driver, allows20µs, writes the full packet, flushes, allows another20µs and releases GP2 in a finally block. That block also runs after a partial write or flush failure. It requests driver-off/listening; only a physical probe can verify the pin and line actually followed it.

The responder waits3500µs after decoding a complete request before enabling its own driver. This is about3.36character times at the chosen rate and leaves room for the initiator’s final stop bit, software allowance and receiver re-enable. It is a conservative policy for this two-node experiment, not an RS-485 arbitration standard. Both nodes configured as initiators violate that policy; no collision detection or multi-master recovery is claimed.

A checksum and sequence constrain the claim

A packet contains PING or ACK, a three-digit sequence0–255 and a two-digit hexadecimal checksum, followed by newline. The checksum is CRC-8, cyclic redundancy check with polynomial0x07 and initial value zero. It detects many accidental changes, not every possible error and not malicious traffic. Sequence numbers wrap after255; they are a small bench correlation field, not authenticated freshness or a permanent message identity.

The parser holds at most64 incomplete bytes, discards an oversized line through its next newline, and rejects malformed fields or checksums. Before a request the initiator clears its parser and the configured receive buffer while the responder is expected to be quiet. It accepts only a matching ACK within its bounded receive window. The window uses a wrap-aware elapsed-clock difference. A receive call also stops after at most 4096 loop services, and an exchange stops after at most 64 response attempts, even when the observed clock does not advance. A negative difference between serviced clock observations, or from the window start, raises a clock fault; a service-budget fault also stops the main program as LINK_FAULT_STOPPED. Both parser and pending replies are cleared on these faults. These are finite software-operation budgets, not physical deadlines: a UART, sleep, clock or report call that never returns cannot be interrupted here. The clock differences assume observations less than half the tick period apart; a complete unobserved wrap can still alias. An ordinary short timer wrap is supported.

Complete program for both endpoints

Copy the complete file to each Pico as bench_link.py. Keep ROLE="initiator" on one board and change it to "responder" on the other. Start the responder first, then run import bench_link; bench_link.main() on the initiator. Keep two clearly named consoles so the role is visible before running.

Download full MicroPython program (ZIP; file: tricky-circuit-batch-006/code/thvd1450-bench-link.py) · Blank link worksheet (ZIP; file: tricky-circuit-batch-006/code/thvd1450-bench-link-observations-blank.csv)

"""THVD1450DR pair; original Pico RP2040; MicroPython1.26.0.
Set ROLE differently on the two boards. Host fakes are not an electrical bus model.
"""
ROLE = "initiator"  # Other board: "responder". Never two initiators.
BAUD = 9600
TURNAROUND_US = 3500
MAX_RECEIVE_POLLS = 4096  # Returned loop services, not a physical deadline.
MAX_EXCHANGE_ATTEMPTS = 64  # Includes unrelated replies; clock may be frozen.


def crc8(data):
    result = 0
    for byte in data:
        result ^= byte
        for _ in range(8):
            result = ((result << 1) ^ (7 if result & 128 else 0)) & 255
    return result


def frame(kind, sequence):
    if kind not in ("PING", "ACK") or type(sequence) is not int or not 0 <= sequence <= 255:
        raise ValueError("need PING/ACK and integer sequence0..255")
    body = ("%s,%03d" % (kind, sequence)).encode("ascii")
    return body + (",%02X\n" % crc8(body)).encode("ascii")


def decode(line):
    text = line.decode("ascii")
    fields = text.split(",")
    if len(fields) != 3 or len(fields[1]) != 3 or not all("0" <= c <= "9" for c in fields[1]):
        raise ValueError("malformed fields")
    sequence = int(fields[1])
    expected = frame(fields[0], sequence)[:-1]
    if line != expected:
        raise ValueError("checksum or canonical-format mismatch")
    return {"kind": fields[0], "sequence": sequence}


class Lines:
    def __init__(self):
        self.reset()

    def reset(self):
        self.buffer = bytearray()
        self.discarding = False

    def feed(self, data):
        completed = []
        for byte in data:
            if byte == 10:
                if self.discarding:
                    completed.append({"error": "oversized line discarded"})
                elif self.buffer:
                    try:
                        completed.append(decode(bytes(self.buffer)))
                    except (ValueError, UnicodeError) as error:
                        completed.append({"error": str(error)})
                self.reset()
            elif not self.discarding:
                if len(self.buffer) >= 64:
                    self.buffer = bytearray()
                    self.discarding = True
                else:
                    self.buffer.append(byte)
        return completed


class Link:
    def __init__(self, uart, direction, sleep_us, sleep_ms, ticks_ms, ticks_diff, report=print):
        self.uart, self.direction = uart, direction
        self.sleep_us, self.sleep_ms = sleep_us, sleep_ms
        self.ticks_ms, self.ticks_diff, self.report = ticks_ms, ticks_diff, report
        self.lines, self.pending = Lines(), []
        direction.value(0)  # DE low and /RE low: listening.

    def send(self, kind, sequence):
        data = frame(kind, sequence)  # Validate before enabling the driver.
        self.direction.value(1)
        try:
            self.sleep_us(20)  # Device enable allowance; not a measured waveform.
            if self.uart.write(data) != len(data):
                raise OSError("partial UART write; frame unknown")
            self.uart.flush()  # RP2 waits through transmission, unlike write().
            self.sleep_us(20)
        finally:
            self.direction.value(0)  # Also release after write/flush error.

    def clear_receive(self):
        self.lines.reset()
        self.pending = []
        self.uart.read(256)  # RX buffer256 baseline; bounded one read, peer quiet.

    def receive(self, timeout_ms):
        if type(timeout_ms) is not int or not 1 <= timeout_ms <= 3000:
            raise ValueError("receive bound1..3000ms required")
        start = last = self.ticks_ms()
        for _ in range(MAX_RECEIVE_POLLS):
            now = self.ticks_ms()
            elapsed = self.ticks_diff(now, start)
            if self.ticks_diff(now, last) < 0 or elapsed < 0:
                self.lines.reset()
                self.pending = []
                raise OSError("receive clock moved backward or interval is ambiguous")
            last = now
            if elapsed >= timeout_ms:
                self.lines.reset()
                self.pending = []
                return None
            if self.pending:
                result = self.pending.pop(0)
                if "error" not in result:
                    return result
                self.report({"state": "FRAME_REJECTED", "reason": result["error"]})
            else:
                data = self.uart.read(32)
                if data:
                    self.pending = self.lines.feed(data)
                else:
                    self.sleep_ms(1)
        self.lines.reset()
        self.pending = []
        raise OSError("receive service budget exhausted; frame unknown")

    def exchange(self, sequence):
        frame("PING", sequence)  # Validate before clearing input or enabling output.
        self.clear_receive()
        self.send("PING", sequence)
        start = last = self.ticks_ms()
        for _ in range(MAX_EXCHANGE_ATTEMPTS):
            now = self.ticks_ms()
            elapsed = self.ticks_diff(now, start)
            if self.ticks_diff(now, last) < 0 or elapsed < 0:
                self.lines.reset()
                self.pending = []
                raise OSError("exchange clock moved backward or interval is ambiguous")
            last = now
            remaining = 1500 - elapsed
            if remaining <= 0:
                return {"state": "NO_MATCHING_REPLY", "sequence": sequence}
            reply = self.receive(remaining)
            if reply is None:
                return {"state": "NO_MATCHING_REPLY", "sequence": sequence}
            if reply == {"kind": "ACK", "sequence": sequence}:
                return {"state": "ACK_RECEIVED", "sequence": sequence}
            self.report({"state": "UNRELATED_FRAME", "frame": reply})
        self.lines.reset()
        self.pending = []
        raise OSError("exchange response budget exhausted; no reply accepted")

    def respond_once(self):
        request = self.receive(2000)
        if request is None:
            return {"state": "LISTEN_TIMEOUT"}
        if request["kind"] != "PING":
            return {"state": "IGNORED_NON_REQUEST"}
        self.sleep_us(TURNAROUND_US)
        self.send("ACK", request["sequence"])
        return {"state": "ACK_SENT", "sequence": request["sequence"]}


def main(role=ROLE):
    if role not in ("initiator", "responder"):
        raise ValueError("role must be initiator or responder")
    from machine import Pin, UART
    from time import sleep_us, sleep_ms, ticks_ms, ticks_diff
    direction = Pin(2, Pin.OUT, value=0)
    uart = UART(0, baudrate=BAUD, bits=8, parity=None, stop=1,
                tx=Pin(0), rx=Pin(1), timeout=20, timeout_char=3, rxbuf=256)
    link = Link(uart, direction, sleep_us, sleep_ms, ticks_ms, ticks_diff)
    sequence = 0
    try:
        while True:
            if role == "initiator":
                print(link.exchange(sequence))
                sequence = (sequence + 1) & 255
                sleep_ms(1000)
            else:
                print(link.respond_once())
    except (OSError, ValueError) as error:
        print({"state": "LINK_FAULT_STOPPED", "error": str(error)})
    except KeyboardInterrupt:
        print({"state": "STOPPED"})
    finally:
        direction.value(0)


if __name__ == "__main__":
    main()

A repeatable bench sequence

  1. With both supplies off, verify every adapter pin, capacitor, direction strap and terminator. Measure resistance across the unplugged pair and investigate an unexpected result before powering. Record cable type, length and the actual fixture.
  2. Power the two Picos, confirm local3.3V supplies and common ground, and start the single responder. Then start the single initiator. Record matching sequence results and timeouts, not just the presence of printed bytes.
  3. If an analyzer is available, observe GP2, UART transmit and receiver output using their common logic ground. Verify that driver release follows the final stop bit and that the two direction outputs do not overlap. A single-ended logic analyzer is not automatically a differential-line-voltage probe.
  4. For a missing-peer trial, switch both endpoints off, remove one endpoint and restart the remaining initiator. Expect NO_MATCHING_REPLY. A failsafe idle receiver does not generate an ACK.
  5. For corruption, partial writes and direction-cleanup faults, use the host injections. Do not start two real transmitters together or short powered wires to create a physical collision.
  6. Stop the program and confirm GP2 returns low with a meter or analyzer before changing wiring. A firmware printout alone is not an electrical measurement.
Challenge: UART.write returned12. Can GP2 immediately go low?

No. The bytes may still be in a transmit queue or hardware shifter. This RP2 program flushes the UART before release. Copying a fixed delay from another baud rate or another MicroPython port is not equivalent to qualifying the actual transmit-complete behavior.

Checks, limits and primary references

Earlier host tests checked every sequence for both packet types, a published CRC check vector, fragmentation, corruption, oversized-line recovery, incomplete-frame expiry, matching/stale replies, request-only response policy and release after write/flush failures. A separate nominal check covered termination resistance/power. The bounded-loop revision adds targeted actual-code regressions for frozen and backward clock observations, short timer wrap, unrelated-frame floods and cleanup after faults; the earlier broad test suite was not rerun for this revision. These tests have no analog line, edge rate, common-mode disturbance or physical collision. Keep their scope separate from any later owner bench observations.

The interactive lessons cover supply, resistor and digital-input foundations. This project adds a differential physical interface and a controlled turnaround protocol, rather than assuming that two UART wires alone form a qualified shared bus.

📡Broadcast the signal — amplify the connection.

Leave a Reply

Temu affiliate offers

Find your next electronics project

Explore these do-it-yourself project kits. Check the selected option, included parts and instructions on each offer.

Tricky Circuit may earn a commission if you buy through these Temu affiliate links. These are product ideas; they have not been bench-tested by Tricky Circuit and are not verified lesson parts lists.

Supplier photo of a breadboard, jumper wires and assorted electronic components in a plastic storage case.

Supplier product photo

Try breadboard experiments

Breadboard, wires and assorted parts. Arduino controller board not included.

View kit on Temu

Supplier photo of an assembled blue surface-mount soldering practice board with a circular ring of small lights.

Supplier product photo

Solder a chasing-light board

Surface-mount soldering practice. Battery and battery holder not included.

View kit on Temu

Supplier photo of an assembled two-wheeled line-following car with a blue circuit board, two motors and an empty battery holder.

Supplier product photo

Build a line-following car

Soldering and assembly required. Check battery and track requirements before buying.

View kit on Temu