User Tools

Site Tools


arduino:sd-card-modules

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
arduino:sd-card-modules [2019/04/06 18:23]
Ilias Iliopoulos [Catalex]
arduino:sd-card-modules [2024/02/02 21:47] (current)
Ilias Iliopoulos
Line 1: Line 1:
  
 ====== SD Card Modules and their problems ====== ====== SD Card Modules and their problems ======
 +
 +{{htmlmetatags>​metatag-keywords=(arduino,​ sd card module, sd, sd card) 
 +metatag-description=(SD Card Modules and their problems)
 +}}
  
 ===== Introduction ===== ===== Introduction =====
Line 11: Line 15:
  
   - **A socket**, which is robust enough to withstand the designed number of in-out actions. The size of the socket should match the SD cards that we intend to use, otherwise we must select a standard SD size which will accomodate miniSD and microSD cards using appropriate adapters.   - **A socket**, which is robust enough to withstand the designed number of in-out actions. The size of the socket should match the SD cards that we intend to use, otherwise we must select a standard SD size which will accomodate miniSD and microSD cards using appropriate adapters.
-  - **A 3.3V power source**. SD cards operate at 3.3V.+  - **A 3.3V power source**. SD cards themselves ​operate at 3.3V. Some modules may contain a voltage converter and others may also contain a level shifter for the data signals.
   - **A voltage level shifter**. As stated above, SD cards operate at 3.3V. Therefore, to interface with a 5V Arduino, the Arduino 5V signals MOSI and SCK should be converted to 3V, whereas the SD card output MISO should be converted from 3.3V to 5V   - **A voltage level shifter**. As stated above, SD cards operate at 3.3V. Therefore, to interface with a 5V Arduino, the Arduino 5V signals MOSI and SCK should be converted to 3V, whereas the SD card output MISO should be converted from 3.3V to 5V
   - **Capability to connect the SPI signals into an SPI __bus__ configuration**,​ meaning that we need to make sure that our signals will have the proper electrical characteristics when multiple SPI devices are connected to the same bus. In short words, multiple SPI devices should be able to share the same bus.   - **Capability to connect the SPI signals into an SPI __bus__ configuration**,​ meaning that we need to make sure that our signals will have the proper electrical characteristics when multiple SPI devices are connected to the same bus. In short words, multiple SPI devices should be able to share the same bus.
Line 19: Line 23:
 Let us examine the SD card modules existing in the market. I have found and used two modules, both having very low prices. Unfortunately,​ the module schematics are not available in the seller web sites. Therefore, one would need to reverse engineer the module by tracing the PCB, in order to have a complete view about how the interface to the controller will be designed and implemented. Let us examine the SD card modules existing in the market. I have found and used two modules, both having very low prices. Unfortunately,​ the module schematics are not available in the seller web sites. Therefore, one would need to reverse engineer the module by tracing the PCB, in order to have a complete view about how the interface to the controller will be designed and implemented.
  
 +For the impatient, here is a comparison table:
 +
 +|              ^ Catalex ​           ^ LC Studio ​         ^
 +^ SD card size    | micro SD          | Standard SD        |
 +^ Voltage ​        | 5V                | 5V, 3.3V           |
 +^ Level shifter ​  | Yes               | No                 ​|  ​
 +^ SPI             | Partial. Does not allow other devices on SPI bus          | Exposes SD card pins        |
 +^ Write-enable detection | No | No |
  
  
Line 38: Line 50:
 As a result, the module fails miserably in criterion 4, meaning that the module will not operate if another SPI device shares the same bus. Moreover, it will also block the other device from operating properly. Could we ask a refund from the supplier? Well, probably no. The module specs do not state that the board can co-exist with other SPI devices, only that it can operate by itself in SPI mode, which is actually a function of the SD card.  As a result, the module fails miserably in criterion 4, meaning that the module will not operate if another SPI device shares the same bus. Moreover, it will also block the other device from operating properly. Could we ask a refund from the supplier? Well, probably no. The module specs do not state that the board can co-exist with other SPI devices, only that it can operate by itself in SPI mode, which is actually a function of the SD card. 
  
-Could we tamper with the module to make it operate properly? Well, in design terms, yes. After all, the only thing required is to remove pin 13 from ground and connect it to pin 8, which is the module selection signal. (You can see below the schematic of the LC Studio extension circuit to see exactly how it is done.) But in operational terms, this means that we need to desolder very carefully pin 13 of an SMD chip, find a way to raise it in the air without breaking, keep it in the air without touching the board, solder a very small wire to it and solder the other end of the wire on the chip's pin 8. Another "​hack"​ would be to de-solder the SMD chip, provided that you have the proper equipment, cut the trace to pin 13, resolder the chip and then connect a wire between pins 8 and 13. Both these arrangements ​has strong problems of mechanical nature, therefore you either find a good way to do the above actions and subsequently enclose the entire fix into a thick layer of resin to protect it from vibrations and similar wear, or just forget it.+Could we tamper with the module to make it operate properly? Well, in design terms, yes. After all, the only thing required is to remove pin 13 from ground and connect it to pin 8, which is the module selection signal. (You can see below the schematic of the LC Studio extension circuit to see exactly how it is done.) But in operational terms, this means that we need to desolder very carefully pin 13 of an SMD chip, find a way to raise it in the air without breaking, keep it in the air without touching the board, solder a very small wire to it and solder the other end of the wire on the chip's pin 8. Another "​hack"​ would be to de-solder the SMD chip, provided that you have the proper equipment, cut the trace to pin 13, resolder the chip and then connect a wire between pins 8 and 13. Both these arrangements ​have strong problems of mechanical nature, therefore you either find a good way to do the above actions and subsequently enclose the entire fix into a thick layer of resin to protect it from vibrations and similar wear, or just forget it.
  
-It would be expected that the manufacturers will have identified this flaw and make the correction, but even after several years I have not yet seen the expected Catalex V2!!+It would be expected that the manufacturers will have identified this flaw and make the correction, but even after several years I have not yet seen a revised version!
  
 ===== LC Studio ===== ===== LC Studio =====
Line 48: Line 60:
     ​     ​
  
-This module can accommodate standard sized SD cards, meaning that we can use microSD cards with the help of an adapter. It is powered by a 5V source and contains internally an AMS1117-3.3 ​linera ​regulator which converts to 3.3V. A bonus(?) is that the 3.3V output of the converter is available to the module connectors and can be used to power devices external to the module, provided that the consumption does not exceed the AMS1117-3.3 specs. ​ From my point of view, using this regulator as a power source for external devices may cause problems that will be very difficult to locate in the future. It is better not to use it, unless you know exactly what you are doing (who admitts it, is another story....).+This module can accommodate standard sized SD cards, meaning that we can use microSD cards with the help of an adapter. It is powered by a 5V source and contains internally an AMS1117-3.3 ​linear ​regulator which converts to 3.3V. A bonus(?) is that the 3.3V output of the converter is available to the module connectors and can be used to power devices external to the module, provided that the consumption does not exceed the AMS1117-3.3 specs. ​ From my point of view, using this regulator as a power source for external devices may cause problems that will be very difficult to locate in the future. It is better not to use it, unless you know exactly what you are doing (who admitts it, is another story....).
  
 The 3.3V pin can also be used as an input to the module, if a 3.3V external source is available. The AMS1117-3.3 will not complain if a 3.3V is applied to its output. In such a case, we should make sure that the 5V pin is left floating, without any other power source connected to it. The 3.3V pin can also be used as an input to the module, if a 3.3V external source is available. The AMS1117-3.3 will not complain if a 3.3V is applied to its output. In such a case, we should make sure that the 5V pin is left floating, without any other power source connected to it.
Line 56: Line 68:
 The module interfaces with the world with a double set of headers. The two pins of each row are wired together, so you can use any of the two. If our project is based on a 3.3V power supply and we do not need to use the level shifter below, we could utilize the double pins to continue our wiring to other SPI devices, connecting the appropriate signals in parallel, except the CS pin of course, since each device should be selected individually. ​ The module interfaces with the world with a double set of headers. The two pins of each row are wired together, so you can use any of the two. If our project is based on a 3.3V power supply and we do not need to use the level shifter below, we could utilize the double pins to continue our wiring to other SPI devices, connecting the appropriate signals in parallel, except the CS pin of course, since each device should be selected individually. ​
  
-It is obvious that this SD Card Module complies only with criteria 1 and 2 set in our Introduction section. The module will of course operate if wired to a 3.3V Raspberry Pi, but shall it survive ​the 5V Arduino voltages? One can find several internet pages which advice that this is safe, because "​several"​ SD cards can tolerate 5V signalsMy approach ​is that if your project contains an SD card socketthe type of SD card and its specifications ​are totally outside the control and the original intentions of the designer. We must therefore assume that our project will receive various SD cards from several origins and manufacturers. **I need to point out that the module does not buffer in any way the SD card pins, so whatever voltage we send, goes directly ​to the SD card**. ​  If the designer undertook the risk of damaging the circuitthat would be of course his choice. But such wiring will probably has no effect on the controller but will rather damage the SD card itself and risk the loss of its valuable data. This is absolutely not acceptable for a reasonable design. An addition of a level shifter, external to the module is mandatory for safe operation in all circumstances.+A schematic ​of the module ​can be found onlineJ1 is the SD card socket ​and the named signals ​are connected ​from the socket ​to the headerswhich is only implied in the schematic.
  
-Can we expand the module with a level shifter, while at the same time allow the board to work in a multi-participant SPI bus? I have developed the circuit that is depicted in the following diagram. We are adding an external chip which operates both as a voltage level shifter and as a chip selector for the SPI bus. This chip is the 74LV125 or 74HCT125N. This is the same chip type used in the Catalex module, in a DIP version, so that we can work with easily. In this circuit, the wiring allows multiple participation to the SPI bus, because the MISO output (as seen from the module side) is activated only when the controller has explicitly indicated that it intends to communicate with the module, activating the CS pin, which subsequently activates pin 8 of the 74125 chip and finally brings the buffer handling the MISO signal out of the high impedance state. Whenever CS is not active, MISO output is kept at the high impedance state, leaving other modules and devices free to use the SPI bus. We could also wire pin 8 to pins 4 and 10 instead of wiring 4 and 10 to ground, but I just wanted to point out in its simplest form the correction that would be required to the Catalex module to make it operate properly. When CS is not active, the SD card by itself ignores the signals in its inputs, so it is OK to have pins 4 and 10 connected to ground. ​+No copyright is indicated on the schematic. If otherwise, please let me know. 
 +{{arduino:​lc-studio-schematic.jpg?​300}} 
 + 
 +It is obvious that this SD Card Module complies only with criteria 1 and 2 set in our [[#​Introduction|Introduction section]]. The module will of course operate if wired to a 3.3V Raspberry Pi, but shall it survive the 5V Arduino voltages? One can find several internet pages which advice that this is safe, because "​several"​ SD cards can tolerate 5V signals. My approach is that if your project requires the use of an SD card, the type of SD card and its specifications are totally outside the control and the original intentions of the designer. Even users who had been warned about specific precautions,​ will (and shall) behave eratically at some point in time. We must therefore assume that our project will receive various SD cards from several origins and manufacturers. **I need to point out that the module does not buffer in any way the SD card pins, so whatever voltage we send, goes directly to the SD card**. ​  Such wiring will probably have no effect on the controller but will rather damage the SD card itself and risk the loss of its valuable data. This is absolutely not acceptable for a reasonable design. An addition of a level shifter, external to the module, is mandatory for safe operation in all circumstances where a 5V architecture is implemented. In the case where the project architecture is based on 3.3V, the module can be used without any problem. 
 + 
 +Can we expand the module with a level shifter, while at the same time allow the board to work in a multi-participant SPI bus? I have developed the circuit that is depicted in the following diagram ​for that purpose. We are adding an external chip which operates both as a voltage level shifter and as a chip selector for the SPI bus. This chip is the 74LV125 or 74HCT125N. This is the same chip type used in the Catalex module, in a DIP version, so that we can work with it easily. ​**(I was not able to find in the market a PDIP 74LV125, so I used an 74HCT125 instead. It is specified at 5V, whereas the 74LV125 works from 2V to 5.5V. Yet it worked, but I cannot guarantee that it will work at all circumstances.)** ​In this circuit, the wiring allows multiple participation to the SPI bus, because the MISO output (as seen from the module side) is activated only when the controller has explicitly indicated that it intends to communicate with the module, activating the CS pin, which subsequently activates pin 8 of the 74xx125 ​chip and finally brings the buffer handling the MISO signal out of the high impedance state. Whenever CS is not active, MISO output is kept at the high impedance state, leaving other modules and devices free to use the SPI bus. We could also wire pin 8 to pins 4 and 10 instead of wiring 4 and 10 to ground, but I just wanted to point out in its simplest form the correction that would be required to the Catalex module to make it operate properly. When CS is not active, the SD card by itself ignores the signals in its inputs, so it is OK to have pins 4 and 10 connected to ground. ​
  
 The chip is powered by the 3.3V which is present in the module connector, so, although we hated it above, we are exploiting it to our benefit and avoid the need of an extra power source. The schematic is shown below: ​ The chip is powered by the 3.3V which is present in the module connector, so, although we hated it above, we are exploiting it to our benefit and avoid the need of an extra power source. The schematic is shown below: ​
Line 64: Line 81:
 {{arduino:​lc-studio-extension-schematic.jpg?​800}} {{arduino:​lc-studio-extension-schematic.jpg?​800}}
  
-I have implemented and tested this configuration along with an Ethernet ENC28J60 module. Both modules shared the same SPI bus. The SD card used pin D4 as Chip Select and the Ethernet module used pin D10. Everything was operating properly.+I have implemented and tested this configuration ​where the SD card shared the SPI along with an Ethernet ENC28J60 module. The SD card used pin D4 as Chip Select and the Ethernet module used pin D10. Everything was operating properly.
  
-Of course the addition of one chip and some resistors in a project increases the board space and wiring effort. But, it is the only solution in order to contruct ​a proper module. ​  +Of course the addition of one chip and some resistors in a project increases the board space and wiring effort. But, it is the only solution in order to construct ​a proper module. ​  
  
 ===== Conclusion ===== ===== Conclusion =====
Line 81: Line 98:
  
  
 +~~DISQUS~~
arduino/sd-card-modules.1554564219.txt.gz · Last modified: 2019/04/06 18:23 by Ilias Iliopoulos