0
Offline
Newbie
Karma: 0
Posts: 4
Arduino rocks
|
 |
« Reply #45 on: September 25, 2007, 05:44:30 pm » |
When attempting to compile my program with the onewire library I am getting this error. I have created the library directories and added the keyword file.
o: In function `__static_initialization_and_destruction_0(int, int)': undefined reference to `OneWire::OneWire(unsigned char)
Anyone know how to fix it?
#include <OneWire.h>
OneWire ds(10); <------------ Commenting out this line makes the program compile
void setup() {
}
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 183
|
 |
« Reply #46 on: September 26, 2007, 02:36:02 am » |
But does you program work without "OneWire ds(10)"? I don't think so.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #48 on: November 09, 2007, 10:55:09 am » |
Has anyone tried the library with the arduino-0010 version yet? When I try to use the 008 version of the OneWire library with it, I get a bunch of errors.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #49 on: January 17, 2008, 08:44:00 pm » |
I put the files in hardware/libraries/OneWire and everything worked fine. I am on OS X using arduino-0010 and the 0008 version of the OneWire library.
Dan
PS - Can the OP post the circuit they are testing with?
|
|
|
|
« Last Edit: January 17, 2008, 08:44:57 pm by DanMo »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 39
Arduino rocks
|
 |
« Reply #50 on: January 24, 2008, 06:24:29 am » |
[...] it really eats up SRAM. The CRC tables use about 256 bytes of RAM (from the 1 kbytes the atmega168 has). On my system I have temporarily commented out that section, but I think a good solution would be to use PROGMEM for the CRC tables. A better solution, I think, would be to do the CRC calculation in code, without using the lookup table at all. I spent a couple of hours on that yesterday and worked it out. Just replace the current code for the OneWire::crc8() function with the following, uint8_t OneWire::crc8 ( uint8_t *addr, uint8_t len ) { uint8_t i, j; uint8_t crc = 0;
for (i = 0; i < len; i++) { uint8_t inbyte = addr[i]; for (j = 0; j < 8; j++) { uint8_t mix = (crc ^ inbyte) & 0x01; crc >>= 1; if (mix) crc ^= 0x8C; inbyte >>= 1; } } return crc; }
|
|
|
|
« Last Edit: January 24, 2008, 06:26:11 am by TomP »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #51 on: February 18, 2008, 06:54:24 am » |
The OneWire library working fine with Arduino-0009. I'm reading from two DS18S20 using parasite power. Just to mention that it's working fine with Arduino-0010 as well, using it to read a DS18S20 with parasite power.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« Reply #52 on: March 24, 2008, 10:22:01 pm » |
does any one know if this works with the DS18B20... I have it hooked up per everything I have found here, in parasite mode, and all get is this R=28 92 F1 7D 1 0 0 34 Device is not a DS18S20 family device any ideas?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 39
Arduino rocks
|
 |
« Reply #53 on: March 24, 2008, 10:51:16 pm » |
Yes I ran into that too, as I reported elsewhere - the family code for the 18B20 is different from that for the 18S20. (There's a note one the Arduino OneWire page that mentions this.) Just replace the family code in the test (0x28) with the one for the 18B20 (0x10). For the record, the DS1822 thermometer has yet another family code (0x22).
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« Reply #54 on: March 25, 2008, 06:59:50 am » |
Yes I ran into that too, as I reported elsewhere - the family code for the 18B20 is different from that for the 18S20. (There's a note one the Arduino OneWire page that mentions this.) Just replace the family code in the test (0x28) with the one for the 18B20 (0x10). For the record, the DS1822 thermometer has yet another family code (0x22). Awesome, Thanks, I must have missed the family code changed, I thought I read all the paged, my bad. edit: Its working now, I am getting hex data out, which is great. I saw this piece of code in the original code snip, I just want to make sure its an accurate conversion of the hex Serial.print("read scratchpad "); msb = pad[1]; lsb = pad[0]; if (msb <= 0x80)lsb = lsb/2; msb = msb & 0x80; if (msb >=0x80) lsb = (~lsb)+1; if (msb >=0x80) lsb = lsb/2; if (msb >=0x80) lsb = ((-1)*lsb); Serial.print("T = "); Serial.print(lsb); Serial.print(" ");
|
|
|
|
« Last Edit: March 25, 2008, 07:50:00 am by venalicio »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 9
Arduino rocks
|
 |
« Reply #55 on: April 17, 2008, 04:18:16 pm » |
Has anyone had any problems with this library in Arduino-0011?
I am trying to interface to the 1-wire weather station and am just initially trying to access the ds1820 temperature sensor. But when I try the sample code provided with the library it can't seem to find any addresses. If I comment out the search part and enter the address manually it does return a presence pulse but all zeros for the temperature and 0 for the crc
This is exactly what it returns : R=10 A 36 9 0 8 0 C9 P=1 0 0 0 0 0 0 0 0 0 CRC=0
I'm not very good at understanding the code and maybe I've jumped into deep water but the wiring I2C library was so easy, I kind of expected the same here...
Thanks,
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 39
Arduino rocks
|
 |
« Reply #56 on: April 18, 2008, 08:55:28 am » |
venalicio: (Sorry for not responding sooner, but your edit didn't trigger a notification.) The code to read the temperature needs to be slightly different for the DS18B20 (and DS1822), because it returns a 12-bit temperature value (0.0625 deg precision), while the DS18S20 and DS1820 return 9-bit values (0.5 deg precision). Assuming you've gotten the msb and lsb for the temperature, here's how converting to a floating-point temperature value is pretty easy. You should just need the following code: DS18S20: int hext = (msb <<  + lsb; double tempc = (double)hext * 0.5; DS18B20 int hext = (msb <<  + lsb; double tempc = (double)hext * 0.0625; These snippets ought to work, but I don't have my Arduino wired up to the temperature sensors at the moment, and so I can't verify it right now.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 39
Arduino rocks
|
 |
« Reply #57 on: April 18, 2008, 12:05:52 pm » |
For 18S20: void loop() { int LowByte, Whole, Fract, Tc; OneWireReset(TEMP_PIN); OneWireOutByte(TEMP_PIN, 0xcc); OneWireOutByte(TEMP_PIN, 0x44); // perform temperature conversion, strong pullup for one sec OneWireReset(TEMP_PIN); OneWireOutByte(TEMP_PIN, 0xcc); OneWireOutByte(TEMP_PIN, 0xbe); LowByte = OneWireInByte(TEMP_PIN); Tc=(LowByte*10)/2; // 18S20 Temp= LSB/2 Whole=Tc / 10; //calcul de l'entier Fract=Tc % 10; //calcul fraction ".5" Serial.print("Temperature :"); Serial.print(Whole); Serial.print("."); Serial.println(Fract); delay(2000); }
I only have 18S20 so I know it works and I did spend a couple of hours reading through the datasheet.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 39
Arduino rocks
|
 |
« Reply #58 on: April 18, 2008, 03:50:05 pm » |
For 18S20: Tc=(LowByte*10)/2; // 18S20 Temp= LSB/2 Whole=Tc / 10; //calcul de l'entier Fract=Tc % 10; //calcul fraction ".5" } I only have 18S20 so I know it works and I did spend a couple of hours reading through the datasheet. Of course, that code only works for temperatures above freezing. I'm sure that's fine for your purposes, but anyone who might want to use reuse your code should be aware of this.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 39
Arduino rocks
|
 |
« Reply #59 on: April 19, 2008, 02:05:56 am » |
YES, I did forget to say that !
|
|
|
|
|
Logged
|
|
|
|
|
|