I'm working on an arduino project, but i’m dealing with an problem for quite a while now.
I'm trying to communicate via the SPI data bus between a few components.
My components are:
-Master: Arduino Uno
-Slave: GPS Modul ORG-13XX (GPS-Module Data-Sheet) on a antrax GPS/GSM shield (Shield). I connect the necessary SPI pins via wires to the arduino,
because otherwise it would block all the other pins i need for other components.
-Slave: LC Soft SD Card Reader (SD-Card-Socket)
(- sonar for water depth information via serial interface TX/RX)
Task is to save the GPS data on the SD card.
(Later join also data from a sonar, to complete informations for "under-water-maps".)
The hardware part (wiring) is already done, my questions target the software part.
My primary goal is to communicate with the different parts via SPI using the specific libraries.
If this is not possible, i have to go one step "backwards" and use the original SPI way and transfer bits from the master to the slaves and reverse.
Is this correct after all and is it possible to use the SPI bus working with the hardware libraries??
Here is a recent discussion on a similar project. It uses Serial, not SPI, so this is a "different way".
Roonpower:
My primary goal is to communicate with the different parts via SPI using the specific libraries.
It is possible to use multiple SPI hardware libraries, but you haven't pointed us to the libraries. Many hardware libraries are written as if they are the only library using the SPI. Then, when you try to use 2 libraries, they conflict with each other.
It is also possible to read/write SPI commands and data yourself, using the hardware specifications. Is this what you mean by "original SPI way"?
From looking at your other posts, I am concerned that you are trying to learn too many things, all at the same time. I would suggest an incremental approach:
Get the basic SD card examples to work, because this is a common SPI library.
Without any SD code, get the basic GPS examples to work. You may try SPI+TinyGPS libraries, or you may try a hardware-specific library. (I have written a GPS library called NeoGPS, but I don't recommend it to you at this time.) Just print some GPS data to Serial. This will help you understand the timed behavior of GPS devices in general, and how your GPS device acquires a fix.
Add the SD library to your GPS sketch and merge in some of the SD-writing code. Write something simple in setup first. When that works, start writing GPS data in loop. You will have to understand the timing of these operations. The GPS device can emit lots of data, and its easy to lose some bytes.
Take the same approach with the sounder: start with just the sounder library. Print some data. Then try adding SD or GPS (just one of them). Then add the other piece. Then try writing to the SD card. Again, understanding the timing will help you coordinate the operations.
Taking smaller steps will also be good when you need help. Don't throw everything into one program and ask why it doesn't work. By taking smaller steps, you can say "This program worked until I added this one part. Why doesn't it compile?" It's easier for us to answer that kind of question.
Also, be sure to read this. Pics and circuit diagrams are very useful, sometimes required. Code is always required, because we can't read your mind. And please use [ϲode] tags, attach the files, or provide a link to their online location.