microSD card reader module - SDRamps (HCMODU0044)

Products related to 3D printing and CNC machines.
Post Reply
admin
Site Admin
Posts: 874
Joined: Sun Aug 05, 2012 4:02 pm

microSD card reader module - SDRamps (HCMODU0044)

Post by admin » Fri Oct 11, 2013 2:27 pm

Image

Description:
A microSD card reader module with built in 3.3V level shifter which allows safe interfacing to any microSD cards that support an SPI interface. This module has primarily been designed to work with our RAMPS compatible 3D printer shield (See HC3DPR0002 in our shop). The module will directly interface with the AUX-3 connector on the RAMPS shield.

Although designed for this purpose in mind, this module will work fine with any microcontoller with 5V tolerant DIO that supports a hardware or software SPI interface (see example Arduino sketch below)

PINOUT:
1...VCC
2...N/A
3...MISO
4...MOSI
5...SCK
6...CS
7...N/A
8...N/A


26/02/2015 Please note: We are currently chipping an alternative SD ramps version with a slightly different connector. However pinout is in the same order. Please see diagram below for more information:

Image



Example Arduino Sketch:

Code: Select all

/* FILE:    ARD_SDRAMPS_MICROSD_MODULE_HCMODU0041_READ_EXAMPLE
   DATE:    11/10/13
   VERSION: 0.1

REVISIONS:

11/10/13 Created version 0.1

This is an example of how to use the HobbyComponents SDramps microSD card
reader module (HCMODU0041). This module allows reading and writing of data
to a standard microSD card and is useful for applications such as 3D printers, 
data loggers where a large amount of data needs to be stored. The module works
with the standard Arduino SD card library.

This example program will attempt to read a text file named text.txt and 
output its contents to the serial port. 

PINOUT:

Module              UNO/NANO
PIN 1:  VCC    --->  +5V
PIN 2:  N/A    --->  N/A
PIN 3:  MISO   --->  D12
PIN 4:  MOSI   --->  D11
PIN 5:  SCLK   --->  D13
PIN 6:  CS     --->  D4
PIN 7:  GND    --->  GND
PIN 8:  N/A    --->  N/A
PIN 9:  N/A    --->  N/A
PIN 10: N/A    --->  N/A


You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used for the purpose of premoting or selling products 
that directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER. */

/* Include the standard SD card library */
#include <SD.h>

#define SD_CARD_CD_DIO 4 /* DIO pin used to control the modules CS pin */

File SDFileData;

/* Initialise serial and DIO */
void setup()
{
  Serial.begin(9600);
  /* DIO pin used for the CS function. Note that even if you are not driving this
     function from your Arduino board, you must still configure this as an output 
     otherwise the SD library functions will not work. */
  pinMode(10, OUTPUT);
}

/* Main program loop */
void loop()
{

  /* Initiliase the SD card */
  if (!SD.begin(SD_CARD_CD_DIO)) 
  {
    /* If there was an error output this to the serial port and go no further */
    Serial.println("ERROR: SD card failed to initiliase");
    while(1);
  }else
  {
    Serial.println("SD Card OK");
  }
  
 
   /* Check if the text file exists */
   if(SD.exists("test.txt"))
   {
     Serial.println("test.txt exists, attempting to read file...");

     /* The file exists so open it */
     SDFileData = SD.open("test.txt");
     
     /* Sequentially read the data from the file and output it's
        contents to the UART */
     while (SDFileData.available())
     {
       Serial.write(SDFileData.read());
     }
     
     /* Close the file */
     SDFileData.close();  
   }
 
  
  /* Do nothing */
  while (1);
}

Javi
Posts: 1
Joined: Thu Oct 24, 2013 9:32 am

Re: microSD card reader module - SDRamps (HCMODU0044)

Post by Javi » Thu Oct 24, 2013 9:50 am

Hello,

I received yesterday this micro SD module and I uploaded the following code:

Code: Select all

//Program by Jeremy Blum
//www.jeremyblum.com
//SD Card Demonstration
//Based on Example by Tom Igoe

#include <SD.h>

//Set by default for the SD Card Library
//MOSI = Pin 11
//MISO = Pin 12
//SCLK = PIN 13
//We always need to set the CS Pin
int CS_pin = 4;
int pow_pin = 10;

void setup()
{
  Serial.begin(9600);
  Serial.println("Initializing Card");
  //CS Pin is an output
  pinMode(CS_pin, OUTPUT);
  
  //Card will Draw Power from Pin 8, so set it high
  pinMode(pow_pin, OUTPUT);  
  digitalWrite(pow_pin, HIGH);
  
  if (!SD.begin(CS_pin))
  {
      Serial.println("Card Failure");
      return;
  }
  Serial.println("Card Ready");
  
}

void loop()
{
  String dataString = "Hello";
  
  //Open a file to write to
  //Only one file can be open at a time
  
  File dataFile = SD.open("log.txt", FILE_WRITE);
  if (dataFile)
  {
    dataFile.println(dataString);
    dataFile.close();
    Serial.println(dataString);
  }
  else
  {
    Serial.println("Couldn't open log file");
  }
  delay(5000);
}
When I run the program, the serial monitor shows:

Initializing Card
Card Ready
Hello
Couldn't open log file


When I check the SD card in the computer, it creates a LOG.txt despite the program code is File dataFile = SD.open("log.txt", FILE_WRITE); Basically, looks like is case sensitive. The word hello is also present in the created LOG.txt file. Looks like that for some reason is not closing the file after writing on it and then cannot open it again?

I also check the example provided in this forum and the result is that the card is OK but the test.txt file is not created in the card. So when I plug the card in the computer, there is nothing there.

Does anyone knows what am I doing wrong?

Thank you,

Javi

andrew
Site Admin
Posts: 1407
Joined: Sun Aug 05, 2012 4:15 pm

Re: microSD card reader module - SDRamps (HCMODU0044)

Post by andrew » Thu Oct 24, 2013 11:01 am

The example sketch in the first post doesn't actually create the test.txt file, you have to create it yourself from your computer. The sketch is just a modified version of the the one in the SD card module post here: http://forum.hobbycomponents.com/viewtopic.php?f=39&t=5

In that post there is also a sketch that will write to the card. Although we haven't tested it with this module it should work fine. So I would suggest giving that a try.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

uobstudent
Posts: 8
Joined: Thu Mar 06, 2014 1:08 pm

Re: microSD card reader module - SDRamps (HCMODU0044)

Post by uobstudent » Wed Mar 26, 2014 3:42 pm

How would I go about reading individual lines of the SD card of varying length? (From 9 to 12 characters) I'd imagine I can use a break variable when I save the data then use the Seek() to choose the line to read? But I'm not sure how to tell it to stop reading at the break variable. Or is there a readLine() method of some kind which I can use?
Thanks.

Agustin
Posts: 1
Joined: Tue May 01, 2018 5:01 am

Re: microSD card reader module - SDRamps (HCMODU0044)

Post by Agustin » Tue May 01, 2018 5:12 am

Hello, I have a module HCMODU0044 and I would like to ask how can I play music from the SD card?

Post Reply

Return to “3D Printing / CNC”