-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
70 lines (52 loc) · 2.57 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
This is early work -- Just getting started.
The intent is to produce a library designed to read many OneWire Temperature
sensors (e.g. DS18B20, DS18S20, etc.) reliably and as quickly as possible.
Further, the intenet is to provide more complete documentation of the library
than is present in the others I've found.
Tricks used for speeding up the library:
1. Tell all the sensors to start converting at the same time.
2. Wait for all of them to finish at the same time.
There's no way to monitor a single temperature
sensor after you've reset the bus. This is an
artifact of the OneWire protocol. However, we can
tell all the sensors to start converting and if
we wait without resetting the bus, the bus will
not start responding with 1s until ALL of the
devices have finished their conversion.
It would be nice if we could iterate through
the devices and check for a ready result, but
that's not possible with OneWire.
3. Store the last received scratchpad, temperature, and
a timestamp (millis) for each sensor we track. If a
read request is issued for a particular sensor and the
data is less than 2000 millis old, just return what we
already have.
4. Anytime a conversion request is made, initiate
conversions on ALL devices.
5. If a read request comes in after a conversion request
was made, finish waiting for all conversion requests
to complete prior to performing the read. (This makes
the library relatively safe, but does reduce speed in
some less likely applications)
6. Record the timestamp of each conversion request. Any
request for conversion less than 2000 millis later
will return immediately. It will not affect the
devices.
7. If the last conversion request has been waited on,
mark it wait_complete. (Don't wait again for the
same conversion)
8. If the bus is reset prior to waiting on conversion
(shouldn't happen), mark the conversion status as
wait_maxtime. (maxtime is 750ms according to the
datasheet, but allow 760). Any subsequent fetch will
result in a delay until now-timestamp > 760. An extra
10 ms one-time (not per sensor) is relatively harmless.
(we could further optimize since we have the data and
track max resolution and optimize this timer based on
the maximum resolution currently in use).
9. In order to optimize for speed, we don't worry about
bus power density being kept for parasitic power.
DO NOT USE parasitic power with this library.
(For one thing, parasitic power is generally completely
inadequate for powering multiple sensors performing
simultaneous conversion).