نمایش نتایج: از 1 به 8 از 8
Like Tree3 لایک
  • 1 Post By magmagmary
  • 1 Post By magmagmary
  • 1 Post By magmagmary

موضوع: مشکل در وصل کردن ماژول sd card به آردوینو مگا

  1. #1
    Junior Member
    تاریخ عضویت
    Oct 2016
    نوشته ها
    3

    مشکل در وصل کردن ماژول sd card به آردوینو مگا

    سلام من دارم برای وصل کردن ماژول sd card به آردوینو مگا از شماتیک زیر استفاده میکنم.

    برای دیدن سایز بزرگ روی عکس کلیک کنید

نام: arduino-SD-sch.jpg
مشاهده: 464
حجم: 74.7 کیلو بایت
    و از کد زیر برای آردوینو
    کد:
    #include <SD.h>
    
    void setup() {
    pinMode(53,OUTPUT);
    digitalWrite(53,HIGH);
    Serial.begin(9600);
    if(SD.begin(53))
    {
    * Serial.println("True");
    }
    else
    {
    * Serial.println("False");
    }
    
    }
    
    void loop() {
    * // put your main code here, to run repeatedly:
    
    }
    مشکل اینجاست که توی خروجی سریال همیشه مقدار ۰ رو بهم برمیگردونه.
    تصاویر کوچک شده (Thumbnails) پیوست شده تصاویر کوچک شده (Thumbnails) پیوست شده hpbfo.jpg  

  2. #2
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,064
    اوکی
    شما باید به پینهای SPI ریدر رو به پین های SPI مگا وصل کنید یعنی پینهای :
    MISO
    MOSI
    SCK

    شماره پینها رو اینجا نوشته : https://www.arduino.cc/en/Reference/SPI

    پین چهارم که میشه پین Cs رو به هر پین دیجیتال دلخواه وصل کنید.

    از کدهای نمونه خود کتابخونه sd استفاده کنید:
    مثالی که باهاش میتونید متوحجه بشید همه چیز اوکیه یا نه این مثاله :

    برای دیدن سایز بزرگ روی عکس کلیک کنید

نام: 2016-10-15_12-15-13.jpg
مشاهده: 342
حجم: 19.3 کیلو بایت


    این مثال بهترین مثال برای تست ماژول و کارت همزمانه که تو کنسول اطلاعات کارت رو بر می گردونه

  3. #3
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,064
    به احتمال زیاد سیم بندیتون درسته کد رو عوض کنید ببینید جواب میگیرید!
    لایک کردن

  4. #4
    Junior Member
    تاریخ عضویت
    Oct 2016
    نوشته ها
    3
    مرسی از جوابتون.
    من با مثال های خود Arduino Studio هم تست کردم اما بهم خطای Initialization Failed میده.
    sd card رو هم با Fat تست کردم هم با FAT32

  5. #5
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,064
    نقل قول نوشته اصلی توسط feri_sharp نمایش پست ها
    مرسی از جوابتون.
    من با مثال های خود Arduino Studio هم تست کردم اما بهم خطای Initialization Failed میده.
    sd card رو هم با Fat تست کردم هم با FAT32
    من با اس دی کارت خودم و مگا تست کردم :

    سیم بندیم به این صورته :

    Arduino SD card
    3.3 Vcc
    Gnd Gnd
    4 Ss
    51 Mosi
    50 Miso
    52 Sck

  6. #6
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,064
    نقل قول نوشته اصلی توسط feri_sharp نمایش پست ها
    مرسی از جوابتون.
    من با مثال های خود Arduino Studio هم تست کردم اما بهم خطای Initialization Failed میده.
    sd card رو هم با Fat تست کردم هم با FAT32
    کدی هم که باهاش تست کردم اینه :
    کد:
    #include <SPI.h>
    #include <SD.h>
    
    
    // set up variables using the SD utility library functions:
    Sd2Card card;
    SdVolume volume;
    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;
    
    
    void setup() {
      // Open serial communications and wait for port to open:
      Serial.begin(9600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
      }
    
    
    
    
      Serial.print("\nInitializing SD card...");
    
    
      // 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)) {
        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");
        return;
      }
    
    
    
    
      // 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);
    
    
    
    
      Serial.println("\nFiles found on the card (name, date and size in bytes): ");
      root.openRoot(volume);
    
    
      // list all files in the card with date and size
      root.ls(LS_R | LS_DATE | LS_SIZE);
    }
    
    
    
    
    void loop(void) {
    
    
    }
    بدون مشکل جواب میده
    اینم خروجی کنسولمه :
    برای دیدن سایز بزرگ روی عکس کلیک کنید

نام: 2016-10-18_9-14-22.jpg
مشاهده: 381
حجم: 17.4 کیلو بایت
    لایک کردن

  7. #7
    Junior Member
    تاریخ عضویت
    Oct 2016
    نوشته ها
    3
    نقل قول نوشته اصلی توسط magmagmary نمایش پست ها
    کدی هم که باهاش تست کردم اینه :
    کد:
    #include <SPI.h>
    #include <SD.h>
    
    
    // set up variables using the SD utility library functions:
    Sd2Card card;
    SdVolume volume;
    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;
    
    
    void setup() {
      // Open serial communications and wait for port to open:
      Serial.begin(9600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
      }
    
    
    
    
      Serial.print("\nInitializing SD card...");
    
    
      // 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)) {
        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");
        return;
      }
    
    
    
    
      // 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);
    
    
    
    
      Serial.println("\nFiles found on the card (name, date and size in bytes): ");
      root.openRoot(volume);
    
    
      // list all files in the card with date and size
      root.ls(LS_R | LS_DATE | LS_SIZE);
    }
    
    
    
    
    void loop(void) {
    
    
    }
    بدون مشکل جواب میده
    اینم خروجی کنسولمه :
    برای دیدن سایز بزرگ روی عکس کلیک کنید

نام: 2016-10-18_9-14-22.jpg
مشاهده: 381
حجم: 17.4 کیلو بایت
    ممنونم.
    امکانش هست که شماتیک از مدارتون بفرستید؟ و مشخصات SD Cardتون رو بهم بدید؟ ممکنه مشکل از SD cardم باشه؟ لپتاپ میخونه SD Card رو

  8. #8
    مدیر گروه
    تاریخ عضویت
    Nov 2013
    محل سکونت
    ایران
    نوشته ها
    4,064
    نقل قول نوشته اصلی توسط feri_sharp نمایش پست ها
    ممنونم.
    امکانش هست که شماتیک از مدارتون بفرستید؟ و مشخصات SD Cardتون رو بهم بدید؟ ممکنه مشکل از SD cardم باشه؟ لپتاپ میخونه SD Card رو
    دوست عزیز ماژول من تو سایت نیست دست سازه

    اما قائدتا نباید فرقی داشته باشه
    چون پروتکل ارتباطی همه اینها شبیه به هم هستن .
    کافیه مطابق با سیم بندی من شما هم تست بفرمایید.

    و در مورد SD Card شما باید فرمت و ماکزیمم حجم حافظه رو با ماژول تطبیق بدید.
    لایک کردن

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •  

SEO by vBSEO