User avatar
DougieLawson
Posts: 36578
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: kernel patch for Dallas 1-wire interface

Tue Sep 09, 2014 6:49 pm

Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

r0binFR
Posts: 8
Joined: Wed Jan 21, 2015 4:31 pm

Re: kernel patch for Dallas 1-wire interface

Wed Jan 21, 2015 4:48 pm

wikily wrote:
stephelton wrote:When I've worked with the w1 interface before (in my Arduino days) I was able to get some extremely high performance out of the 5+ temperature probes I was using compared to the performance I get when I use this kernel module.

First, a command like "cat /sys/bus/w1/devices/28-000001d169fe/w1_slave" takes about 0.8 seconds. I assume this is because the command causes the master to (1) address the probe, (2) tell it to take a sample, and (3) get that sample after the required time has elapsed (750ms IIRC).

When I was using numerous probes, I would do something more like the following:

(1) for each probe, (a) address the probe, (b) tell it to take a temperature sample
(2) wait the required time (depends on the desired precision, I stuck with 750ms)
(3) for each probe, (a) address the probe, (b) ask the temperature

The advantage to this should be pretty clear -- in under a second, I was able to address every single probe and obtain a temperature reading with full precision.

Unless I'm missing something, this kernel module won't support that -- I need to patiently wait for every single temperature probe I have. If I'm not missing anything, any ideas for improving this? I'll be glad to help out with some programming.

Second, the desired precision affects the necessary wait time. At very low precision, a temperature probe could be read extremely quickly (something on the order of 100ms, IIRC). For some applications, this could be very desirable.

Here's a table I copied from http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf

Resolution / Max Conversion Time
9 bits : 93.75 ms
10 bits : 187.5 ms
11 bits : 375 ms
12 bits : 750 ms

With my technique described above and 9 bit precision, you could get a LOT of data from these things.
Any luck with this.... also, how do I go about changing the resolution. I'm thinking this will involve some C level programming ?

Regards,
a bit late, but i may have a lead for those interested:
you need to write in the register of your temperature sensor the resolution you need.
On DS 18B20, it's byte n°5 of the RAM, see this document (french) page 5:
http://daniel.menesplier.free.fr/Doc/BUS%201%20WIRE.pdf

That would mean modify the linux w1 therm module:
linux/drivers/wi/slaves/w1_therm.c
and call a "write" command with the suitable byte to configure at initialization time, or before the read
i don't have this chipset so i cannot help more

Hope that helps anyway
Rgds

x29a
Posts: 1
Joined: Sat Apr 30, 2016 4:25 pm

Re: kernel patch for Dallas 1-wire interface

Sat Apr 30, 2016 4:29 pm

Actually, there is a kernel patch waiting for beeing accepted:

https://lkml.org/lkml/2016/4/16/174

With that patch, it will be possible to write 9 to 12 to the w1_slave device to change the precision (SRAM). Also, writing 0 to the w1_slave file will save the precision permanently (EEPROM).

The according changes can be seen in the pull request:

https://github.com/raspberrypi/linux/pull/1413

So fetch it from there and rebuild the module if you want to try it out.

The reading of the temp is still stuck at 750ms, but feel free to improve that part as well.

Return to “Interfacing (DSI, CSI, I2C, etc.)”