1-Wire library, is there one? if multiple, which one choose?

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi there,
I need to access Maxim/Dallas 18B20 thermometers, using 1-wire protocol.

Is there a (good) library for 1-wire protocol, for avr-gcc?
[I don't want to program in Bascom]

For LCD I am using Peter Fleury's lib,
for I2C (hardware), routines Joerg included in avr-libc examples.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If I remember correctly Atmel posted a flexible 1 wire lib, but it was for the IAR compiler.

Shouldn't be too hard to convert to GCC though.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have a look here

http://www.siwawi.arubi.uni-kl.d...

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

https://code.google.com/p/atmega-clib/
https://code.google.com/p/atmega-clib/source/browse/branches

You can import them as Eclipse projects. It works with the most recent Atmel Toolchain

If you work with Atmel Studio, you can import the Solution from here:

https://code.google.com/p/atmel-clib/

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@Bingo600: looks good (first impression looking into code).

As I have to respect strict timing (synced to line), *and* measure temperature, I started to think about adding an Tiny in 8pin, and connect it to main (now Mega8) using SPI... To be able to use only short (SPI / 2-3bytes) transfer with interrupts disabled...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@funlw65: Yours is far too big for me, and it looks i is the same (1W part), the Bingo600 pointed me at.

I am having problems using this lib:
- device seems to respond (at least if I "manually" issue "1W reset" condition - I measure "presence" pulse), but
- when I try (simplest possible code for an 1wire device):
"ow_reset"
"byte_wr(ow_read_rom)"
8x "byte_rd", I get "FF"'s.

What's wrong?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

laurentppol wrote:
What's wrong?

- missing: #include "defines.h" in "onewire.c", provided F_CPU is defined in "defines.h" :)

Just for others :), look at the warnings of compiler,not only errors...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
look at the warnings of compiler,not only errors...

Set the "treat warnings as errors" for your compiler. A build with warnings is not a clean build, IMO.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
A build with warnings is not a clean build, IMO.

Even if it comes "incompatible pointer type" (missinig typecast?).

But which switch schould I use? My gouru ;P :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Even if it comes "incompatible pointer type" (missinig typecast?).

Yes, the point is that a build is only clean if it is really clean. The trouble with allowing some warnings is that sooner or later you will miss a warning that is actually indicating a big problem. All warnings should be removed right away.

Quote:

But which switch schould I use?

In general, "when everything else fails - read the documentation". In this case I'll spoil you and say that you want the
-Wall switch.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And maybe -Werror ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, -Werror was what I was after.

Thanks, Slug! :wink:

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]