kernel patch for Dallas 1-wire interface


226 posts   Page 3 of 10   1, 2, 3, 4, 5, 6 ... 10
by fulburncams » Tue Jun 26, 2012 5:50 pm
Hi
Am i right in thinking that the solution being discussed uses a GPIO pin direct, what is wrong with using the DS2482 I2C-to-1 wire or equivalent . Is it not possible to use the DS 2482 chip to guarantee the 1-wire timing and interface electricla standards are complied with, sorry if I have misunderstood.
Cheers
Steve
User avatar
Posts: 70
Joined: Wed Nov 30, 2011 8:29 pm
by Frank Buss » Wed Jun 27, 2012 5:29 am
fulburncams wrote:Hi
Am i right in thinking that the solution being discussed uses a GPIO pin direct, what is wrong with using the DS2482 I2C-to-1 wire or equivalent . Is it not possible to use the DS 2482 chip to guarantee the 1-wire timing and interface electricla standards are complied with, sorry if I have misunderstood.
Cheers
Steve


Should be possible. The DS 2482 has single bit commands, which can be difficult to control with the right timing, but it has higher level commands, too, which should work.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by GadgetUK » Wed Jun 27, 2012 6:13 am
Frank Buss wrote:
fulburncams wrote:Hi
Am i right in thinking that the solution being discussed uses a GPIO pin direct, what is wrong with using the DS2482 I2C-to-1 wire or equivalent . Is it not possible to use the DS 2482 chip to guarantee the 1-wire timing and interface electricla standards are complied with, sorry if I have misunderstood.
Cheers
Steve


Should be possible. The DS 2482 has single bit commands, which can be difficult to control with the right timing, but it has higher level commands, too, which should work.


If you're looking to use the DS2482 or DS2483 then I'd recommend the use of OWFS see my blog post for details of using these driver chips and OWFS

http://raspberrypi.homelabs.org.uk/i2c- ... e-masters/

OWFS presents the 1-wire bus as a filesystem, or through a web interface, with modules available for a number of languages.
Posts: 42
Joined: Thu Jan 19, 2012 6:02 pm
by stes » Thu Jun 28, 2012 11:56 pm
I was able to use the 1-wire and i2c drivers successfully at the same time. The pi can query temp sensors while controlling a LED on/off time and run a web server continuously sending data to the client. I don't think a separate micro-controller or i2c to 1-wire chip is needed as the capabilities for this application is expanded. The raspberry pi is going to be used to control a heating element in a vessel now but would also like to add pump and stirrer control in the future.

https://github.com/steve71/RasPiBrew
Posts: 3
Joined: Fri Jun 15, 2012 1:07 am
by jon wise » Sat Jul 07, 2012 10:28 am
Worked straight from the box for me as well.
Is the patch likely to work with Debian wheezy?
Posts: 23
Joined: Thu May 31, 2012 8:21 pm
by Frank Buss » Sun Jul 08, 2012 2:37 am
jon wise wrote:Worked straight from the box for me as well.
Is the patch likely to work with Debian wheezy?


Yes, it works with Debian Wheezy, too. But it overwrites the bootloader, maybe the Debian Wheezy has a newer version, could be a problem if you plan to use OpenGL ES. Then backup the files in /boot and install it back after installing (except kernel.img of course), or just uncomment the parts in the w1-test script.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by Avoncliff » Wed Jul 11, 2012 10:35 pm
Frank
What is the status of your patch merging with main raspberry builds?
I see several people have their own branches, and I would like to use your 1-wire but also update some other modules.
David
Posts: 26
Joined: Fri Dec 09, 2011 5:24 pm
by Frank Buss » Mon Jul 16, 2012 1:28 pm
Avoncliff wrote:Frank
What is the status of your patch merging with main raspberry builds?
I see several people have their own branches, and I would like to use your 1-wire but also update some other modules.
David


I don't know, if the 1-wire patch will be integrated in the other builds, maybe ask the maintainer of the other builds for it. Looks like bootc has some leading edge kernel versions:

http://www.bootc.net/projects/raspberry-pi-kernel/

And then there is the "official" Raspberry Pi kernel, last seen in the beta test for the Wheezy Debian image, but it is based on an old Linux version:

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

I'm sure someday the standard distributions will use a new kernel, and maybe even with 1-wire enabled, which would be cool for some hardware projects. I guess with the new pinmux concept of Linux it would be even possible to not use the pin exclusive as 1-wire and configure at runtime which pin to use. Maybe ask the maintainers so that they are aware of the problem. I think it would be good to enable just all hardware related modules, like in a desktop Linux distribution, so that just all hardware works with the Raspberry Pi.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by Frank Buss » Mon Jul 16, 2012 4:17 pm
Just read in another posting ( viewtopic.php?p=124531#p124531 ) that at least the I2C and SPI driver was backported to the "standard" Linux kernel:

https://github.com/raspberrypi/linux/co ... 0d06291d7b

I guess this will be released for a new Linux image for the Raspberry Pi.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by netomx » Wed Jul 18, 2012 4:18 pm
Thank God! Please, to the standard kernel =)
Posts: 80
Joined: Tue Oct 11, 2011 4:06 am
by Grey Whittney » Fri Jul 20, 2012 11:38 pm
I've been able to get a ds1820 running (and plugged into rrdtool for 5 min logging over crontab). The only issue I had was that I had to run the chip in non-parasitic mode. I couldn't get the true "1-wire" (ie. only data and Gnd needed) running, unlike my avr code. I'll double check over the weekend in case I made a mistake. Does the bus take into account the parasitic mode requirements (such as driving the data bus during conversions)?
--
~ Grey
Posts: 10
Joined: Fri Jul 13, 2012 6:10 pm
Location: PA, USA
by Frank Buss » Sat Jul 21, 2012 5:37 am
Grey Whittney wrote:Does the bus take into account the parasitic mode requirements (such as driving the data bus during conversions)?


I think it sets the output to 1 when idle:

http://lxr.free-electrons.com/source/dr ... 1_io.c#L80

But the GPIO pin can't deliver enough current to power external devices and it could destroy the CPU, if you try it. It is not a high-current GPIO, as available on some AVR chips.
User avatar
Posts: 92
Joined: Fri Jan 06, 2012 4:39 pm
by Andre-W » Sun Jul 22, 2012 3:07 pm
Hi all,

thanks @Frank for this patch. I've included it in my kernel (actual bootc kernel) and compiled it today.
So far, everything wents well - But i does not detects my DS18B20.

I only get the following output:

Code: Select all
ls  /sys/bus/w1/devices/w1_bus_master1
driver     w1_master_add              w1_master_pointer  w1_master_slave_count
power      w1_master_attempts         w1_master_pullup   w1_master_slaves
subsystem  w1_master_max_slave_count  w1_master_remove   w1_master_timeout
uevent     w1_master_name             w1_master_search


I've just connected the DS18B20 to 3V3, GND and GPIO4 and included a pull-up resistor with 4,7k between 3V3 and GPIO4. If i check my circuit for example with arduino it works.

Any idea, what i've did wrong? Have i missed something?

Thanks in advanced - Best regards,

André
Posts: 24
Joined: Fri Jun 01, 2012 1:56 pm
by nry » Sun Jul 22, 2012 3:11 pm
Im having the same problem, wiring looks fine to me

Code: Select all
pi@raspberrypi ~ $ ls /sys/bus/w1/devices/w1_bus_master1/
driver/                    uevent                     w1_master_max_slave_count  w1_master_pullup           w1_master_slave_count
power/                     w1_master_add              w1_master_name             w1_master_remove           w1_master_slaves
subsystem/                 w1_master_attempts         w1_master_pointer          w1_master_search           w1_master_timeout


On a side note based on what has been said about long cables
What would be the best way to attach multiple sensors then with longer cables. I know next to nothing when it comes to designing circuits but can easily turn a circuit diagram into a working item, just can't find much info on this
Posts: 9
Joined: Sun Jul 22, 2012 12:29 pm
by tonyzhang78 » Sun Jul 22, 2012 9:52 pm
Great stuff for the linux newbie like me. Does this include DS2408 driver? Could you please add the C header file can be used in user space for application software development?
Posts: 2
Joined: Fri Jul 20, 2012 9:14 pm
by netomx » Mon Jul 23, 2012 3:57 am
try a 2.2k resistor.

btw, is this pach in the new raspbian image?
Posts: 80
Joined: Tue Oct 11, 2011 4:06 am
by Andre-W » Mon Jul 23, 2012 5:15 am
2.2k resistor sadly dosen't changed anything, it still does not work.

No its not in the officall raspberian-image. You need to use Frank's Kernel or to compile it by yourself.
Posts: 24
Joined: Fri Jun 01, 2012 1:56 pm
by netomx » Mon Jul 23, 2012 5:19 am
I will wait for it.

Btw, are you sure your Dallas are good?
Posts: 80
Joined: Tue Oct 11, 2011 4:06 am
by Andre-W » Mon Jul 23, 2012 5:40 am
Yes, i've used them with Arduino without problems.
Posts: 24
Joined: Fri Jun 01, 2012 1:56 pm
by netomx » Mon Jul 23, 2012 6:15 am
try different resistors values
Posts: 80
Joined: Tue Oct 11, 2011 4:06 am
by Andre-W » Mon Jul 23, 2012 10:52 am
Yes i already did - I've tried some resistors starting from 470 to 10k. I've also tested another RPi Board and another GPIO Ports in the kernel patch.
Posts: 24
Joined: Fri Jun 01, 2012 1:56 pm
by Avoncliff » Mon Jul 23, 2012 10:20 pm
Difficult to offer much help for those who it does not work, but I can say that when I had problems with long cables I got the same sort of output you report. ie lots of w1-xxx files but no device files.
You should see a file in /sys/bus/w1/devices/w1_bus_master1 similar to 28-000001f81b74.
What I did was to look at the signals on the GPIO pin with a digital scope. A logic probe may tell you if the pin is moving. Can you also check the 3.3v line is stable.
Are you testing with the DS18B20 device directly onto the io pins?

For multiple devices on long wires simply wire all three pins in parallel, with as much cable in between as you need. The doc I listed above details best practice, but I have proved worst practice also works 8-). I started with one 18B20 directly on the IO pins and another on the end of a long cable, and then another.....

Frank, have you tried your patch on the latest raspbian kernel?
Posts: 26
Joined: Fri Dec 09, 2011 5:24 pm
by Avoncliff » Wed Jul 25, 2012 11:04 pm
I have failed to add this 1wire to the raspbian kernel, has anyone done this successfully?
I got the kernel source from https://github.com/raspberrypi/linux.git and built it OK.
I then tried adding Frank's patch and building 1-wire as a module, this built and installed OK but will not load.
I note that the original script to install the patched kernel also changed firmware files and more. Do I need any of this?
Posts: 26
Joined: Fri Dec 09, 2011 5:24 pm
by gcb » Sun Jul 29, 2012 3:23 pm
Yes, it works for me, with the kernel source from https://github.com/raspberrypi/linux.git .
I added the patch and started the Kernel Compilation as http://elinux.org/Rpi_kernel_compilation#getting_the_compiler_2 on Ubuntu
Copy the new kernel and the modules to the Raspberry Pi .
Load the module and have a look with dmesg
I found for example
Code: Select all
[   13.127543] Driver for 1-wire Dallas network protocol.
[   13.194290] w1_master_driver w1 bus master: Family 20 for 20.0000000c862e.0f is not registered.
[   13.274196] w1_master_driver w1 bus master: Family 26 for 26.000000c999ec.db is not registered.
[   13.324166] w1_master_driver w1 bus master: Family 29 for 29.00000002b11a.32 is not registered.
[   13.374270] w1_master_driver w1 bus master: Family 29 for 29.00000002aa2d.56 is not registered.
Posts: 3
Joined: Sun Jul 29, 2012 3:12 pm
by mhepp » Wed Aug 01, 2012 1:13 pm
Hi,

I have 5 DS18[BS]20s connected to my RPi. The first usage was via direct connection to GPIO4. And I had trouble with reading values from sensors. The longest wire was aroung 5 meters long and longer wire causes totaly unreadable tepmerature. So, I used DS2482 connected to I2C and stability is now very good. Then I tied add 5th sensor with longer wire (7m) and it is still functional.

Now I have two DS2482 (one near RPi, one on 10m wire) and reading temperartures from 18B20s is stable.
Posts: 1
Joined: Sat Dec 10, 2011 6:33 pm