0
Offline
Sr. Member
Karma: 19
Posts: 424
Always making something...
|
 |
« Reply #30 on: January 17, 2013, 06:43:43 pm » |
I'm getting ready to publish OneWire 2.2. Here's a preview version: http://www.pjrc.com/teensy/beta/OneWire_preview22_17jan13.zipIf anyone has any feedback regarding how OneWire 2.2 should look, please speak up ASAP!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 1
Posts: 83
Arduino rocks
|
 |
« Reply #31 on: January 17, 2013, 07:54:54 pm » |
Unfortunatly, can't test it... argh...
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #32 on: January 23, 2013, 09:17:40 pm » |
Paul, I'm having problems reading from multiple DS18B20's with your 2.2 preview library. Fresh copy of arduino-1.5.1r2-windows, and downloaded just your 2.2 preview library, and I run the DS18x20_Temperature sketch with three of the DS18B20's attached to Due pin 54 (Analog line 0) and I get the following: No more addresses.
No more addresses.
No more addresses.
If I pull two of the sensors out it starts returning results although sometimes it returns results like the following: ROM = 28 F6 C3 49 3 0 0 25 Chip = DS18B20 Data = 0 FF FF FF FF FF FF FF FF FF CRC=C9 Temperature = 4095.94 Celsius, 7404.69 Fahrenheit
or ROM = 28 F6 C3 49 3 0 0 25 Chip = DS18B20 Data = 1 50 5 4B 46 7F FF C 10 1C CRC=1C Temperature = 85.00 Celsius, 185.00 Fahrenheit
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 1
|
 |
« Reply #33 on: February 03, 2013, 12:03:08 am » |
I'm using the ADK2012 device (with the google-provided IDE), which is very similar to an Arduino Due. When I include the pre-release 2.2 version linked above into a project and compile, I get errors like this: OneWire.cpp: In constructor 'OneWire::OneWire(uint8_t)': OneWire.cpp:123: error: base operand of '->' has non-pointer type 'const PinDescription' OneWire.cpp:124: error: base operand of '->' has non-pointer type 'const PinDescription'
Removing the 2 lines it's complaining about allows it to compile, but unsurprisingly, it doesn't actually work. I'm new enough to all this that I don't have a good handle on how to get started debugging this. Any ideas? (I asked this on stackoverflow too: http://stackoverflow.com/q/14669607/114917)
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Sr. Member
Karma: 19
Posts: 424
Always making something...
|
 |
« Reply #34 on: February 05, 2013, 07:37:48 pm » |
I'm using the ADK2012 device (with the google-provided IDE), which is very similar to an Arduino Due. When I include the pre-release 2.2 version linked above into a project and compile, I get errors like this:
Did you try compiling on Arduino 1.5.1? Maybe you can copy whatever's ADK2012 is missing from Arduino 1.5.1? Of course, without fixing delayMicroseconds(), it's unlikely to work reliably.
|
|
|
|
« Last Edit: February 05, 2013, 07:49:42 pm by Paul Stoffregen »
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 1
|
 |
« Reply #35 on: February 10, 2013, 12:43:35 am » |
Is there any way to fix to the delayMicroseconds() issue? or is this something we have to hope the folks at arduino will fix for us? I am using the Ds18b20's for a brewery system and have moved to the due recently and don't want to backtrack to change the sensors
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #36 on: February 11, 2013, 07:50:50 am » |
Hi all, I tried the the OneWire 2.2 with IDE 1.5.1r2. Two of four DS1820 sensors give me no readings ("No more addresses" in the DS18x20 Example sketch), the other two produce no valid temperature readings: ROM = 10 D1 A2 54 2 8 0 57 Chip = DS18S20 Data = 1 FF FF FF FF FF FF FF FF FF CRC=C9 Temperature = -0.50 Celsius, 31.10 Fahrenheit
It is probably the delayMicroseconds problem Paul mentioned in his post. With the new IDE 1.5.2 ( http://arduino.cc/forum/index.php?topic=147531.0) all four sensors are unable to be read ("No more addresses"). It's kind of weird... Have someone else tried 1.5.2 with OneWire yet? Leo Update: the OneWire Library with changes by alvesjc and mantoui works with both 1.5.1r2 and 1.5.2. I'm able to read all 4 sensors.
|
|
|
|
« Last Edit: February 11, 2013, 08:13:24 am by leonid_leonid »
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #37 on: February 12, 2013, 09:26:52 am » |
Hi Paul, I just finished diff-and-try session with the library version OneWire_preview22_17jan13.zip and the version from this thread (with changes by alvesjc and mantoui). The critical point seems to be the write_bit() function and the interrupt handling combined with delayMicroseconds() calls in this function (both have been mentioned in this thread already). As soon as I excluded delayMicroseconds calls from noInterrupts()/interrupts() sections in the write_bit() function, the library worked. Here is the changed version of write_bit(): void OneWire::write_bit(uint8_t v) { IO_REG_TYPE mask=bitmask; volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
if (v & 1) { noInterrupts(); DIRECT_WRITE_LOW(reg, mask); DIRECT_MODE_OUTPUT(reg, mask); // drive output low interrupts(); delayMicroseconds(10); noInterrupts(); DIRECT_WRITE_HIGH(reg, mask); // drive output high interrupts(); delayMicroseconds(55); } else { noInterrupts(); DIRECT_WRITE_LOW(reg, mask); DIRECT_MODE_OUTPUT(reg, mask); // drive output low interrupts(); delayMicroseconds(65); noInterrupts(); DIRECT_WRITE_HIGH(reg, mask); // drive output high interrupts(); delayMicroseconds(5); } }
It's the only change I made on the library. I'm running a test with all the sensors installed in my house heating control, I have 9 DS1820 for temperature sensing and some DS2408 and DS2413 for relay switching. All of them are working (so far) as they usually do with my old Arduino Mega. I'll post test results tomorrow. Leo
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Sr. Member
Karma: 19
Posts: 424
Always making something...
|
 |
« Reply #38 on: February 12, 2013, 10:29:54 am » |
Interrupts are disabled for a very good reason. There's absolutely no way OneWire will return to the buggy pre-2.0 days where interrupts could lengthen the timing and cause random communication errors.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #39 on: February 13, 2013, 04:13:30 am » |
Interrupts are disabled for a very good reason. There's absolutely no way OneWire will return to the buggy pre-2.0 days where interrupts could lengthen the timing and cause random communication errors.
Ok, I understand that (I do know what are interrupts for and why they are disabled in time critical sections). I do not understand why delayMicroseconds acts differently depending on interrupts being disabled or enabled. Declaration of delayMicrosections for SAM is quite simple (from wiring.c): void delayMicroseconds( uint32_t us ) { uint32_t start = micros(); while ((micros() - start) < us) ; }
It did not change since 1.5.1r2. Do you have an idea, what the solution could be? Leo PS if I can contribute in any way, let me know.
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
Full Member
Karma: 10
Posts: 182
|
 |
« Reply #40 on: February 13, 2013, 05:40:05 am » |
Interrupts are disabled for a very good reason. There's absolutely no way OneWire will return to the buggy pre-2.0 days where interrupts could lengthen the timing and cause random communication errors.
Ok, I understand that (I do know what are interrupts for and why they are disabled in time critical sections). I do not understand why delayMicroseconds acts differently depending on interrupts being disabled or enabled. Declaration of delayMicrosections for SAM is quite simple (from wiring.c): void delayMicroseconds( uint32_t us ) { uint32_t start = micros(); while ((micros() - start) < us) ; }
It did not change since 1.5.1r2. Do you have an idea, what the solution could be? Leo PS if I can contribute in any way, let me know. So the problem must be somewhere behind the micros the function delayMicroseconds is realy open so the problem musst be somewhere there uint32_t micros( void ) { uint32_t ticks ; uint32_t count ;
SysTick->CTRL; do { ticks = SysTick->VAL; count = GetTickCount(); } while (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk);
return count * 1000 + (SysTick->LOAD + 1 - ticks) / (SystemCoreClock/1000000) ; } its in the wiring.c
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #41 on: February 13, 2013, 09:03:07 am » |
So the problem must be somewhere behind the micros the function delayMicroseconds is realy open so the problem musst be somewhere there
Right, micros() must have a problem with noInterrupts(). I tried to change delayMicroseconds() to make it independent from micros(). Here is the code: #define CYCLES_PER_USEC 84 // Arduino Due has 84 MHz clock #define CYCLES_PER_LOOP 6 // one iteration of the loop takes 6 cycles #define OVERHEAD_CONST 18 // could someone with an osci please verify this constant? void delayMicroseconds( uint32_t us ) { if(us==1) return; int j; //one iteration of this loop takes 6 cycles on Arduino Due compiled with IDE 1.5.2 for(j=0;j<us*(CYCLES_PER_USEC/CYCLES_PER_LOOP)-OVERHEAD_CONST;j++) { asm volatile("mov r0, r0"); // just NOP asm volatile("mov r0, r0"); } }
This change worked with the original version of OneWire (OneWire_preview22_17jan13.zip) This patch is not pretty but it proves that the problem is in the micros(). Tomorrow I'll try to understand, why micros() has a problem with noIterrupts().
|
|
|
|
|
Logged
|
|
|
|
|
Forum Administrator
Milano, Italy
Offline
Full Member
Karma: 19
Posts: 210
|
 |
« Reply #42 on: February 13, 2013, 09:55:37 am » |
Thank you all, guys, for debugging this one. I've pushed a patch that makes delayMicrosecond() independent from micros(). Paul, I've borrowed the implementation from the Teensy core, if you don't mind! I've only slightly changed it: - the "bne" instruction to "bge" to allow delays of 0uS - changed the calculation of "n" (multiply seems to use 1 cycle as the shift and makes the formula generic) https://github.com/arduino/Arduino/commit/7f7637c782fc0c028f0539d27b99f930ee30baa5@leonid_leonid sorry, I didn't looked at the forum thread with your implementation!
|
|
|
|
|
Logged
|
C.
|
|
|
|
0
Offline
Jr. Member
Karma: 1
Posts: 83
Arduino rocks
|
 |
« Reply #43 on: March 14, 2013, 09:15:11 am » |
Hi all.
I'm back in Due.
I've compiled IDE from the latest info in Git, so I'll give a try on the latest lib from Paul later today.
|
|
|
|
|
Logged
|
|
|
|
|
Pasig City, Philippines
Offline
Newbie
Karma: 3
Posts: 35
I enjoy doing Simple Things!
|
 |
« Reply #44 on: April 01, 2013, 12:05:03 am » |
Hello World! Sometime today, I'll be receiving my Arduino Due, and one of my active Arduino projects is using OneWire. After reading through all of the posts, I'm confused on what to do with my current OneWire library. Should I patch it, replace it, or make a new OneWire library parallel to the current one I'm using? My Project: Arduino Mega 2560: Digital Temperature using DS18B20 and 7-Segments LEDsI've removed the serial debugging code and simplified my sketch that works on my Arduino Mega 2560 clone. From this Forum, I've downloaded OneWire.zip and OneWire_preview22_17jan13.zip.
|
|
|
|
|
Logged
|
I run Xubuntu Linux as my only computer operating system!Windows does not run here; Only Linux! I learned Arduino on my own while living in the Philippines!I first learned Arduino theory in September 2010 and then used ProtoStack's ATmega168 Dev Kit to learn the Arduino Bootloader. Prior to receiving my Seeeduino 328 in January 2011, I have built three ATmega8L boards that work with Arduino IDE. As of April 2013, I have over 3 Dozen Arduino-compatible boards, most of which I built by hand. I have an Arduino Mini R5, Arduino Mega 2560 clone and a Arduino Due. I'm in Twitter and in Google+. Sometimes, I use Skype as Kuya.Marc. I've founded MirandaSoft in 1992 and now in the process of retiring...
|
|
|
|
|