Once every 22 ms · 07 of 10

Once every 22 ms

The chip sleeps most of the time. About every 22 ms it wakes for 50 µs, looks at the field, sets its output, and sleeps again. So SIGNAL can change up to 22 ms after the magnet arrives, and a magnet that is in range for less than that can pass unseen.

Brief glances

The CC6201 is a micropower part, built for battery equipment. To keep its average current down to about 5 µA it spends 99.8 % of its time asleep. Its datasheet gives the cycle: awake for about 50 µs, then asleep until the next scan, about 22 ms after the last. That is roughly 45 looks a second.

Each time it wakes it measures the field, compares it with its thresholds, sets its output, and goes back to sleep. Between looks, the output holds. The datasheet's word for that is a latch, which is where the old page's idea that this is a latching sensor came from.

Once every 22 ms
The magnet is in range for
In range
10 ms
Scan period
22 ms, typical
Seen
No magnet yet. The chip wakes on each tick, finds nothing, and goes back to sleep. SIGNAL holds HIGH between ticks.

What it costs

Run the figure with each of the three passes:

  • 100 ms in range. Seen, but not at once: SIGNAL went LOW at the first look after the magnet arrived, 20 ms after it did here, and went back HIGH at the first look after it left. Any pass of a whole period or longer is always seen, up to one period late at each end.
  • 30 ms in range. Seen the same way, and held LOW after the magnet had gone.
  • 10 ms in range. Not seen at all. The magnet arrived just after one look and left before the next. With a different timing it might have been caught; the point is that nothing guarantees it.

The timing in the figure is illustrative. On a real chip the looks fall wherever they fall, and the 22 ms is a typical figure with no maximum given.

What that means for a project

A door, a lid, a drawer, a tray going back into a printer: the magnet stays put for seconds, and 22 ms of delay is nothing. That is the job this chip was made for.

A magnet flicking past on a fast wheel, a fan blade, or a motor shaft is a different job. Each pass may be shorter than one look apart, and the counter misses turns without any sign that it did. Counting turns works out where the line is. The page this book replaced called this block "the basis of every wheel-speed counter". For a slow wheel, yes. For a fast one, it needs a sensor that does not sleep.

When it does not work

Will reading the pin faster help?

No. The chip only updates SIGNAL when it wakes, and holds it in between. A loop that reads the pin a million times a second sees the same level every time until the next look. The limit is in the chip, not in your sketch.

Would an interrupt catch the fast passes?

No. An interrupt fires when SIGNAL changes, and SIGNAL only changes when the chip looks. A pass that falls between two looks never changes SIGNAL, so there is nothing for an interrupt to catch.

Why does it sleep at all?

To save power. Awake it draws about 2 mA; asleep, about 3 µA. Awake for 50 µs in every 22 ms, it averages about 5 µA, which a battery-powered door sensor can afford for years. The LED on this board draws far more whenever it is lit.

Is 22 ms exact?

No. The datasheet gives it as a typical value at 3.5 V with no maximum, and plots the scan rate changing with the supply voltage. Treat it as about 22 ms, and design with room to spare.

Where this goes next

One magnet on a wheel, a counter, and how fast the wheel can go before it starts missing turns.

Counting turns

Edit this page — content/books/hall-effect-sensor/once-every-22-ms.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Hall Effect Sensor

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum