PinerdF
Posts: 21
Joined: Wed Sep 30, 2015 8:23 am

Speed up Refresh / Readout Rate of DS2482

Tue Feb 21, 2017 7:21 pm

Hey there, I'm currently working on the project with a lot of DS18B20 Digital Thermometer Sensors. In the current setup all sensors are connected to the GPIO4 (default 1-wire pin) in parallel. Everything works great. By using the python threading library the system is capable of reading the temperature values of all sensors within 16 seconds.

In order to decrease the timing and increase reliability of the system I decided to use this Raspberry Pi compatible 1-wire master board, which is based on the DS2482-800 IC with 8 individual 1-wire channels. Since Raspberry Pi has just one 1-wire channel and the DS2482 chip speaks via I2C protocol to the Raspberry Pi, I'm hoping to read out the temperature data faster.

I was following this tutorial in order to get the owfs running. Typing:

Code: Select all

sudo /opt/owfs/bin/owfs --i2c=ALL:ALL --allow_other /mnt/1wire/ 
I'm able to read the temperature value via:

Code: Select all

cat /mnt/1wire/28.6613DA050000/temperature
which outputs me the temperature '23.5' of the sensor 28.6613DA050000. Repeating this cat command for a few times leads always to the same temperature value of 23.5, even if I heat up the sensor with my hand. After about 15 seconds of repeating the cat command, the command line stucks for a second and then finally outputs the updated value which is recognizable higher.

The same behavior is observed by reading the temperature via the owserver. First I start the owserver like:

Code: Select all

sudo /opt/owfs/bin/owserver -c /etc/owfs.conf --pid-file /var/run/owfs/owserver.pid

then I cd in folder /mnt/1wire/ read the sensors temperature values by:

Code: Select all

owread 28.6613DA050000/temperature; echo
which outputs the temperature value just fine. Repeating this command will again take about 15 seconds until the temperature finally jumps to the updated value.

I know this is not a problem of the sensors, since I already managed to readout the values of single sensors much faster.
Does anybody know how to boost the 'refresh / readout' rate of the DS2482, in order to achieve a higher time resolution? Or am I missing something? Should I prefer talking I2C to the DS2482 directly? If so, how?

Any help is welcome :)

maurice1
Posts: 37
Joined: Tue Mar 05, 2013 8:55 am
Location: Dublin

Re: Speed up Refresh / Readout Rate of DS2482

Thu Feb 23, 2017 4:28 pm

Interesting idea, never knew of DS2482-800 IC

I just use php for about 18 DS1820b attached to GPIO4 with 2 resistors in parallel maybe 20 metres away from my pi.

I use a php webpage and

Code: Select all

$flow    = file_get_contents('/sys/devices/w1_bus_master1/28-0000034660e5/w1_slave');
$outside = file_get_contents('/sys/devices/w1_bus_master1/28-000002ee8c95/w1_slave');
$Dining  = file_get_contents('/sys/devices/w1_bus_master1/28-000003463cf9/w1_slave');
$Kitchen = file_get_contents('/sys/devices/w1_bus_master1/28-0000034633d1/w1_slave');
$Lounge  = file_get_contents('/sys/devices/w1_bus_master1/28-00000346679f/w1_slave');
$Hall    = file_get_contents('/sys/devices/w1_bus_master1/28-0000034780b9/w1_slave');
$Morning = file_get_contents('/sys/devices/w1_bus_master1/28-000461041bff/w1_slave');
$Bed     = file_get_contents('/sys/devices/w1_bus_master1/28-0004610770ff/w1_slave');
$Priest  = file_get_contents('/sys/devices/w1_bus_master1/28-000006c4b0a0/w1_slave');
Takes around 7 seconds to get webpage up for the 9 x DS1820b.
The webpage also has to figure out the state of 7 actuators outputs and 3 thermostat inputs attached to a MCP23017.
When you say a lot how many? 100s

d_older
Posts: 118
Joined: Mon Jun 25, 2012 5:04 pm
Location: East Yorkshire, UK

Re: Speed up Refresh / Readout Rate of DS2482

Fri Feb 24, 2017 12:20 am

Hi PinerdF,

The OWFS system by default caches all readings for about 15 seconds - so that multiple accesses from different machines (one owserver - many clients) don't swamp the 1-wire bus. There are uncached/unbuffered directories under /mnt/1-wire/ (not quite sure whether they're under each sensor or under /mnt/1-wire - I'm 300 miles away from my home monitor pi - I'll try to remember to look when I get home tomorrow) which force a new reading on every access.
This is not an issue I have as I only poll my sensors every 5 minutes.


If you don't need the full resolution (0.75 seconds per reading) then reading the lower bit entries in the directory return much faster.

There is a way of initiating all sensor temperature conversions and then - say after 1 second - reading all the results in quick sucession - I've never done that but searching should give a solution - although I don't think OWFS can use that technique.


Hope this helps,

Dave

PinerdF
Posts: 21
Joined: Wed Sep 30, 2015 8:23 am

Re: Speed up Refresh / Readout Rate of DS2482

Wed Mar 01, 2017 9:04 am

I'm having 176 sensors, all connected in parallel to the one and only 1-wire pin GPIO4 of Raspberry Pi 3. It is arranged in a star topology with four branches, each with 44 sensors. The readout is done in about 16 seconds, as I mentioned. The only thing which appears to be different to all tutorials I found online: I using a very low pullup-resistor. Using the 4.7kOhm or even 1kOhm as suggested by almost everybody out there will not work for networks like this big. I changed the resistor to be 270 Ohm. Maybe somebody can explain if this is either critical or briliant :) So far I can tell the system is running stable for 4 weeks collecting data without any error.

Now the new setup using the DS2482-800:

I managed to set the default time caching of the OWFS to 0 by passing --timeout_volatile=0 when starting the owfs, like so:

Code: Select all

sudo /opt/owfs/bin/owfs --i2c=/dev/i2c-1 --allow_other /mnt/1wire/ --timeout_volatile=0
or adding it to the /etc/owfs.config like:

Code: Select all

timeout_volatile = 0
Doing this makes sure, that all temperature values are new and not just some old cached values. (You can test this by having a while loop reading just one sensor each second. Take the sensor between your fingers and you will see the rising temperature every second.)

Since I did not manage to get the [url:http://owfs.sourceforge.net/owpython.html]owfs python binding[/url] running I decided to use pyownet. Once your owfsserver is running pyownet works very well. Using a modified version the provided python example from github called 'scan.py' it is possible to time the readout. Like described in the datasheet of the DS18B20 sensors it takes 750ms to readout the temperature of one sensor (in the highest resolution, which I need for my project). So I maned to readout 4 sensors in about 3 seconds, having them all connected to just one bus of the DS2482. Sadly my plan of decreasing the time consumption by using multiple buses did not work out. Connecting the 4 sensors to two buses (2 each) I still have the same readout time of about 3 seconds. This leads to the assumption that the DS2482 is not capable of reading multiple buses simultaneously, even though owfs server documentary tells "owserver (1) is by default multithreaded".

This issue leads to the first question:
How is it possible to readout the buses in parallel?
I know there is something like "reading out simultaneously" by writing a "1" to the "simultaneous/temperature" register, like described here, but I did not managed to get this working. How exactly do I write a "1" to the mentioned register?

An additional question is about the maximum number of sensors connected:
So far the DS2482-800 is not capable of reading out 44 sensors on one single bus. As described in the datasheet it comes with an active pullup resistor and does not tell anything about limitations in the matter of maximum number of connected sensors. Any suggestions about this problem?

Thanks for reading and taking the time ;) All help is appreciated!

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