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?
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 =/
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.
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,
or the tutorial page, or somewheres where they're not buried with 1000 other links [like Playground].
oric_dan(333):
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,
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);