“SKU:RB-02S018A TF卡讀寫模塊”的版本間的差異

來自ALSROBOT WiKi
跳轉至: 導航搜索
?產品相關推薦
 
(未顯示1個用戶的17個中間版本)
第1行: 第1行:
?
[[文件:02S018A01.png|500px|有框|右]]
+
[[文件:02S018A001.png|500px|有框|右]]
 
==產品概述==
 
==產品概述==
 
該模塊(MicroSD Card Adapter)是Micro SD卡讀寫模塊,通過文件系統(tǒng)及SPI接口驅動程序,單片機系統(tǒng)即可完成MicroSD卡內的文件進行讀寫。Arduino用戶可直接使用Arduino IDE自帶的SD卡程序庫即可完成卡的初始化和讀寫。<br/>
 
該模塊(MicroSD Card Adapter)是Micro SD卡讀寫模塊,通過文件系統(tǒng)及SPI接口驅動程序,單片機系統(tǒng)即可完成MicroSD卡內的文件進行讀寫。Arduino用戶可直接使用Arduino IDE自帶的SD卡程序庫即可完成卡的初始化和讀寫。<br/>
第16行: 第16行:
 
# 通信接口:標準 SPI 接口
 
# 通信接口:標準 SPI 接口
 
# 支持卡類型:Micro SD 卡(< = 2G),Micro SDHC 卡(< = 32G)
 
# 支持卡類型:Micro SD 卡(< = 2G),Micro SDHC 卡(< = 32G)
?
==接口定義==
+
# 電源指示燈:紅色
 +
# 數(shù)據傳輸指示燈:藍色
 +
 
 +
10.接口定義<br/>
 
* + :電源正
 
* + :電源正
 
* - :電源地
 
* - :電源地
第24行: 第27行:
 
* CS :片選信號,由控制器進行控制
 
* CS :片選信號,由控制器進行控制
 
[[文件:02S018A02.png|500px|有框|居中]]
 
[[文件:02S018A02.png|500px|有框|居中]]
?
==使用方法==
+
 
?
===工作原理===
+
==工作原理==
?
TF 卡模塊使用 SPI 總線連接方式實現(xiàn)與 Arduino 控制器的通信,穩(wěn)壓芯片輸出的 3.3V 為電平轉換芯片、Micro SD 卡進行供電,電平轉換電路往 Micro SD 卡方向的信號轉換成 3.3V,Micro SD 卡往控制接口方向的 MISO 信號也轉換成了 3.3V,一般 AVR 單片機系統(tǒng)都可以讀取該信號,產品使用自彈式卡座,方便卡的插拔。
+
TF 卡模塊使用 SPI 總線連接方式實現(xiàn)與 Arduino 控制器的通信,穩(wěn)壓芯片輸出的 3.3V 為電平轉換芯片、Micro SD 卡進行供電,電平轉換電路往 Micro SD 卡方向的信號轉換成 3.3V,Micro SD 卡往控制接口方向的 MISO 信號也轉換成了 3.3V,一般 AVR 單片機系統(tǒng)都可以讀取該信號,產品使用自彈式卡座,方便卡的插拔。<br/>
?
===編程原理===
+
注意:Arduino 的 sd.h 庫文件目前對 2G 及其以下的支持比較好,對 2G 以上的支持不好,所以在使用時,建議選用 2G 或以下的內存卡。
 +
==編程原理==
 
TF 卡模塊共引出 6 個引腳,其中 DO、CK、DI 是 SPI 總線接口,“+”為電源正,“-”為電源 GND,CS 為片選端,實際使用時依照下面的接線圖連接即可,使用 Arduino IDE 自帶的例子程序就可以進行測試。
 
TF 卡模塊共引出 6 個引腳,其中 DO、CK、DI 是 SPI 總線接口,“+”為電源正,“-”為電源 GND,CS 為片選端,實際使用時依照下面的接線圖連接即可,使用 Arduino IDE 自帶的例子程序就可以進行測試。
?
===連接示意圖===
 
?
[[文件:02S018A03.png|700px|有框|居中]]
 
?
===例子程序===
 
?
<pre style='color:blue'>
 
?
/*
 
?
  SD card test
 
  
?
  * SD card attached to SPI bus as follows:
+
==使用方法==
?
** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila
+
===example1_Arduino===
?
** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila
+
* 主要硬件
?
** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila
+
:Arduino UNO 控制器
?
** CS - depends on your SD card shield or module.
+
:傳感器擴展板 V5.0
?
Pin 4 used here for consistency with other Arduino examples
+
:TF卡讀寫模塊
 +
:單頭防插反 3P 傳感器連接線
 +
:USB 數(shù)據線
  
 +
* 硬件連接
 +
[[文件:02S018A_1.png|660px|縮略圖|居中]]
 +
 +
* 例子程序
 +
<pre style='color:blue'>
 +
/*
 +
* TF 卡模塊與 Arduino UNO的接線
 +
DI -- D11
 +
CS -- D4
 +
CK -- D13
 +
DO -- D12
 
  */
 
  */
?
// include the SD library:
 
 
#include <SPI.h>
 
#include <SPI.h>
 
#include <SD.h>
 
#include <SD.h>
  
?
// set up variables using the SD utility library functions:
 
 
Sd2Card card;
 
Sd2Card card;
 
SdVolume volume;
 
SdVolume volume;
 
SdFile root;
 
SdFile root;
  
?
// change this to match your SD shield or module;
 
?
// Arduino Ethernet shield: pin 4
 
?
// Adafruit SD shields and modules: pin 10
 
?
// Sparkfun SD shield: pin 8
 
 
const int chipSelect = 4;
 
const int chipSelect = 4;
  
?
void setup()
+
void setup() {
?
{
+
?
  // Open serial communications and wait for port to open:
+
 
   Serial.begin(9600);
 
   Serial.begin(9600);
 
   while (!Serial) {
 
   while (!Serial) {
?
     ; // wait for serial port to connect. Needed for Leonardo only
+
     ;  
 
   }
 
   }
?
 
?
 
 
   Serial.print("\nInitializing SD card...");
 
   Serial.print("\nInitializing SD card...");
 +
  if (!SD.begin(4)) {
 +
    Serial.println("initialization failed");
 +
    return;
 +
  }
 +
    Serial.println("Wiring is correct and a card is present.");
  
?
  // 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, chipSelect)) {
 
   if (!card.init(SPI_HALF_SPEED, chipSelect)) {
?
     Serial.println("initialization failed. Things to check:");
+
     Serial.println("initialization failed. Check: SD Card");
?
    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;
 
     return;
 
   } else {
 
   } else {
?
     Serial.println("Wiring is correct and a card is present.");
+
     Serial.println("============= Card Information ==================");
 
   }
 
   }
?
 
+
Serial.print("Card type: ");
?
  // print the type of card
+
?
  Serial.print("\nCard type: ");
+
 
   switch (card.type()) {
 
   switch (card.type()) {
 
     case SD_CARD_TYPE_SD1:
 
     case SD_CARD_TYPE_SD1:
第95行: 第94行:
 
       break;
 
       break;
 
     default:
 
     default:
?
       Serial.println("Unknown");
+
       Serial.println("Unknow");
 
   }
 
   }
?
 
+
    if (!volume.init(card)) {
?
  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
+
     Serial.println("Could not find FAT16/FAT32 partition.");
?
  if (!volume.init(card)) {
+
?
     Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
+
 
     return;
 
     return;
 
   }
 
   }
?
 
+
   // 顯示類型和 FAT 空間大小
?
 
+
?
   // print the type and size of the first FAT-type volume
+
 
   uint32_t volumesize;
 
   uint32_t volumesize;
?
   Serial.print("\nVolume type is FAT");
+
   Serial.print("Volume type is FAT");
 
   Serial.println(volume.fatType(), DEC);
 
   Serial.println(volume.fatType(), DEC);
 
   Serial.println();
 
   Serial.println();
第122行: 第117行:
 
   volumesize /= 1024;
 
   volumesize /= 1024;
 
   Serial.println(volumesize);
 
   Serial.println(volumesize);
?
 
  
 
   Serial.println("\nFiles found on the card (name, date and size in bytes): ");
 
   Serial.println("\nFiles found on the card (name, date and size in bytes): ");
 
   root.openRoot(volume);
 
   root.openRoot(volume);
  
?
  // list all files in the card with date and size
 
 
   root.ls(LS_R | LS_DATE | LS_SIZE);
 
   root.ls(LS_R | LS_DATE | LS_SIZE);
 +
 +
  Serial.println("================= Finished =====================");
 
}
 
}
  
第136行: 第131行:
 
}
 
}
 
</pre>
 
</pre>
?
===程序效果===
+
 
 +
* 程序效果
 
程序編譯上傳無誤之后,將準備好的 TF 卡插入到模塊中,連接 TF 卡模塊和 Arduino UNO 控制器,連接正常情況下,會顯示出卡的信息,如下圖所示:
 
程序編譯上傳無誤之后,將準備好的 TF 卡插入到模塊中,連接 TF 卡模塊和 Arduino UNO 控制器,連接正常情況下,會顯示出卡的信息,如下圖所示:
?
[[文件:02S018A04.png|500px|有框|居中]]
+
[[文件:02S018A_2.png|530px|縮略圖|居中]]
  
?
==產品相關推薦==
+
===example2_Arduino===
?
[[文件:erweima.png|230px|無框|右]]
+
* 主要硬件
?
===產品購買地址===
+
:Arduino UNO 控制器
 +
:傳感器擴展板 V5.0
 +
:TF卡讀寫模塊
 +
:單頭防插反 3P 傳感器連接線
 +
:USB 數(shù)據線
  
?
===周邊產品推薦===
+
* 硬件連接
 +
[[文件:02S018A_1.png|660px|縮略圖|居中]]
  
?
===相關問題解答===
+
* 例子程序
 +
<pre style='color:blue'>
 +
/*
 +
* TF 卡模塊與 Arduino UNO的接線
 +
DI -- D11
 +
CS -- D4
 +
CK -- D13
 +
DO -- D12
 +
*/
  
 +
#include <SPI.h>
 +
#include <SD.h>
 +
 +
File myFile;
 +
 +
//設置功能變量
 +
Sd2Card card;
 +
SdVolume volume;
 +
SdFile root;
 +
 +
const int chipSelect = 4;
 +
 +
void setup() {
 +
 +
  Serial.begin(9600); 
 +
  while (!Serial) {   
 +
  }
 +
 +
  //----------- 寫入文檔
 +
  Serial.print("\nWaiting for SD card ready...");
 +
 +
  if (!SD.begin(4)) {
 +
    Serial.println("Fail!");
 +
    return;
 +
  }
 +
  Serial.println("Success!");
 +
 +
  myFile = SD.open("card.txt", FILE_WRITE);      // 開啟文檔,一次只能開啟一個文檔
 +
 
 +
  if (myFile) {                                  // 如果文檔正常
 +
    Serial.print("Write to card.txt...");       
 +
    myFile.println("Test to write data to SD card...");  // 繼續(xù)寫在文檔的后面
 +
    myFile.close();                              // 關閉文檔
 +
    Serial.println("Completed!");
 +
  } else {
 +
    Serial.println("\n open file error ");    // 無法打開文檔時,打印“open file error”
 +
  }
 +
 
 +
  //----------- 顯示SD卡信息
 +
 +
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
 +
    Serial.println("initialization failed. Check: SD Card");
 +
    return;
 +
  } else {
 +
    Serial.println("============= Card Information ==================");
 +
  }
 +
 +
  // 顯示 SD 卡類型
 +
 +
  Serial.print("Card 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("Unknow");
 +
  }
 +
 +
  if (!volume.init(card)) {
 +
    Serial.println("Could not find FAT16/FAT32 partition.");
 +
    return;
 +
  }
 +
 +
  // 顯示類型和FAT空間的大小
 +
  uint32_t volumesize;
 +
  Serial.print("Volume type is FAT");
 +
  Serial.println(volume.fatType(), DEC);
 +
  Serial.println();
 +
 +
  volumesize = volume.blocksPerCluster();   
 +
  volumesize *= volume.clusterCount();     
 +
  volumesize *= 512;                           
 +
  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);
 +
 +
  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
 +
  root.openRoot(volume);
 +
 +
  // 列出卡內所有文件及 SD 卡的尺寸
 +
  root.ls(LS_R | LS_DATE | LS_SIZE);
 +
 +
  Serial.println("================= Finished =====================");
 +
}
 +
 +
void loop() {     
 +
}
 +
</pre>
 +
 +
* 程序效果
 +
程序編譯上傳無誤之后,將準備好的 TF 卡插入到模塊中,連接 TF 卡模塊和 Arduino UNO 控制器,連接正常情況下,會顯示出卡的信息,如下圖所示:
 +
[[文件:02S018A_3.png|530px|縮略圖|居中]]
 +
 +
==產品相關推薦==
 +
[[文件:erweima.png|230px|無框|右]]
 +
===資料下載===
 +
網盤鏈接: https://pan.baidu.com/s/1CiwpDShiB_Seityve6HVEQ
 +
提取碼:i4dp
 +
 +
===產品購買地址===
 +
Arduino TF卡讀寫存儲模塊:http://gharee.com/goods-782.html
 
===相關學習資料===
 
===相關學習資料===
 
[http://www.makerspace.cn/portal.php 奧松機器人技術論壇]<br/>
 
[http://www.makerspace.cn/portal.php 奧松機器人技術論壇]<br/>

2021年7月21日 (三) 11:39的最后版本

02S018A001.png

目錄

產品概述

該模塊(MicroSD Card Adapter)是Micro SD卡讀寫模塊,通過文件系統(tǒng)及SPI接口驅動程序,單片機系統(tǒng)即可完成MicroSD卡內的文件進行讀寫。Arduino用戶可直接使用Arduino IDE自帶的SD卡程序庫即可完成卡的初始化和讀寫。
模塊特點如下:

  • 支持Micro SD卡、Micro SDHC卡(高速卡)
  • 板載電平轉換電路,即接口電平可為5V或3.3V
  • 供電電源為4.5V - 5.5V,板載3.3V穩(wěn)壓電路
  • 通信接口為標準SPI接口
  • 4個M2螺絲定位孔,便于安裝

規(guī)格參數(shù)

  1. 工作電壓:3.3V - 5V
  2. 產品尺寸:40mm * 28mm
  3. 重量大?。?g
  4. 信號類型:模擬信號
  5. 固定孔:M3 * 4個
  6. 通信接口:標準 SPI 接口
  7. 支持卡類型:Micro SD 卡(< = 2G),Micro SDHC 卡(< = 32G)
  8. 電源指示燈:紅色
  9. 數(shù)據傳輸指示燈:藍色

10.接口定義

  • + :電源正
  • - :電源地
  • DI :串行數(shù)據輸入
  • DO :串行數(shù)據輸出
  • CK :串行時鐘
  • CS :片選信號,由控制器進行控制
02S018A02.png

工作原理

TF 卡模塊使用 SPI 總線連接方式實現(xiàn)與 Arduino 控制器的通信,穩(wěn)壓芯片輸出的 3.3V 為電平轉換芯片、Micro SD 卡進行供電,電平轉換電路往 Micro SD 卡方向的信號轉換成 3.3V,Micro SD 卡往控制接口方向的 MISO 信號也轉換成了 3.3V,一般 AVR 單片機系統(tǒng)都可以讀取該信號,產品使用自彈式卡座,方便卡的插拔。
注意:Arduino 的 sd.h 庫文件目前對 2G 及其以下的支持比較好,對 2G 以上的支持不好,所以在使用時,建議選用 2G 或以下的內存卡。

編程原理

TF 卡模塊共引出 6 個引腳,其中 DO、CK、DI 是 SPI 總線接口,“+”為電源正,“-”為電源 GND,CS 為片選端,實際使用時依照下面的接線圖連接即可,使用 Arduino IDE 自帶的例子程序就可以進行測試。

使用方法

example1_Arduino

  • 主要硬件
Arduino UNO 控制器
傳感器擴展板 V5.0
TF卡讀寫模塊
單頭防插反 3P 傳感器連接線
USB 數(shù)據線
  • 硬件連接
02S018A 1.png
  • 例子程序
/*
 * TF 卡模塊與 Arduino UNO的接線
DI -- D11
CS -- D4
CK -- D13
DO -- D12
 */
#include <SPI.h>
#include <SD.h>

Sd2Card card;
SdVolume volume;
SdFile root;

const int chipSelect = 4;

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; 
  }
  Serial.print("\nInitializing SD card...");
  if (!SD.begin(4)) {
    Serial.println("initialization failed");
    return;
  } 
    Serial.println("Wiring is correct and a card is present.");

  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Check: SD Card");
    return;
  } else {
    Serial.println("============= Card Information ==================");
  }
 Serial.print("Card 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("Unknow");
  }
    if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.");
    return;
  }
  // 顯示類型和 FAT 空間大小
  uint32_t volumesize;
  Serial.print("Volume 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);

  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);

  root.ls(LS_R | LS_DATE | LS_SIZE);

  Serial.println("================= Finished =====================");
}


void loop(void) {

}
  • 程序效果

程序編譯上傳無誤之后,將準備好的 TF 卡插入到模塊中,連接 TF 卡模塊和 Arduino UNO 控制器,連接正常情況下,會顯示出卡的信息,如下圖所示:

02S018A 2.png

example2_Arduino

  • 主要硬件
Arduino UNO 控制器
傳感器擴展板 V5.0
TF卡讀寫模塊
單頭防插反 3P 傳感器連接線
USB 數(shù)據線
  • 硬件連接
02S018A 1.png
  • 例子程序
/*
 * TF 卡模塊與 Arduino UNO的接線
DI -- D11
CS -- D4
CK -- D13
DO -- D12
 */

#include <SPI.h>
#include <SD.h>

File myFile;

//設置功能變量
Sd2Card card;
SdVolume volume;
SdFile root;

const int chipSelect = 4;

void setup() {

  Serial.begin(9600);  
  while (!Serial) {    
  }

  //----------- 寫入文檔
  Serial.print("\nWaiting for SD card ready...");

  if (!SD.begin(4)) {
    Serial.println("Fail!");
    return;
  }
  Serial.println("Success!");

  myFile = SD.open("card.txt", FILE_WRITE);       // 開啟文檔,一次只能開啟一個文檔
  
  if (myFile) {                                   // 如果文檔正常
    Serial.print("Write to card.txt...");         
    myFile.println("Test to write data to SD card...");  // 繼續(xù)寫在文檔的后面
    myFile.close();                               // 關閉文檔
    Serial.println("Completed!");
  } else {
    Serial.println("\n open file error ");    // 無法打開文檔時,打印“open file error”
  }
  
   //----------- 顯示SD卡信息

  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Check: SD Card");
    return;
  } else {
    Serial.println("============= Card Information ==================");
  }

  // 顯示 SD 卡類型

  Serial.print("Card 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("Unknow");
  }

  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.");
    return;
  }

  // 顯示類型和FAT空間的大小
  uint32_t volumesize;
  Serial.print("Volume type is FAT");
  Serial.println(volume.fatType(), DEC);
  Serial.println();

  volumesize = volume.blocksPerCluster();    
  volumesize *= volume.clusterCount();       
  volumesize *= 512;                            
  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);

  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);

  // 列出卡內所有文件及 SD 卡的尺寸
  root.ls(LS_R | LS_DATE | LS_SIZE);

  Serial.println("================= Finished =====================");
}

void loop() {      
}
  • 程序效果

程序編譯上傳無誤之后,將準備好的 TF 卡插入到模塊中,連接 TF 卡模塊和 Arduino UNO 控制器,連接正常情況下,會顯示出卡的信息,如下圖所示:

02S018A 3.png

產品相關推薦

Erweima.png

資料下載

網盤鏈接: https://pan.baidu.com/s/1CiwpDShiB_Seityve6HVEQ 提取碼:i4dp

產品購買地址

Arduino TF卡讀寫存儲模塊:http://gharee.com/goods-782.html

相關學習資料

奧松機器人技術論壇