Near Field Notes

Videos

The notes, in motion

One video per topic, newest first. Point at a card for a silent preview.The card in the middle of the screen plays a silent preview. Open one to watch it whole.

41 videos, 41 with a note to read after.

2:52 · With sound

1-Wire

How does a sensor run on just ground and data?

Read Note 38

Transcript

This sensor has two wires. Ground and data.

No power wire. It runs on its data line.

Here's how that works, why it sometimes reads exactly 85 degrees, and where the same bus hides in a MacBook charger.

The bus is called 1-Wire. Dallas Semiconductor patented it in 1989.

One line, held high by a resistor. The master or any chip can pull it low.

Every bit starts with the master pulling low. A short pulse is a one. A long pulse is a zero.

To read, the master pulls low for an instant and lets go. The chip holds the line down for a zero.

That's about 15 kilobits a second.

Now the power. Inside the chip, a diode leads from the data pin to a tiny capacitor.

While the line is high, the capacitor charges. While it's low, the chip runs on the capacitor.

Asleep, the chip draws under a microamp. A half-millisecond reset pulse costs the capacitor about half a volt.

The maker calls this parasite power.

Then you ask for a temperature.

A conversion takes up to 750 milliseconds, and up to 1.5 milliamps.

On a 3.3 volt board, a 4.7k pull-up can deliver 64 microamps before the pin falls below the chip's 3 volt minimum.

I simulated it. The pin is under 3 volts within microseconds, and it stays there.

If the chip resets, it wakes up with 85 degrees in its temperature register. Read it back, and that's your reading.

That's one classic cause of the 85 degree bug. Reading too early is another.

The fix is in the datasheet. Within 10 microseconds of the command, bypass the resistor and hold the line hard high.

A FET does it. So does the master's own pin, driven high. In the sim, the pin holds at 3.24 volts.

Arduino's library does this for you. That's why it works for some people and not for others.

Put ten of these on one line. How does the master tell them apart?

Every chip has a 64-bit ID, set at the factory.

The master asks for bit one. Every chip answers at once: its bit, then the opposite.

If both come back zero, the chips disagree. The master picks a side, and the others go quiet.

64 bits later, one chip is left. Then it starts over and takes the other branches.

One pass takes 13 milliseconds. That's 75 chips a second.

This bus is in a lot of things.

The plug of a MagSafe charger has a 1-Wire chip. The Mac reads the charger's wattage from it, and sets the LED color through it.

A Dell laptop adapter has one on the center pin. It holds plain text: Dell, 90 watts, 19.5 volts.

If the laptop can't read it, it won't charge the battery, and it slows the CPU.

These steel buttons are door keys. The lid is data, the can is ground. Maxim says there are over 350 million.

And Stratasys 3D-printer cartridges use one to store how much material is left.

The catch is distance. Cable adds capacitance, and the resistor has to charge all of it in 9 microseconds.

With 4.7k, that runs out near 60 meters. With 1k, near 300.

All of it over two wires.