rickrack
Posts: 10
Joined: Mon Jan 08, 2018 2:29 pm

Re: 1-wire DS18B20 disappears

Mon Jan 15, 2018 2:10 pm

jenscollin wrote:
rickrack wrote:
Mon Jan 15, 2018 9:45 am
...
The sensors are working now fine again.

I think with turning of the dtoverlay we had an power reset of the sensors. Like described in my third setup earlier.
So I am not sure if the BitBang is the solution.
Did you powercycle the raspberry or the command reboot? This does the hole difference for me. A reboot by cutting power 30 seconds solves the issue, a software reboot (setting the dtoverlay on/off) does not help.
No I just rebooted by software command. Cutting power solves the issue in my case too.

Made a mistake in my post beforde. There was no power reset of the sensors.
By removing the dtoverlay, the 1-Wire Pin returns to be a normal GPIO Pin with the Mode IN by default.
I thought this caused the sensors to be powerless, but the GPIO is just the signal wire. The power still comes from the 5v Pin.

Then it could be a software issue.

have "broken" setup here and a scope, I can check the signal and compare it to yours.

danjperron
Posts: 2852
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: 1-wire DS18B20 disappears

Mon Jan 15, 2018 4:17 pm

If you have a scope, check the rise signal. the signal should change from low to high in less than 15 us max. The bitbanging ask for 13 us.

Is it possible that water has been leaking into the cable or a power cable is now located near the sensor cable. A heating device maybe?

Did you try to isolate one sensor and see if they all work alone?

It is possible to change the read bit delay. Originally the read bit uses 2 usec. On the python version it is set to 13 us. You should be able to increase it up to 15 usec. Function readBit() and readByte()

rickrack
Posts: 10
Joined: Mon Jan 08, 2018 2:29 pm

Re: 1-wire DS18B20 disappears

Mon Jan 15, 2018 4:35 pm

danjperron wrote:
Mon Jan 15, 2018 4:17 pm
If you have a scope, check the rise signal. the signal should change from low to high in less than 15 us max. The bitbanging ask for 13 us.
I gonna check that.
danjperron wrote:
Mon Jan 15, 2018 4:17 pm
Is it possible that water has been leaking into the cable or a power cable is now located near the sensor cable. A heating device maybe?

Did you try to isolate one sensor and see if they all work alone?
I am sure its not a hardware issue of the sensor. I tried different Raspberrrys with different 1-Wire Sensors and got the same result.
The only constant is the software. They we're created from the same image.

danjperron
Posts: 2852
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: 1-wire DS18B20 disappears

Mon Jan 15, 2018 5:08 pm

I tried different Raspberrrys with different 1-Wire Sensors and got the same result.
I never had issue with the 1-wire driver. I ran my first PI-B for three years outside to control my pond heater and it was working with five DS18B20. Winter in Canada is quite cold! It is -20C today in Montréal.


I hope that you are using 3.3V and not 5V like you said in one of the post.

jenscollin
Posts: 17
Joined: Sat Dec 31, 2016 11:26 am

Re: 1-wire DS18B20 disappears

Mon Jan 15, 2018 8:37 pm

I'm using 5V on mine with the divider-resistor part to 3.3V. The values to the gpio is never above 3.3V.
Any other obvious reason I shouldn't have done that? It was some time ago, but I remember putting som serious looking into it before applying.

Are there any other factors I can change to get temperature readings instead of "None" in addition to the 2->13us change?
(I'll check the rising times tomorrow)

danjperron
Posts: 2852
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: 1-wire DS18B20 disappears

Mon Jan 15, 2018 9:12 pm

I'm using 5V on mine with the divider-resistor part to 3.3V.
What kind of divider resistor. how big are your resistors.

You know that a resistor divider could be reduce by thevenin theorem. You will get 3.3V but you add a resistor in series and this could be your problem. Is the resistor divider only on the power pin or you have the same thing on the data pin.

Do you have a small schematic of your setup?

User avatar
rpdom
Posts: 12397
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: 1-wire DS18B20 disappears

Mon Jan 15, 2018 9:40 pm

danjperron wrote:
Mon Jan 15, 2018 9:12 pm
What kind of divider resistor. how big are your resistors.

You know that a resistor divider could be reduce by thevenin theorem. You will get 3.3V but you add a resistor in series and this could be your problem. Is the resistor divider only on the power pin or you have the same thing on the data pin.
I'm guessing not a resistor divider, but just the pull-up resistor.

The data-pin of the DS18B20 is equivalent to open collector, so you can feed the VCC with 5V and use a 4K7 pull up on data to 3.3V and it will be perfectly happy.

danjperron
Posts: 2852
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: 1-wire DS18B20 disappears

Mon Jan 15, 2018 10:37 pm

The data-pin of the DS18B20 is equivalent to open collector, so you can feed the VCC with 5V and use a 4K7 pull up on data to 3.3V and it will be perfectly happy
Yes indeed!

I don't think this what jenscollin does! The DS18B20 could sink up to 4 ma and it requires up to 1.5 ma to do a conversion.

rickrack
Posts: 10
Joined: Mon Jan 08, 2018 2:29 pm

Re: 1-wire DS18B20 disappears

Tue Jan 16, 2018 8:35 am

Right now I am using the 5v Pin. But had the issue with the 3,3V too.

jenscollin
Posts: 17
Joined: Sat Dec 31, 2016 11:26 am

Re: 1-wire DS18B20 disappears

Tue Jan 16, 2018 6:39 pm

You are right, It's a pull-up of 10K, not a voltage divider. I did some serious research and moved to 10k from previous 4k7 but I can't for my life figure out why I did go up in size instead of down to a 2-3K. Must have been a brain-slip...

I've attached the schematic that I'm using which I beleive is correct. (Not visible in the schematic is the mosfet working as a low-side switch)

I did a couple of measurements with just one sensor connected (0.5m cable) as well as with 4 sensors on 3m cable.
Assuming that the rise trigger level on rpi 3.3V pin is abot 2.2-2.5V I'd say that my rise time is somewhere between 8-15us if I'm measuring the right place. I understand it must be less than 14 right?

i still have the issue that the kernel driver can read sensor values but the bit-banger can't. I'll test with the timing suggestions mentioned and get back to you. I'm running a pi3, can that make a difference?

Regards,
JEns
Attachments
schematic1.PNG
schematic1
schematic1.PNG (14.86 KiB) Viewed 874 times

User avatar
rpdom
Posts: 12397
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: 1-wire DS18B20 disappears

Tue Jan 16, 2018 6:46 pm

The recommended pull-up on the datasheet for the DS18B20 is 5K. The closest common resistor to that is the 4K7. Best to stick with that (although I have used two 10K resistors in parallel when I didn't have a 4K7 to hand).

rickrack
Posts: 10
Joined: Mon Jan 08, 2018 2:29 pm

Re: 1-wire DS18B20 disappears

Wed Jan 17, 2018 9:29 am

jenscollin wrote:
Tue Jan 16, 2018 6:39 pm
I did a couple of measurements with just one sensor connected (0.5m cable) as well as with 4 sensors on 3m cable.
Assuming that the rise trigger level on rpi 3.3V pin is abot 2.2-2.5V I'd say that my rise time is somewhere between 8-15us if I'm measuring the right place. I understand it must be less than 14 right?
Got a similiar result.

danjperron
Posts: 2852
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: 1-wire DS18B20 disappears

Wed Jan 17, 2018 12:16 pm

my rise time is somewhere between 8-15us
Are you with a 10K pull up?

Hum a little bit to slow. The DS18B20 could sink up to 4 ma. Then try a 3K3 instead of a 4k7. This will increase the rise time.

jenscollin
Posts: 17
Joined: Sat Dec 31, 2016 11:26 am

Re: 1-wire DS18B20 disappears

Wed Jan 17, 2018 2:35 pm

Thanks for the follow-ups!
I made some progress:
On my pi3 with 10k pullup I could before not read with bitbang program but with kernel module.

I changed the C-version of the scan program a little and it seems to work now.
I changed the sleep 2us to 13us and 60us to 47us in both ReadBit() and ReadByte().

Still not sure if I can read on a "broken" setup yet, but this is good progress to try something that should work.

danjperron
Posts: 2852
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: 1-wire DS18B20 disappears

Wed Jan 17, 2018 4:24 pm

It will be better that you change the 10K to a 4k7. This way your signal will be in specification. With a 10K your rise time is way to slow. By definition a 4k7 will decrease the time rise by half.

Don't forget you can't change the timing for the 1-wire dtoverlay driver so try to keep your hardware at the specification. You don't have a 4k7 then put another 10K in parallel.

rickrack
Posts: 10
Joined: Mon Jan 08, 2018 2:29 pm

Re: 1-wire DS18B20 disappears

Thu Jan 18, 2018 8:37 am

I double checked the rise times and compared two pi's.
They are 6-10 us.Are they fast enough? or do i need to change sth?

danjperron
Posts: 2852
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: 1-wire DS18B20 disappears

Thu Jan 18, 2018 3:04 pm

They are 6-10 us.Are they fast enough? or do i need to change sth?
This should work with the 1-wire dtoverlay.

I did some experimentation and 12us looks to be the maximum rise slope before the DS18B20 start to failed.
pic_164_4.gif
12 us DS18B20 rise slope
pic_164_4.gif (17.6 KiB) Viewed 720 times
Roughtly a cable will be around 50pf/m so if you have 3 cables of 10 m you will add a capacitance of 30*50pF=1.5nF .

Then your rise time will be around ~1T which is 1RC => 4k7 * 1.5nF = 7us which is what i get experimentally using a cat3 solid wire cable.

You notice that if you are using a 10K instead you will be into a zone that it should not work.

The only way to reduce the rise time is to reduce the capacitance effect , changing cable type or decrease the resistance value. Don't forget that the maximum sink current of the DS18B20 is 4 ma.


P.S. My bitbanging routine only set the correct timing in the python code . The DS18B20Scan and DS18B20V2 are set with 2 us max. I will have to change them.

jenscollin
Posts: 17
Joined: Sat Dec 31, 2016 11:26 am

Re: 1-wire DS18B20 disappears

Sun Jan 21, 2018 4:05 pm

Just a brief follow-up from my end:
The problematic setups that I have, and test on, are not reachable. Adding a 10K in parallell or replacing with a 4k7 or lower isn't possible.

I've probably been very close to the limit of what is an acceptable rise time with my setups (still on the right side). What bothers me is that it works for a few months and then stops (kernel module). Not just fails occasionally, I can handle that, but stops.

I've implemented your bitbang code (modification from python adapted) into mine and we'll see if they can handle the off-site troubling sensors better. (Kernel module disabled)

I'll keep this post updated, but it might take a while.
A big thanks to all chipping in!

Regards,
Jens

jenscollin
Posts: 17
Joined: Sat Dec 31, 2016 11:26 am

Re: 1-wire DS18B20 disappears

Mon Jan 22, 2018 7:14 pm

Ok, I got the situation again, some new information found!
Recap:
The setup has 10K pull-up (Should be 4k7, I know), 5V power support. Same as image above.
The 4 sensors have been working for a few weeks, a few misreads but nothing unusual. Using kernel module with dtoverlay.

It got stuck, no data from any sensors. Just a few 00-80000000 and 00-40000000 dirs with garbage in them.

new:
I disabled the kernel module in boot/config.txt, rebooted rpi. (sudo reboot).
Ran the BitBang code in hope of it working, but instead of sensors this time I got a new type of error:

Code: Select all

*** Error Unable to detect Logic level 1. No pull-up ?
Looking through the code I see that it seems as if a sensor is pulling the line LOW constantly. (Cables and resistors are soldered on and can not fall off)
Using wiringPi toolset to see the pin state, and its input and reads 0.
I tried to set it to OUT, wrote 1 and 0 to it, tried pulling it up/down to move it out of that state.

Could it be that a sensor hangs and completely sinks the whole bus? Anyone heard of that?

Jens

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

Who is online

Users browsing this forum: No registered users and 3 guests