Go Down

Topic: Adding a second 23LC1024 (Read 2 times) previous topic - next topic

Gerry48

I'm a bit limited with just one ram chip.  Just storing x,y,z data, I can get 14,221 data set entries before the ram is full.  At 5 ms per measurement, in 71 seconds the ram is full. 

It's been a long time since I messed around with ram, (perhaps 1978), but is seems with this stuff, we can solder another chip on top of the first one.  Just keep CS isolated.  I Have 4 ram chips.  I guess I could build a ram stack 4 high!  Will that work?  Will RamDisk work without any discontinuities?

Thanks for your thoughts.
Gerry

fat16lib

Quote
I guess I could build a ram stack 4 high!  Will that work?

Not with the current version of RamDisk.

I will soon post a version of RamDisk that supports multiple chips.  This will allow you to create one large volume.  I am testing with four chips but the design is only limited by the number of pins used for chip selects.

I am also developing a version for 256 KB FRAM chips.  Four FRAM chips will have a capacity of 1 MB.

robtillaart

Could use a multiplexer to select the right "chip selects" => 4 lines to select one of 16 memory banks!

switching of the chips would take minimal time?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

fat16lib

Quote
Could use a multiplexer to select the right "chip selects" => 4 lines to select one of 16 memory banks!

I looked at 16 pin 3:8 decoder chips and decided for fewer than eight chips I would directly handle chip select.

For eight or more chips a decoder makes sense.  I bought several 74HC138 decoders and may try to get the 16-DIP decoder and eight SRAM chips on a proto shield.  For 16 SRAM chips you need a 24 pin DIP decoder so a custom PCB would be nice.

For larger memories, the 8 MB RamDisk pito is using http://www.rlx.sk/en/storage-boards-memorystorage-boards-memory/2559-ramdisk-8mb-8mx8-8mbytes-with-8bit-parallel-access.html looks good.

Koepi

#4
Apr 28, 2014, 07:30 pm Last Edit: Apr 28, 2014, 08:27 pm by Koepi Reason: 1
Take a look here: http://forum.arduino.cc/index.php?topic=225052.0

I wouldn't use the chips as staple, that was my first idea as well; look in the thread linked above, there are photos especially in the last post showing the bus system on the back of my PCB. For 5 chips I already use a 74HCT138 3:8 demuxer (had to save pins on the µC - in the end I've still too little left and changed to a bigger STM32F0 / STM32F103, the last ones are very cheap available on eBay for ~6 Euros/8 USD). As I reworked my RAM bank a little, I had 2 outputs left over (one has to be spare in my project for the SPI chip deselect function) that I attached to the SPI bus and Vcc/GND/CS. Now I can add other SPI devices like an SD/Micro-SD-card shield for finally writing the captured data away more permanently.

The speed is quite constant. 5ms per measurement is close to eternity! No need for optimizing the code much. Anyhow, switching to the next chip takes at least 4 additional byte writes, if you prepare the chips for sequential mode before starting the writing. I'm doing that on another µC platform currently (pseudo-code):
Code: [Select]
for (i=0; i<5;i++){
chip_select(i);
spi_send (write mode register);
spi_send (sequential mode);
chip_deselect();
}

address=0;
int chip=0;
while (measurement) {
 if (address % 0x1FFFF == 0) {
   chip=(address / 0x1FFFF);  // ram size 0x1FFFF=128kByte
   chip_select(i);
   spi_send(WRITE);
   spi_send(0>>16);  // MSB
   spi_send(0>>8);  // middle address byte
   spi_send(0);  // LSB
 }
 for (int i=0; i<0x20000; i++) {
   x=read_stuff();
   spi_send(x);
   address++;
 }
 if (address==(5*0x1FFFF)) measurement=false;
}


Hope that helps!

P.S.: fat16lib, are there 256kByte FRAM chips publically available? That sounds very interesting! Edit: Nevermind, just found the thread about the prototype.

fat16lib

A version of RamDisk with support for multiple chips is attached to this topic http://forum.arduino.cc/index.php?topic=229485.msg1656674#msg1656674.

Gerry48

Thanks for your work on the multiple ram chip library.  Right now I have a stack of two ram chips.    The examples work great.  I'm using RamDiskToSdFat as a basis to load ram data into the SD card.  I believe I'm only writing from the first ram chip and not from the second.  The max SD file size remains at 125KB.  That's what I got with just one ram chip.

Does this code work for multiple chips?
Code: [Select]
  Serial.println(F("Copying ramFile to sdFile"));
  int n;
  while ((n = ramFile.read(buf, sizeof(buf))) > 0) {
    if (sdFile.write(buf, n) != n) {
      Serial.println(F("sdFile.write failed"));
      return;
    }
  }
  ramFile.close();
  sdFile.close();
  sd.ls(&Serial, LS_DATE | LS_SIZE);

  Serial.println(F("Done"));


Thanks
Gerry


fat16lib

Quote
Does this code work for multiple chips?


It should copy the entire file.  It reads until end-of-file.

You need to define the multiple chip mode and provide the two chip select pins.  The default is a single chip.

Gerry48

When I use your example RamDiskToSdFat, and change "n" (the number to writes to ram) we can increase the file size.  You used n = 1000

n = 1000, FileSize = 17k
2000. 35k
5000, 90k
6500, 118k
7000, 125k
7500, 125k
8000, 125k

The file size stops at 125k.  That's just one ram chip of data.

I believe my hardware is working OK.  When I use the MultipleChipTest example, I get:
with 1 chip 32,000 numbers
with 2 chip 64640 numbers
when I tell it 3 chips (and have just 2) the data stops at 64512.

Gerry


fat16lib

You need to post your code. 

You are either using the single chip driver library or your format statement is limited to 256 blocks.

Gerry48

This is your code: RamDiskToSdFat.

I changed n to 8000 and
changed:
uint8_t csPins[] = {9,8,7,6};
const uint8_t CHIP_COUNT = 2;

I already had ram 1 on CS=9.  ram2 is on CS=8.

Code: [Select]
// Create a text fine on the RamDisk an then copy the file to an SD.
// Warning this requires a new test version of SdFat.
#include <SdFat.h>
#include <SdFatUtil.h>
#include <RamDisk.h>

#define USE_FRAM 0

#define USE_MULTIPLE_CHIPS 0

#if USE_FRAM
#include <MB85RS2MT.h>
#if USE_MULTIPLE_CHIPS
// Multiple FRAM chips so use CS pin list.
uint8_t csPins[] = {8, 9};
const uint8_t CHIP_COUNT = 1;
MB85RS2MT ram;
#else  // USE_MULTIPLE_CHIPS
// Single FRAM chip so use fast single chip template class.
const uint8_t RAM_CS_PIN = 9;
T_MB85RS2MT<RAM_CS_PIN> ram;
#endif  // USE_MULTIPLE_CHIPS
#else  // USE_FRAM
#include <M23LCV1024.h>
#if USE_MULTIPLE_CHIPS
// Multiple SRAM chips so use CS pin list.
uint8_t csPins[] = {9,8,7,6};
const uint8_t CHIP_COUNT = 2;
M23LCV1024 ram;
#else  // USE_MULTIPLE_CHIPS
// Single SRAM chip so use fast single chip template class.
const uint8_t RAM_CS_PIN = 9;
T23LCV1024<RAM_CS_PIN> ram;
#endif  // USE_MULTIPLE_CHIPS
#endif  // USE_FRAM

#define FILENAME "TEST.CSV"
const uint8_t SD_CS_PIN = SS;

SdFat sd;
SdBaseFile sdFile;
RamVolume vol;
RamFile ramFile;
char buf[40];
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
  Serial.print(F("FreeRam: "));
  Serial.println(FreeRam());
 
  Serial.print(F("Format (Y/N): "));
  while (!Serial.available());
 
   if (!sd.begin(SD_CS_PIN)) sd.errorHalt();
   
   // Initialize RAM
#if USE_MULTIPLE_CHIPS
  ram.begin(csPins, CHIP_COUNT);
#else  // USE_MULTIPLE_CHIPS
  ram.begin();
#endif  // USE_MULTIPLE_CHIPS
 
  char c = toupper(Serial.read());
  Serial.println(c);

  if (c == 'Y') {
    // use defaults:
    // totalBlocks: entire RAM
    // dirBlocks: 4  (64 entries)
    // clusterSizeBlocks: 1 (one 512 byte block per cluster)
    if (!vol.format(&ram)) {
      Serial.println(F("format fail"));
      return;
    }
  } else if (c != 'N') {
    Serial.println(F("Invalid entry"));
    return;
  }
  if (!vol.init(&ram)) {
    Serial.println(F("init fail"));
    return;
  }
  // Remove old version.
  vol.remove(FILENAME);
  if (!ramFile.open(FILENAME, O_CREAT | O_RDWR)) {
    Serial.println(F("open fail"));
    return;
  }
  Serial.println(F("Writing ramFile"));
  uint32_t m0 = micros();
  for (int i = 0; i < 8000; i++) {
    ramFile.print(micros() - m0);
    ramFile.write(",Line,");
    ramFile.println(i);
  }
  // like closing and opening file (need to update dir for ls).
  ramFile.sync();
  ramFile.rewind();
 
  vol.ls(&Serial, LS_DATE | LS_SIZE);

  if (!sdFile.open(FILENAME, O_CREAT | O_RDWR | O_TRUNC)) {
    Serial.println(F("sdFile.open failed"));
    return;
  }
  Serial.println(F("Copying ramFile to sdFile"));
  int n;
  while ((n = ramFile.read(buf, sizeof(buf))) > 0) {
    if (sdFile.write(buf, n) != n) {
      Serial.println(F("sdFile.write failed"));
      return;
    }
  }
  ramFile.close();
  sdFile.close();
  sd.ls(&Serial, LS_DATE | LS_SIZE);

  Serial.println(F("Done"));
}
void loop() {}

fat16lib

You need to set USE_MULTIPLE_CHIPS non-zero like this:
Code: [Select]

#define USE_MULTIPLE_CHIPS   1


I don't think it matters but you may want to remove the extra entries here:
Code: [Select]

// Multiple SRAM chips so use CS pin list.
uint8_t csPins[] = {9,8,7,6}; <-------REMOVE ,7,6 HERE
const uint8_t CHIP_COUNT = 2;
M23LCV1024 ram;
#else  // USE_MULTIPLE_CHIPS



Gerry48

Excellent.  With n=8000, I get file size 146k.  Now I can add 2 more ram chips on the SD shield.

Thanks,
Gerry

jensgutsche

#13
May 13, 2014, 05:43 pm Last Edit: May 13, 2014, 05:48 pm by jensgutsche Reason: 1
sorry wrong thread....

Gerry48

Here's the final product.  Four ram chips, two stacks of two.  The lower shield contains the accelerometer.

My soldering was so bad that I had to lower the photo resolution. ;-)

Gerry

Go Up