kernel patch for Dallas 1-wire interface


223 posts   Page 2 of 9   1, 2, 3, 4, 5 ... 9
by netomx » Sun Jun 03, 2012 5:28 am
eikcam wrote:
netomx wrote:If mine says:

Code: Select all
root@raspberrypi:/sys/bus/w1/devices/w1_bus_master1/28-0000030a0170# cat w1_slave
50 05 4b 46 7f ff 0c 10 1c : crc=1c YES
50 05 4b 46 7f ff 0c 10 1c t=85000


I'm using the wrong resistor?

85c is the initial value of the sensor on power up. It seems that your sensor isnt doing any calculations. What size resistor are you using? 4.7k?



Yes. Tried with 10k too. Tried without resistor, but it is not detected
Posts: 78
Joined: Tue Oct 11, 2011 4:06 am
by beakersoft » Sun Jun 03, 2012 6:42 pm
netomx wrote:
eikcam wrote:
netomx wrote:If mine says:

Code: Select all
root@raspberrypi:/sys/bus/w1/devices/w1_bus_master1/28-0000030a0170# cat w1_slave
50 05 4b 46 7f ff 0c 10 1c : crc=1c YES
50 05 4b 46 7f ff 0c 10 1c t=85000


I'm using the wrong resistor?

85c is the initial value of the sensor on power up. It seems that your sensor isnt doing any calculations. What size resistor are you using? 4.7k?



Yes. Tried with 10k too. Tried without resistor, but it is not detected


Make sure you put the resistor between the power and the data rail, i made that mistake at first as well
Posts: 27
Joined: Thu Apr 26, 2012 4:35 pm
by netomx » Sun Jun 03, 2012 7:00 pm
beakersoft wrote:
netomx wrote:
eikcam wrote:85c is the initial value of the sensor on power up. It seems that your sensor isnt doing any calculations. What size resistor are you using? 4.7k?



Yes. Tried with 10k too. Tried without resistor, but it is not detected


Make sure you put the resistor between the power and the data rail, i made that mistake at first as well


Im pretty sure I made that. But the power line, it is 3v3 isnt it?
Posts: 78
Joined: Tue Oct 11, 2011 4:06 am
by beakersoft » Sun Jun 03, 2012 7:15 pm
yes, use the 3v3 as your power line the resistor should be between the power line and the data line, then your ground. I'd take a picture of mine but its gonna be a bit hard to see it
Posts: 27
Joined: Thu Apr 26, 2012 4:35 pm
by netomx » Sun Jun 03, 2012 7:23 pm
beakersoft wrote:yes, use the 3v3 as your power line the resistor should be between the power line and the data line, then your ground. I'd take a picture of mine but its gonna be a bit hard to see it


no worries, belive me, I had connected well. Maybe the Dallas is damaged? I'll try with a new one tomorrow, but like to work on weekends on this :(

btw, this patch and the new firmware, breaks the sound support :(
Posts: 78
Joined: Tue Oct 11, 2011 4:06 am
by Frank Buss » Sun Jun 03, 2012 7:51 pm
netomx wrote:btw, this patch and the new firmware, breaks the sound support :(


Works for me. How did you test it? When I do this as root:

apt-get install alsa
modprobe snd-bcm2835
amixer cset numid=3 1


and then login as "pi", then "startx", I can start "Music Player" and the demo sound (and other mp3 files) works nice. ("amixer cset numid=3 1" is for using the audio jack, because my HDMI display doesn't have a speaker).
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by netomx » Sun Jun 03, 2012 8:00 pm
Frank Buss wrote:
netomx wrote:btw, this patch and the new firmware, breaks the sound support :(


Works for me. How did you test it? When I do this as root:

apt-get install alsa
modprobe snd-bcm2835
amixer cset numid=3 1


and then login as "pi", then "startx", I can start "Music Player" and the demo sound (and other mp3 files) works nice. ("amixer cset numid=3 1" is for using the audio jack, because my HDMI display doesn't have a speaker).



Well I used the omxplayer, and now I don't hear anything... maybe the amixer is a new thing, I havent test that
Posts: 78
Joined: Tue Oct 11, 2011 4:06 am
by netomx » Wed Jun 06, 2012 4:47 am
Well now I use mplayer and it's working great, thank you guys. I made a little script, but I saw here that you use perl, and a lot of things, so I just used BASH

Code: Select all
#!/bin/bash
SENSORES=$(cat /sys/bus/w1/devices/w1_bus_master1/w1_master_slaves)
for item in ${SENSORES[*]}
do
VALOR=$(cat /sys/bus/w1/devices/$item/w1_slave | grep t= | cut -f2 -d= | awk '{print $1/1000}')
echo $VALOR
done


Save it to whatever name you want and give permissions, chmod a+x yourscript

and run it like this ./yourscript

enjoy it! I'll make another one but with some voices of MW3 and UrbanAssault =D
Posts: 78
Joined: Tue Oct 11, 2011 4:06 am
by Frank Buss » Wed Jun 06, 2012 5:48 am
Yes, there are some problems with some programs, because Alsa is still buggy on the Raspberry Pi, see other forum posts.

Nice script.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by pygmy_giant » Sat Jun 09, 2012 12:42 am
When I update the firmware in readiness for installing these drivers I loose mouse control in X - is this a common problem and is there any known remedy?
Ostendo ignarus addo scientia.
Posts: 1569
Joined: Sun Mar 04, 2012 12:49 am
by pygmy_giant » Sat Jun 09, 2012 10:31 am
sorted it - needed to update lib/modules aswell as the /boot files ... couldn't use hexxeh's updater as I don't have a linux compatible internet connection as yet - I only have a 3g mobile broadband dongle (need to inxtall some bits and bobs to get it working) - have been thinking that it could possibly also be used as a GPS positioning device...?
Ostendo ignarus addo scientia.
Posts: 1569
Joined: Sun Mar 04, 2012 12:49 am
by netomx » Sun Jun 10, 2012 7:43 pm
Anyone got problems building modules with this patch? I updated the firmware and use your modules/kernel. I downloaded the 3.2.18 linux kernel and tried to build... no success :(

Code: Select all
pi@raspberrypi:/usr/src/3.2.18+$ sudo modprobe -f prism2usb
FATAL: Error inserting prism2usb (/lib/modules/3.2.18+/prism2usb.ko): Invalid module format
Posts: 78
Joined: Tue Oct 11, 2011 4:06 am
by Frank Buss » Sun Jun 10, 2012 11:07 pm
netomx wrote:Anyone got problems building modules with this patch? I updated the firmware and use your modules/kernel. I downloaded the 3.2.18 linux kernel and tried to build... no success :(

Code: Select all
pi@raspberrypi:/usr/src/3.2.18+$ sudo modprobe -f prism2usb
FATAL: Error inserting prism2usb (/lib/modules/3.2.18+/prism2usb.ko): Invalid module format


Works for me. "Invalid module format" sounds like you didn't use a cross compiler for ARM, but maybe compiled it with the host system compiler. What says "file prism2usb.ko"? It should say something like "ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped".

Another problems with this driver is that it is in the staging area of the Linux kernel, and it needs WLAN support, which is not enabled in my version of the kernel. The general advice is to use this tutorial:

http://elinux.org/RPi_Kernel_Compilation

Maybe with my version of the kernel at https://github.com/FrankBuss/linux-1/tree/rpi-w1

But I've tested it and created two different update files, with the prism2 and WLAN support enabled:

http://www.frank-buss.de/raspberrypi/kernel-prism2.tgz

http://www.frank-buss.de/raspberrypi/modules-prism2.tgz

When I do "modprobe prism2_usb", in /var/log/messages (and on the console, if you are logged in with the keyboard) it says this:

Jun 10 23:51:21 raspberrypi kernel: cfg80211: Calling CRDA to update world regulatory domain
Jun 10 23:51:21 raspberrypi kernel: prism2_usb: module is from the staging directory, the quality is unknown, you have been warned.
Jun 10 23:51:21 raspberrypi kernel: usbcore: registered new interface driver prism2_usb

I don't have this hardware, but it should work.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by netomx » Mon Jun 11, 2012 5:55 am
Code: Select all
pi@raspberrypi:~$ file /lib/modules/3.2.18+/prism2usb.ko
/lib/modules/3.2.18+/prism2usb.ko: ELF 32-bit LSB relocatable, ARM, version 1, not stripped


will test your new kernels tomorrow, thanks!
Posts: 78
Joined: Tue Oct 11, 2011 4:06 am
by netomx » Wed Jun 13, 2012 5:41 pm
Thank you, it worked. It is weird that in my build, the module didn't worked. do your kernel has v4l enabled?
Posts: 78
Joined: Tue Oct 11, 2011 4:06 am
by soend » Sun Jun 17, 2012 7:27 pm
Frank Buss wrote:
Code: Select all
sudo bash
wget http://www.frank-buss.de/raspberrypi/w1-test
bash w1-test



I have read this thread and as i understand i had to run this script to use the patched kernel. So i run the script. But afther reboot i still get this:
Code: Select all
root@raspberrypi:~# modprobe w1-gpio
FATAL: Module w1-gpio not found.


Any other ides what should i do to get this working?
Posts: 9
Joined: Sun Jun 17, 2012 7:23 pm
by Avoncliff » Sun Jun 17, 2012 10:27 pm
Frank thanks for the hard work, tried it tonight and all works out of the box with local 18b20's.
I can not get it to work with the 18b20's spread around the house on 10's of metres of cable. These have worked fine with USB adaptors on 5v in the past.
I need to look at where it breaks, but has anyone tried long runs yet?
David
Posts: 26
Joined: Fri Dec 09, 2011 5:24 pm
by soend » Mon Jun 18, 2012 7:18 pm
Ok, so i have had a little "success". I tried this patch on a clean debian image and all what happened was that it stopped booting. Only red light come on and thats it. I have tried now 4 times with clean install, with new firmware etc but still had no luck. Any dips would be helpful! What exact debian image are u guys using?
Posts: 9
Joined: Sun Jun 17, 2012 7:23 pm
by davidmam » Mon Jun 18, 2012 9:08 pm
I ran the Pi update script to get everythingto the latest versions then used Frank's kernel. It ran without problems.

With respect to long runs, you might find that the long runs drop too much voltage. You have two options. One is to use a serial adapter on the UART pins (I haven't done this but have a DS2480B in the post.) or alternatively shift the levels of the 1-wire run up to 5V using a level shifter between the 18B20s and the GPIO pins (a couple of 2N7000 MOSFET and some 10K resistors should do, but I haven't done this yet so proceed at your own risk)
Posts: 98
Joined: Tue Dec 06, 2011 4:13 pm
by Frank Buss » Tue Jun 19, 2012 5:26 am
soend wrote:I have read this thread and as i understand i had to run this script to use the patched kernel. So i run the script. But afther reboot i still get this:
Code: Select all
root@raspberrypi:~# modprobe w1-gpio
FATAL: Module w1-gpio not found.


Any other ides what should i do to get this working?


No idea, worked for me. This is the output when the script works successfully: http://pastebin.com/CipMMq6C

Maybe some problems with your internet connection? "md5sum /boot/kernel.img" shoud say "2397c154251211d3fa2d4b8bcb224497 /boot/kernel.img" when the update was successful.

I'm using debian6-19-04-2012.zip from the Raspberry Pi download page.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by Frank Buss » Tue Jun 19, 2012 5:42 am
Avoncliff wrote:Frank thanks for the hard work, tried it tonight and all works out of the box with local 18b20's.
I can not get it to work with the 18b20's spread around the house on 10's of metres of cable. These have worked fine with USB adaptors on 5v in the past.
I need to look at where it breaks, but has anyone tried long runs yet?
David


The problem could be the GPIO output of the Raspberry Pi. As I wrote earlier, it is not safe to connect the GPIO to long wires, because of the high load. It could destroy your RPi in the long run, because the GPIO pins are not designed to drive high load.

That said, you could try to increase the driver strength, there are some registers in the Broadcom chip which you can program for this. And maybe this article might help, too, e.g. the RC filter in Appendix B:

http://www.maxim-ic.com/app-notes/index.mvp/id/148

because the signal might be ringing, which you could see on an oscilloscope.

Another idea is to use something like the DS2480B and then connect it to the serial port of the Raspberry Pi.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by GadgetUK » Tue Jun 19, 2012 6:24 am
As I mentioned previously in the thread
viewtopic.php?p=88177#p88177
You may also want to consider using one of the i2c connected 1-wire bus masters.
Posts: 29
Joined: Thu Jan 19, 2012 6:02 pm
by Avoncliff » Tue Jun 19, 2012 10:13 pm
[quote="Frank Buss"

The problem could be the GPIO output of the Raspberry Pi. As I wrote earlier, it is not safe to connect the GPIO to long wires, because of the high load. It could destroy your RPi in the long run, because the GPIO pins are not designed to drive high load.

That said, you could try to increase the driver strength, there are some registers in the Broadcom chip which you can program for this. And maybe this article might help, too, e.g. the RC filter in Appendix B:

http://www.maxim-ic.com/app-notes/index.mvp/id/148

because the signal might be ringing, which you could see on an oscilloscope[/quote]

Quick tests show 2 sensors at around 10m fine but more fail.
The maxim document is based on parasitic power but I am using 3wire, 3.3v, data,ground.
Can you point me to more docs on increasing the driver strength, and would this fit easily into the kernel 1wire module?
The scope show a slow rise, but clean fast fall.
Posts: 26
Joined: Fri Dec 09, 2011 5:24 pm
by Avoncliff » Wed Jun 20, 2012 9:38 pm
Update.
I now have 4 of the 5 sensors I originally installed working on raspberry gpio 3.3v.
I had used a 6k8 resistor and it is clearly better on 4k7 as specified.
The remaining sensor is outside and I am suspecting a wiring fault, it last worked at least one winter ago.
So again thanks to Frank and others here.
Posts: 26
Joined: Fri Dec 09, 2011 5:24 pm
by Avoncliff » Mon Jun 25, 2012 8:44 pm
Update 2: success
I have found this document http://www.1wire.org/Files/Articles/1-W ... 20v1.0.pdf which tells me far more than I ever wanted to know about long cables and 1-wire.
In my case the interesting part is the value of the recommended pull up resistor is between 1k and 4.7k. As the length of the run increases the capacitance increases and the value of the pull up needed reduces. They claim 188m and 20 devices is possible. I have 5 devices and around 20-25m of bad cable and poor topology working with 2k8 resistor.
All working fine with a reading every 15min for last 2 days.
Posts: 26
Joined: Fri Dec 09, 2011 5:24 pm