The Sensor Is Fine. The Board Cannot Understand It
There Are No Bits Inside the File
In one line
A capture file is just a list of voltages. The bits are not in it; they come into being at the moment you decide on a threshold and a time axis.
Why this was needed
There is a sentence heard most often in the field. "The sensor is fine, but the board can't understand it." That this sentence came out means both sides have already been tested separately. Attach the sensor to another board and it reads; attach another sensor to the board and it reads. But connect the two and it doesn't work. What's left is the wire between them, and what happens on a wire does not come out of calculation. You have to measure.
After measuring, what you hold is not a picture but a table of numbers. Whether it is a logic analyzer or an oscilloscope, what comes out when you press the save button is a listing of "at which sample this line was how many volts". This course deals with that table. The job is to turn the table into bits, the bits into bytes, and the bytes into a sentence saying "what went wrong".
The mistake beginners make most often here is to believe that the 1010... shown by a waveform viewer is contained in the file. It is not. The tool picked a threshold, picked a time axis, and produced it from those two choices. If the choices are wrong, the same file gives a different answer. And the tool does not bother to tell you what it chose.
How it works
One sample is a pair of a time and a voltage. The time is usually not written in the file and is calculated from the header's sample rate and the sample number. Sample 312 of a file captured at 500 kHz is at 312 ÷ 500,000 = 624 µs. If you cannot read the sample rate, there is no time axis, and without a time axis you can measure neither the baud rate nor the clock period.
# labhub-capture v1
# sample_rate_hz=500000
# channels=rx
n,rx_v
310,3.30
311,3.29
312,2.36 <- 여기서 내려가기 시작한다
313,1.48 <- 1.65 V 로 보면 여기가 모서리
314,0.94
What turns a voltage into a bit is the threshold. With 1.65 V (half the supply voltage), sample 313 is the falling edge, and with 2.90 V, sample 312 is the falling edge. If the edge were infinitely steep the two would be the same, but a real line has capacitance, so the voltage moves exponentially. So the higher the threshold, the earlier the fall is caught and the later the rise. In this course's normal UART capture, the rising edges of the two thresholds are off by 4 samples, 8 µs.
One important fact here. The receiving chip does not decide at half voltage. The datasheet lists VIH (the minimum voltage it reads as a definite 1) and VIL (the maximum voltage it reads as a definite 0) separately, and in between is a range that is not guaranteed. So even if your decoder says "the data is fine", the real chip may not be able to read it. A decoder that uses only one threshold structurally cannot see this difference.
The partner on the time-axis side is the sample rate. How many samples fit in one bit is the margin for reading. If there is only one sample per bit, you know the position of the start edge only to the nearest sample, and that error accumulates to the end of the frame. If you thin out the samples and read the same file again, you can see with your own eyes at which point the reading quietly starts to go wrong. The word "quietly" matters. A decoder with too few samples does not raise an error; it produces a plausible different character.
There is a third choice too. Which column is which line. Even if the header says channels=scl,sda, that is only the order in which the person who measured plugged in the probes. If you read the two columns swapped, the clock becomes data and the data becomes the clock. So before trusting the names, first look at whether one column goes up and down regularly. A clock is regular and data is not.
What it looks like in the field
Often people get a capture file, say "the tool can't read anything", and go off to measure again. Usually there is no need to measure again. Either the tool's threshold does not match the signal's amplitude (for example, using a 5 V reference on a 3.3 V signal), or the sample rate the tool used is too low compared with the communication speed. Just opening the file yourself and looking at the minimum and maximum voltage of the first 100 lines rules out half of the cases.
There are accidents in the opposite direction too. Because the tool shows a clean 1010, you reported "the signal is normal", yet the real board still cannot read it. That is because the tool decided at half voltage and the chip decided at VIH. What you need then is not a new instrument but to change the decision criterion and read the same file once more. If the answer differs when you change the criterion, that in itself is the conclusion — it means the signal has no margin.
The third most common is judging the file by eye alone. If there are thousands of sample lines, what a person can look at is only the first and last few dozen lines, and the fault is usually in the middle. This is why this course has you write a program from the start — you must be able to sweep the whole thing at once and repeat the same judgment exactly, any number of times. A number counted by hand cannot be checked by the next person.
What to check in the next quiz
It asks how to find the time from a sample number, which way the rising and falling edges each move when you raise the threshold, and in what manner things fail when the number of samples per bit shrinks. After that, in the UART module, you actually turn this table into bytes.