Offline
Newbie
Karma: 0
Posts: 7
|
 |
« on: November 07, 2012, 06:29:03 pm » |
Hi, so basically I am trying to connect 2 accelerometers to the arduino via the I2C protocol and then logging the readings onto an SD card using the Wireless SD shield, which uses the SPI protocol. As some may know, the data buses are shared between I2C and SPI and hence I have a problem when trying to write to the SD card and read from the accelerometers. Is there any way the 2 protocols can be implemented together or is there maybe one of the arduino boards which has seperate buses for the two protocols?
Thanks
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 75
Posts: 6976
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #1 on: November 07, 2012, 06:49:50 pm » |
the data buses are shared between I2C and SPI In what way? They are separate AFAIK. _____ Rob
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #2 on: November 08, 2012, 02:52:16 am » |
I was doing some research about it and i found that on a forum. The problem is when i was retrieving data from the I2C bus, the moment i open the file on the SD card, the program halts. I went looking around to see what the problem was and i read that the SDA and SCL are also the DIN and DOUt buses of the SPI protocol =/
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 75
Posts: 6976
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #3 on: November 08, 2012, 03:09:16 am » |
I went looking around to see what the problem was and i read that the SDA and SCL are also the DIN and DOUt buses of the SPI protocol Not in this universe, at least not on any chip I've seen. Have you looked at the schematics for your board? The problem is when i was retrieving data from the I2C bus, the moment i open the file on the SD card, the program halts. Just a wild guess, but have you considered that there might be a problem with your code  Can you post it and also your schematic of possible? ______ Rob
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #4 on: November 08, 2012, 07:15:11 am » |
Thanks for you reply Graynomad. I don't believe everything that is said in a forum, but i always do research about anything that might be an issue concerning my case. In fact, other than that forum, I couldn't find anything about the I2C and SPI sharing the data bus, so that's why I decided to post something here, to get some opinions.
With regards to the code, it could be that I have some errors but I kept the code quite similar to that on the SD library examples but it definitely needs some more work. I am currently not at home so I can't post the code but if I fail in making it work, i will definitely do so. At least now i know that i might have a chance of solving it software wise.
Thanks again.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Online
Shannon Member
Karma: 226
Posts: 14121
Lua rocks!
|
 |
« Reply #5 on: November 09, 2012, 04:52:14 am » |
As some may know, the data buses are shared between I2C and SPI ...
No, they are not. http://www.gammon.com.au/i2chttp://www.gammon.com.au/spi
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Online
Shannon Member
Karma: 226
Posts: 14121
Lua rocks!
|
 |
« Reply #6 on: November 09, 2012, 04:53:22 am » |
The problem is when i was retrieving data from the I2C bus, the moment i open the file on the SD card, the program halts.
Was this anything to do with interrupts? Perhaps post your code.
|
|
|
|
|
Logged
|
|
|
|
|
the land of sun+snow
Offline
Edison Member
Karma: 91
Posts: 2242
|
 |
« Reply #7 on: November 10, 2012, 06:09:25 pm » |
Wow! Good work, Nick. I hadn't seen those 2 particular pages before. Pages like this should be referenced in an "easy to find" place on the main Arduino website, or are they? Maybe, an extra link in the main Wire pages, etc, http://arduino.cc/en/Reference/Wireor the tutorial page, or somewheres where they're not buried with 1000 other links [like Playground].
|
|
|
|
|
Logged
|
Something different - Kitchen-Sink Arduino-compatible boards
|
|
|
|
Nice, France
Offline
Full Member
Karma: 10
Posts: 232
|
 |
« Reply #8 on: November 11, 2012, 12:16:11 am » |
Pages like this should be referenced in an "easy to find" place on the main Arduino website, or are they? Maybe, an extra link in the main Wire pages, etc, http://arduino.cc/en/Reference/Wireor the tutorial page, or somewheres where they're not buried with 1000 other links [like Playground]. Yes, wouldn't that be lovely.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Online
Shannon Member
Karma: 226
Posts: 14121
Lua rocks!
|
 |
« Reply #9 on: November 11, 2012, 12:21:35 am » |
I'm not sure how to edit that page, or indeed who has permission to do so.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #10 on: November 11, 2012, 03:03:00 am » |
Thanks for your links Nick. I did some further research on the matter of the SPI and I2C sharing data buses, and all the schematics i saw never showed any connection between the two. With regards to the program freezing when i open a file in the SD card, that is still happening. I am using the MPU6050 accelerometers and yesterday was able to get them to work simultaneously without using the MPY6050 library. Now i am still able to initialize the card but still can't open files. This is the code having to do with the SD card:
//Initialize Card in void setup() if (!SD.begin(CS_pin)) { Serial.println("Card Failure"); return; } Serial.println("Card Ready");
//Open file in void loop() after filtering the 6 values for the acc. and then outputting them to serial int output1=movingAvarageFilter.process(acc_Front.value.x); int output2=movingAvarageFilter1.process(acc_Front.value.y); int output3=movingAvarageFilter2.process(acc_Front.value.z); int output4=movingAvarageFilter3.process(acc_Rear.value.x); int output5=movingAvarageFilter4.process(acc_Rear.value.y); int output6=movingAvarageFilter5.process(acc_Rear.value.z); Serial.print(output1); Serial.print(","); Serial.print(output2); Serial.print(","); Serial.print(output3); Serial.print(","); Serial.print(output4); Serial.print(","); Serial.print(output5); Serial.print(","); Serial.println(output6);
File logFile = SD.open("LOG.csv", FILE_WRITE); if (logFile) { logFile.println("Hello");
logFile.close(); } else { Serial.println("Couldn't open log file"); }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Full Member
Karma: 5
Posts: 199
|
 |
« Reply #11 on: November 11, 2012, 09:36:56 am » |
Please post you complete code and not just snippets. Also, please use the code tags code tag This will very much improve the codes readability on the forum.
|
|
|
|
|
Logged
|
|
|
|
|
|