vieiraf / itg-3200driver

Automatically exported from code.google.com/p/itg-3200driver
GNU Lesser General Public License v3.0
2 stars 2 forks source link

readmem causing Wire to crash #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Firstly thanks for some really nicely put together code.

I'm running this on a Seeduino ATMega328P which is running great, but the code 
seems to be crashing randomly at reasonably short intervals while reading data 
off the ITG-3200.

The problem seems to be within the readmem call which is causing Wire to crash? 
 This generally happens while in the main program loop from calls to 
readGyro(xyz), but I've seen it happen several times in the showAll() call as 
well while retrieving register values.

I'm not seeing the problem when running the code found on this page: 
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1278367409/15 which runs 
stabily.

Could this be an Interrupt conflict with Wire? 
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1260739313

Original issue reported on code.google.com by scott.ni...@gmail.com on 2 Sep 2010 at 5:19

GoogleCodeExporter commented 9 years ago
Hello Scott,

Could you confirm if your code (loop) is using isRawDataReady() for testing 
data availability.
Could you also run ITG3200_test.pde example and tell me if it also crashes.
Meanwhile I will do some tests to replicate the crash.

Regards,
Fil

Original comment by fil.vie...@gmail.com on 2 Sep 2010 at 9:28

GoogleCodeExporter commented 9 years ago
Yes I've been running ITG3200_output.pde but this also happens in 
ITG3200_test.pde.  This code is using isRawDataReady().

The sketch tends to crash a lot quicker when running a high sample rate such as 
the default init().  This makes it a lot more stable but does not eliminate the 
crash completely gyro.init(7, RANGE2000, BW005_SR1, PLL_XGYRO_REF, true, true);

Original comment by scott.ni...@gmail.com on 2 Sep 2010 at 9:38

GoogleCodeExporter commented 9 years ago
Passed 22 minutes since I'm running ITG3200_test.pde and still no crash...
(Using Arduino 0018 at 57600 baud.)

Do you have any other devices using same I2C bus?

Fil.

Original comment by fil.vie...@gmail.com on 2 Sep 2010 at 9:54

GoogleCodeExporter commented 9 years ago
I'm running Arduino 0017 so will try upgrading.  No other devices on bus.

Original comment by scott.ni...@gmail.com on 2 Sep 2010 at 10:21

GoogleCodeExporter commented 9 years ago
Hello again Scott,

ITG3200_test.pde run for 41 minutes with no problems.
Now running same code with different initialization for 15 mins and still no 
problems. Using:  gyro.init(7, RANGE2000, BW005_SR1, PLL_XGYRO_REF, true, true).

Please let me know how things run with 0018.

Fil.

Original comment by fil.vie...@gmail.com on 2 Sep 2010 at 10:37

GoogleCodeExporter commented 9 years ago
hmm, still same issues with 0018.  I'm running Ubuntu 10.04 64bit btw.  The 
error doesn't seem to show up at all with lowest sample rate of ~3Hz.

I will narrow down the problem and try to give you more specific information on 
reproducing the crash

Original comment by scott.ni...@gmail.com on 2 Sep 2010 at 10:49

GoogleCodeExporter commented 9 years ago
I'm using win7 x64.

OK then I'll wait for your feedback.

Fil.

Original comment by fil.vie...@gmail.com on 2 Sep 2010 at 11:19

GoogleCodeExporter commented 9 years ago
Ok I've isolated this to the interrupt settings on the ITG3200.  If I remove 
the isRawDataReady() check from the main loop and modify ITG3200:init() to 
disable the interrupts on the ITG3200 the program runs flawlessly

setITGReady(false);
setRawDataReady(false);

Original comment by scott.ni...@gmail.com on 19 Sep 2010 at 1:55

GoogleCodeExporter commented 9 years ago
Hi Scott,

Does this changes work for any program? Does the same code changes make 
ITG3200_test.pde run for you?

What interrupt settings you are using? (Latchmode, Clearmode and Drivetype)
Meanwhile I'll will check Interrupt related code for any bugs.

Fil.

Original comment by fil.vie...@gmail.com on 19 Sep 2010 at 9:25

GoogleCodeExporter commented 9 years ago
I got a problem when I run ITG-3200 output.
here is the output:

ITG3200:Error reading address 0x16
ITG3200:Error reading address 0x16
ITG3200:Error reading address 0x3E
ITG3200:Error reading address 0x17
ITG3200:Error reading address 0x17
Current ITG3200 settings
==========================================================
device address                  = 0x69
Sample rate divider (Hz)        = ITG3200:Error reading address 0x16
ITG3200:Error reading address 0x15

Original comment by guoka...@gmail.com on 11 Nov 2010 at 9:00

GoogleCodeExporter commented 9 years ago
Hi guokai19 and Scott,

I was not able to generate reported problems, but I've made some changes and is 
now available for download (v0.3). Let me know your problems continue.

Fil.

Original comment by fil.vie...@gmail.com on 16 Nov 2010 at 11:29

GoogleCodeExporter commented 9 years ago
I'll try this out, thanks for the update.  Sorry no further reports from me, 
have been stuck into writing IMU code, now I've got the drivers functioning 
(albeit without the ITG3200 interrupt feature enabled).  I will see if the 
update fixes the interrupt problem I was seeing.

Original comment by scott.ni...@gmail.com on 17 Nov 2010 at 8:57

GoogleCodeExporter commented 9 years ago
Scott,

you should read this http://www.rcgroups.com/forums/showthread.php?t=1264836
it is related with interrupt wiring.

Fil.

Original comment by fil.vie...@gmail.com on 20 Nov 2010 at 1:16

GoogleCodeExporter commented 9 years ago
hi fil.vieira
thanks for the changes, I will test it again later

Original comment by tony.a...@gmail.com on 20 Nov 2010 at 11:10

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Guys, this is probably a consequence of some noise on the I2C line.. which 
could result in I2C hangs. Have a look at 
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1291403700/0

Original comment by fabio.va...@gmail.com on 5 Dec 2010 at 10:44

GoogleCodeExporter commented 9 years ago
Also, I can confirm that commenting out setRawDataReady(_INTRawDataReady); in 
init(...) looks like it makes things more stable.

Original comment by fabio.va...@gmail.com on 5 Dec 2010 at 11:07

GoogleCodeExporter commented 9 years ago
My 2 cent guess.. In a already quite noisy i2c connection, when the ITG3200 
launch the interrupt it somehow delay or loses some bits of the I2C 
communication.. this would causes Arduino Wire to hangs.

This actually makes sense because if the device has the DataReady interrupt 
set, it probably expect to answer an I2C request quite some milliseconds after 
the interrupt has been sent, while I'm currently pulling data from it without 
caring about the interrupt.. so, where it queried and at the same time it raise 
and interrupt it delays or loose bits of the communication.

Could it be the problem? 

Maybe it could also helps to connect the interrupt pin to Arduino GND or a 
Digital pin, just to not leave it open and unconnected.

Original comment by fabio.va...@gmail.com on 5 Dec 2010 at 11:23

GoogleCodeExporter commented 9 years ago
nope.. even disabling interrupts it still hangs.. any idea?

Original comment by fabio.va...@gmail.com on 5 Dec 2010 at 1:48

GoogleCodeExporter commented 9 years ago
with me it helped adding Wire.begin() in the constructor.... (helped for now)

Original comment by nee...@gmail.com on 20 Dec 2010 at 11:48

GoogleCodeExporter commented 9 years ago
HI everyone as I posted in another issue.

I found the problem I guess. Since i've added "Wire.begin()" in the constructor 
 everything ran without crashing for some hours.

Hope I get some feedback on this possible sollution.

Maybe Filipe, you initiate the wire library earlier in your code or the arduino 
mega is always a master on I2C. I believe wire.begin intiates a device as 
master or slave and that without this initiation the slaves/masters do'nt know 
how to act in different situations

Original comment by stud...@gmail.com on 26 Dec 2010 at 1:43

GoogleCodeExporter commented 9 years ago
Just created a new branch (fil.testing) with calibrate and wire changes.

Fil.

Original comment by fil.vie...@gmail.com on 29 Dec 2010 at 5:13

GoogleCodeExporter commented 9 years ago

Original comment by fil.vie...@gmail.com on 19 Jan 2011 at 3:18

GoogleCodeExporter commented 9 years ago
In release 0.4 I’ve added code that can be uncommented if such a problem 
occurs. 
Depending of future feedback I will change wire.begin() to constructor if that 
is the final and verified fix.

Original comment by fil.vie...@gmail.com on 20 Jan 2011 at 11:37

GoogleCodeExporter commented 9 years ago
The bus does not hang now that I disabled the interrupt!! yahooo!! thanks!

Original comment by lcasa...@gmail.com on 13 Dec 2011 at 2:00