|| Back to Support & Help Documentation ||

M-Duino uSD

Memory Card

 

Secure Digital (SD) is a non-volatile memory card format developed by the SD Card Association (SDA) for use in portable devices.


The standard was introduced in August 1999 and has become the industry standard. The three companies formed SD-3C, LLC, a company that licenses and enforces intellectual property rights associated with SD memory cards and SD host and ancillary products.

The newer families of SD card improve card speed by increasing the bus rate (the frequency of the clock signal that strobes information into and out of the card). Whatever the bus rate, the card can signal to the host that it is "busy" until a read or a write operation is complete. Compliance with a higher speed rating is a guarantee that the card limits its use of the "busy" indication.

Bus interfaceCard logoBus logoBus speedSpec version
Default SpeedSD-Logo.svg SDHC-Logo.svg SDXC.svg SDUC.svg12.5 MB/s1.01
High Speed25 MB/s2.00
UHS-ISDHC-Logo.svg SDXC.svg SDUC.svgUHS-I.svg12.5 MB/s (SDR12) 
25 MB/s (SDR25) 
50 MB/s (SDR50, DDR50)
104 MB/s (SDR104)
3.01
UHS-IIUHS-II.svg156 MB/s (FD156)
312 MB/s (HD312)
4.00/4.10[40]
UHS-IIIUHS-III.svg312 MB/s (FD312)
624 MB/s (FD624)
6.0[41]
PCIe 3.0 / NVMeSDexpress.svg985 MB/s (FD985)7.0[42]

                                                                      SD speeds range

In embedded systems, most modern microcontrollers have built-in SPI logic that can interface to an SD card operating in its SPI mode, providing non-volatile storage. Even if a microcontroller lacks the SPI feature, the feature can be emulated by bit banging. For example, a home-brew hack combines spare General Purpose Input/Output (GPIO) pins of the processor of the Linksys WRT54G router with MMC support code from the Linux kernel. This technique can achieve throughput of up to 1.6 Mbit/s.

Sizes:

The micro form factor is the smallest SD card format.

  • microSD, microSDHC, microSDXC
  • 15 mm × 11 mm × 1.0 mm


Resultado de imagen de micro sd types

Micro SD Logos meaning



Hardware

Check the M-Duino Family products now!

IMPORTANT: Make sure that your Ethernet PLC is powered (12-24Vdc).

General features:

The maximum capacity is 4 GB. If a higher capacity is used, it will work correctly but only the first 4GB will work.
Allowed file system architectures: FAT32 & FAT16.

Switch configuration:

The micro SD uses the SPI communication to interact with the Arduino Mega. The SPI protocol is always enabled, as there are no switches that configure it. However there is a switch that must be placed to ON mode in order to communicate with the uSD:

D53(SD): If this Switch is OFF, it enables the Chip Select of the microSD socket and disables Q2.0. If this switch is ON, it enables the Q2.0 output, so if the switch is in ON mode the microSD can’t be used.


Switch

Analog Shield

Relay Shield

 

ON

OFF

ON

OFF

uSD 

D53(SD)

Q2.0

D53(SD)

-

D53(SD)

 

 


                       

                        Switch configuration

Connections

As follows you have a table and circuit diagram where you can see how to connect the SD card to the PLC.


SD socket Circuit Diagram


PLCSD CARD
MOSIMOSI
SCKSCK
PIN 53CS
CD
MISODO
GND
                                                                                                 
                                                                                                 SD socket connections table

Software

IMPORTANT: Make sure to download the Arduino based PLC boards for Arduino IDE.

Software Configuration

Using the boards of Industrial Shields, there is a library that simplifies the uSD implementation called SD. It is the same as the Arduino library, with the only modification of using the pin 53 to select the ChipSelect of the uSD chip.

So, firstable it is necessary to include the SD.h library provided in our boards:

#include <SD.h>

Also remember to include the SPI.h library:

#include <SPI.h>


SD Library - Functions

The SD library has 2 differentiated classes, which are shown below:

- SD class:

The SD class provides functions for accessing the SD card and manipulating its files and directories.

- functions:

- File class:

The File class allows for reading from and writing to individual files on the SD card.

- functions:

Example Code:

#include <SD.h>
Sd2Card card;
SdVolume volume;

///////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
  Serial.begin(9600L);
  Serial.println("M-Duino PLUS test started");

// we'll use the initialization code from the utility libraries
// since we're just testing if the card is working!
  if (!card.init(SPI_HALF_SPEED, 53)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card inserted?");
    Serial.println("* is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
    Serial.println("Wiring is correct and a card is present.");
  }

  // print the type of card
  Serial.print("\nCard type: ");
  switch (card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
  } else {
    // print the type and size of the first FAT-type volume
    uint32_t volumesize;
    Serial.print("\nVolume type is FAT");
    Serial.println(volume.fatType(), DEC);
    Serial.println();
  
    volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
    volumesize *= volume.clusterCount();       // we'll have a lot of clusters
    volumesize *= 512;                            // SD card blocks are always 512 bytes
    Serial.print("Volume size (bytes): ");
    Serial.println(volumesize);
    Serial.print("Volume size (Kbytes): ");
    volumesize /= 1024;
    Serial.println(volumesize);
    Serial.print("Volume size (Mbytes): ");
    volumesize /= 1024;
    Serial.println(volumesize);
  }
}

///////////////////////////////////////////////////////////////////////////////////////////////
void loop() {}


     By following these steps carefully, you will be able to achieve the use of the uSD using the Industrial Shields equipments.


1 Star 2 Star 3 Star 4 Star 5 Star