NGHỆ THUẬT
LÀM ĐẸP VÀ SỨC KHỎE
THỦ CÔNG
VĂN HÓA VÀ LỊCH SỬ
GIẢI TRÍ
MÔI TRƯỜNG
THỰC PHẨM VÀ ĐỒ UỐNG
KỸ THUẬT NGƯỢC
KHOA HỌC
THỂ THAO
CÔNG NGHỆ
THIẾT BỊ ĐEO

The UART and Start-Stop Framing
Two machines, one wire, and no shared clock. That is the whole problem, and everything else in this batch is built on the answer to it.
A human telegraphist needed no convention: Morse has rhythm, and a listener locks onto it without being told. A machine has an oscillator that is a percent or two off, drifting with temperature, and it cannot hear rhythm. It needs to be told exactly when a character starts.
The answer came from teleprinters and it is almost embarrassingly simple. Hold the line at MARK when idle. Drop it to SPACE for exactly one bit time — that is the start bit, and its falling edge is the only timing reference in the entire system. Send the data bits, least significant first. Then return to MARK for at least one bit time, the stop bit, so the line is guaranteed back at idle and the next falling edge is unambiguous.
It costs two bits in every ten, a flat twenty percent, and it buys a clock tolerance of about five percent split between the two ends — which a cheap RC oscillator can hold. That trade is the whole design. Resynchronise often and you may use a bad clock; resynchronise rarely and you need a crystal, which is the road that leads to Ethernet's preamble seven blueprints later.
FULLY BUILDABLE. Bit-bang a frame, look at it on a scope, then walk the receiver's baud rate off by a percent at a time and find where it breaks. The stop bit fails before the data does, every time, and that is not a coincidence — it is the last bit sampled and it carries the most accumulated error.
Cơ bản
3 hours
Hướng dẫn
1
1
Where the framing came from
Where the framing came from
Work the Baudot blueprint first. It gives you the fixed-length character code — five bits, always five, unlike Morse's variable lengths — that makes machine reception possible at all.
What Baudot does NOT settle is when a character begins. A teleprinter's mechanism solved it with a start pulse that released a rotating distributor and a longer stop pulse that let it come to rest, which is where the odd 1.5-bit stop length comes from.
The UART is that mechanism in silicon: same start bit, same idle-at-mark, same least-significant-bit-first order. Nothing was invented. It was electrified.
2
2
Bit-bang a frame and break it deliberately
Bit-bang a frame and break it deliberately
Join GPIO17 to GPIO16 with one jumper and flash the sketch. GPIO17 is the ESP32's hardware UART transmitting at 9600 baud; GPIO16 is a receiver written in software, whose baud rate the sketch walks from ten percent slow to ten percent fast. Put the scope on GPIO17 first and send 0x55: alternating bits give the clearest possible picture of the frame, and you can measure one bit time directly with the cursors.
Then let the sweep run. At each step it counts how many bytes arrived correctly, how many raised a FRAMING error, how many arrived as the wrong value, and how many never arrived. The receiver samples every bit at (0.5 + k) of its own bit time after the start edge, so the error accumulates and the stop bit is the first sample to land in the wrong place, at a little over 5 %. Which symptom that produces depends on the direction. Receiver FAST: the stop sample lands on the last data bit, and whenever that bit is 0 you get a framing error, before any wrong data. Receiver SLOW: the stop sample lands late, on the idle mark between bytes, which is high, so it passes; the first failures are wrong data instead.
An exact model of the sample points, with the sketch's five bytes, predicts all five correct from -5 % to +5 %; at +6 % three framing errors (0x55, 0x00, 0x41, whose last data bit is 0); at -6 % three wrong bytes and no framing errors. The sketch was compiled for the ESP32 with the Arduino ESP32 core 3.3.12. An earlier version bit-banged the transmitter too; being single-threaded, it finished each byte before the receiver started listening, so every byte failed.
bitbang_uart.inocpp
Vật liệu cho bước này:
Bộ dây nối1 cáiCông cụ cần thiết:
Bo mạch phát triển ESP32
Máy hiện sóng số
Máy tính để bàn
Breadboard - Classic3
3
The line driver and the null modem
The line driver and the null modem
Build the line-driver stage if you want to talk to anything with a nine-pin D connector. Use a MAX3232, not a MAX232: the ESP32 is a 3.3 V part and its inputs are not 5 V tolerant, while a MAX232 needs 5 V and its receiver output would drive 5 V into the ESP32's RX pin. The MAX3232 runs from the ESP32's 3.3 V and has the same pinout.
It does two jobs: it INVERTS, because RS-232's mark is negative, and its charge pump makes the drivers swing about plus and minus 5.4 V (at least 5 V into 3 kilohms) from the single 3.3 V supply. At 3.3 V the datasheet's charge-pump capacitors C1 to C4 are all 0.1 uF, plus a 0.1 uF bypass on VCC. Ceramic capacitors are fine; if you use polarised ones, fit them the way the datasheet shows. The unused driver input is tied low, because the datasheet requires every driver input at a valid logic level.
Test it before it meets anything else: bridge pins 2 and 3 of the D connector and run the step-2 sketch with GPIO17 on T1IN and GPIO16 on R1OUT. The bytes now make the round trip through RS-232 levels.
Then read the crossover. The connector here is wired as a terminal: it transmits on pin 3, receives on pin 2 and grounds on pin 5. RS-232 assumed a terminal talking to a modem, so transmit and receive are named from opposite ends and a straight cable works. Two computers are both terminals, both transmit on pin 3, and neither hears anything, which is why the null-modem cable, crossing 2 and 3, had to be invented and had to have a name.
Đang tải trình xem KiCanvas...
Trình xem thiết kế PCB chuyên nghiệp
Vật liệu cho bước này:
Vi mạch dịch mức MAX32321 cái
Bộ tụ điện1 cái
Đầu nối DB91 cáiCông cụ cần thiết:
Breadboard - Classic
Bộ dây nối
Đồng hồ vạn năng số cấp phòng thí nghiệm
Máy hiện sóng số4
4
Clock tolerance and the awkward crystal
Clock tolerance and the awkward crystal
Đang tải sổ tay Jupyter…
Công cụ cần thiết:
Máy tính để bàn5
5
Compendium: the cost of having no clock
Compendium: the cost of having no clock
THE TRADE, IN ONE LINE. Two framing bits per eight data bits is twenty percent of the wire spent on saying nothing, and it buys a five percent clock tolerance. Every synchronous protocol after this one spends less on framing and demands a better clock: Ethernet's preamble is 64 bits ONCE per frame rather than two bits per byte, which is far cheaper for a 1500-byte frame and impossible without a crystal.
BREAK, AND WHY IDLE IS MARK. Holding the line at SPACE for longer than a whole frame is a BREAK condition — impossible in normal traffic, because a stop bit must always arrive. It is a signal outside the alphabet, and it exists precisely because idle is mark: a cut wire with a pull-up reads as idle, while a shorted one reads as a permanent break. The choice of which state is idle is what makes those two faults distinguishable.
AGAINST THE DISC. Blueprint 90-3's MFM code solves the same problem — a receiver with no clock — and solves it oppositely, by constraining the DATA so transitions can never be far apart. That works on a disc because the medium is yours to encode. On a wire shared with other equipment you cannot constrain what the other end sends, so you add framing around arbitrary data instead. Same problem, and the answer depends entirely on whether you own the alphabet.
Vật liệu
4- 1 cáiTạm thời
- Tạm thời
- 1 cáiTạm thời
- 1 cáiTạm thời
Công cụ yêu cầu
6- Tạm thời
- Máy hiện sóng sốHoa hồng 10%Magento Legacy Storeships internationallyTạm thời
- Tạm thời
- Breadboard - ClassicHoa hồng 10%$9.43
- Tạm thời
Blueprint liên quan
Các blueprint này chia sẻ kiến thức — kỹ thuật, vật liệu hoặc nguyên tắc
CC0 Phạm vi công cộng
Bản thiết kế này được phát hành theo CC0. Bạn tự do sao chép, sửa đổi, phân phối và sử dụng cho bất kỳ mục đích nào mà không cần xin phép.
Hỗ trợ nhà sáng tạo bằng cách mua sản phẩm qua bản thiết kế, nơi họ nhận Hoa hồng nhà sáng tạo do nhà bán hàng đặt, hoặc tạo phiên bản mới và kết nối trong bản thiết kế riêng để chia sẻ doanh thu.



