Hi all ;D ,
I recently bought a MEGA Sensor Shield V2.4. I was so happy that not only it had a micro SD card slot on it, but it also allows me to put another shield on it. I had a look at the Wiki page of this shield:
http://www.dfrobot.com/wiki/index.php/Mega_IO_Expansion_Shield_V2.3_(SKU:DFR0165)
However, that is V2.3 of the shield not V2.4, which is what I have. The website that I bought the shield from had this page as the Wiki page which is for V2.1 of the shield:
http://www.dfrobot.com/wiki/index.php?title=Mega_IO_Expansion_Shield_V2(SKU:DFR0165)
It is funny
because on the vendor's website it says V2.1, while they have clearly sent me a V2.4 shield.
Now I am confused in two ways:
Why on V2.1 the SS pin is set to pin 4 and not 53 (pin 53 is normally the SS on Mega boards). Correct me if I am wrong, but that means that I have to assert both pin 53 and pin 4 as Outputs, right? I had a look at the schematics of the shield, but could not get much out of it, but I am assuming that pin 4 of the shield must be connected to pin 53 of Mega. Therefore, maybe I only need to set pin 53 as Output, but meanwhile make sure that pin 4 on the shield is not an input.
My second issue is that I am not sure whether the same situation applies to V2.4 of the shield. In other words, did they connected the SS pin to 53 on the shield or is it still connected to pin 4 on the shield?
Your help and ideas are much appreciated 
D53 is the hardware slave select on the Mega. It must be set to OUTPUT to set the Mega's SPI bus to master mode.
D4 is the SD slave select. It must be set to OUTPUT to enable and disable the SD SPI. This is done in the SD.begin(4) call.
D53 is the hardware slave select on the Mega. It must be set to OUTPUT to set the Mega's SPI bus to master mode.
D4 is the SD slave select. It must be set to OUTPUT to enable and disable the SD SPI. This is done in the SD.begin(4) call.
hmmm.... I am a bit confused. Moreover, the stuff I have read over the internet such as on Arduino's website make things even more confusing. For example here's a quote straight from the Arduino webpage:
The communication between the microcontroller and the SD card uses SPI, which takes place on digital pins 11, 12, and 13 (on most Arduino boards) or 50, 51, and 52 (Arduino Mega). Additionally, another pin must be used to select the SD card. This can be the hardware SS pin - pin 10 (on most Arduino boards) or pin 53 (on the Mega) - or another pin specified in the call to SD.begin(). Note that even if you don't use the hardware SS pin, it must be left as an output or the SD library won't work. Different boards use different pins for this functionality, so be sure you’ve selected the correct pin in SD.begin().
The paragraph clearly says a hardware select pin (i.e pin 53 on Mega) or another pin specified by SD.begin() can be used for selecting the SD card. So how can pin 53 be hardware SS and at the same time SD's SS? In such situation if I make pin 53 an OUTPUT both SD and micro-controller will be master and when pin 53 is LOW they are both slaves, so how is this going to work?
Then I bump into another issue; let's say pin 53 should always be kept an OUTPUT to keep the micro-controller in master mode, but what about pin 4 in my case? Is there an electrical connection from pin 4 to the SD card's SS or can I use SD.begin() to pick any other pin for SD's SS and do whatever I want with pin 4?
The page you posted the link to in your OP is very clear. The SD card slave select (SS) on that shield is D4.
1 microSD slot (SCK=52, MISO=50, MOSI=51 and SS=4)
You can change that (I guess) with some pin bending and a jumper, but why?
Firstly, thank you for you response 
You can change that (I guess) with some pin bending and a jumper, but why?
Because I wanted to use that pin 4 for a ADC shield that I was making, but that is easily fixable. The thing that was bugging me is understanding the concept
. So, based on your response it is obvious that pin 4 of the mega shield is electrically connected to SS of SD card slot. Also, what really confused me was the Arduino website saying that one can connect the SS pin of the SD card to the hardware SS pin (i.e. pin 53). So this is my current understanding: people who made the mega shield could connect the SS of the SD card to pin 53, but for some reason they decided to connect it to pin 4. Now, if the SD card's SS pin was connected to pin 53 of mega I could just output that pin low and "select" the SD card for further operations, right? 
OK. Bend the D4 pin on the shield so it does not connect to D4 on the Mega, then use a wire jumper from D4 to D53 on the shield. Then use SD.begin(53);
edit: However, this will not feed D4 through to a shield above the Mega sensor shield. 
You would need to bend D4 on the ADC shield so it doesn't insert into the Mega sensor shield, then jumper D4 on the Mega to D4 on the ADC shield.
The concept is that they probably didn't want you to have to run any wires when you connect this thing, and they just had to pick a pin for SS. Maybe the trace was shortest if they routed it to D4. SS is the only one that can be any pin. The others have to go where the SPI bus actually is. For each device you add to the bus, they all connect to the same pins EXCEPT for SS, which has be unique for each device.
The concept is that they probably didn't want you to have to run any wires when you connect this thing, and they just had to pick a pin for SS. Maybe the trace was shortest if they routed it to D4. SS is the only one that can be any pin. The others have to go where the SPI bus actually is. For each device you add to the bus, they all connect to the same pins EXCEPT for SS, which has be unique for each device.
I see. That makes sense. So I do not have to connect my peripheral device to the hardware SS pin (i.e. pin 53 on Mega), as long as I use a function like SD.begin() to determine the SS pin. Moreover, am I right that the hardware SS pin (i.e. 53) can be used for allowing several micro-controllers to talk to each other?
Cheers 
Yes. Just watch out for how your libraries of choice define the SS/CS pin. Some have it in the constructor and some use #defines. I've encountered both. I prefer #defines but the constructor method is easier to understand in the beginning. And yes pin 53 can be used to address your Mega as a slave. You can see this for more.