If you have written a sketch that needs additional memory would these chips perform well or would the Arduino have to run relatively slow to utilize the chips resources? I realize you could use a SD card instead of EEPROM but, would EEPROM be faster or slower? Would the SRAM be helpful and quick for storing chunks of data before transferring to a SD card?
Remember that such an external SRAM or EEPROM will not be addressable directly by the Arduino. That is, you'd have to write explicit read and write code to access data; you wouldn't be able to just say:
my_var = 42;
but you'd have to code:
WriteToExternalRam(address, 42);
On top of that, the Arduino processor can only execute code from internal Flash memory. External memory cannot be used for program storage.
Writing to external memory is quicker than SD card. SD card has to open & close files, go thru the directory stuff.
SRAM/EEPROM you choose & keep track of the locations beings, access should be via burst of I2C orSPI read/writes.
Using an interpreter like Bitlash may give you the appearance of running from external memory.
Most of my project ideas are related to data logging of a motorcycle. I will be using a SD card but, I am try to learn of all the possibilities. Also, I keep reading threads about people running out of RAM or having problems with their sketch after the Arduino is running for a given amount of time. Therefore, I was wondering why it was not common practice to add memory to their project. Note: I do realize that many of the problems can be cured in programming when it comes to overflow.
Thanks to everyone that has enlightened me so far,
Mark
Fwiw, some of Atmel's processors have XMEM which is hardware-accelerated external memory I/O. Not sure if that integrates cleanly with C so that you can reference variables stored in external SRAM directly, but it's there.
AT90CAN128 is one good example, you can buy an Olimex breakout board for that one or integrate it in your own projects.
ATmega162 too?
Tried doing a search on Atmel's site and got lots of results but didn't find a clean table detailing which ones have it or not...
With all the features the External Memory Interface provides, it is well suited to operate as an
interface to memory devices such as External SRAM and Flash, and peripherals such as LCDdisplay,
A/D, and D/A. The main features are:
• Four different wait-state settings (including no wait-state).
• Independent wait-state setting for different extErnal Memory sectors (configurable sector
size).
• The number of bits dedicated to address high byte is selectable.
• Bus keepers on data lines to minimize current consumption (optional).
5.5.1 Overview
When the eXternal MEMory (XMEM) is enabled, address space outside the internal SRAM
becomes available using the dedicated External Memory pins (see Figure 2-2 on page 4, Table
10-3 on page 73, Table 10-9 on page 77, and Table 10-21 on page 87). The memory configuration
is shown in Figure 5-4.
Sounds like it should become directly accessible with variables names/etc since it becomes part of the AVR's actual address space. Would have to see how to activate support for this and make the C compiler provide access to it.
Ooh actually, the ATmega2560 used in the Arduino Mega has this. So no need to mess with non-standard Arduino-ready procs, but it does require upgrading to the Arduino Mega. Still not sure if anyone has a library or procedure for activating/using it in native C code.
Spirilis, thank you for identifying the AT90CAN128 processor's, they do sound amazing!
However, my line of thinking was similar to changing the size of a hard drive or ram in a computer. What I mean is that if you are processing large amounts of data you add more or a bigger hard drive and continue working. However, with the Atmega chips the "hard drive"EEPROM and the RAM are internal. I am trying to understand if adding external memory would be as useful to the Atmega as it would be to a home computer.
A bigger picture would be, if I put 8 EEPROM chips on the IC2 bus, could I store 16K of info and process it just as quickly as if it was internal to the Atmega chip? Or would the process of transferring the data back and forth make typical sketches run excessively slow? To continue with that idea would adding the RAM or EEPROM make a typical Atmega a lot more useful for more projects.
I gotcha. I dunno, an EEPROM or Flash drive that can read/write very quickly over SPI would be fast, in that SPI can be clocked up to 1/2 the ATmega's clock speed so you can do very quick I/O with that. Considering EEPROM has slow write times by its very nature (even the internal EEPROM takes 3.3 milliseconds typical according to the ATmega328 datasheet; for a frame of reference, that's about 52800 clock pulses at 16MHz) then adding the overhead of SPI isn't much.
You might notice the biggest difference on the read side; according to the ATmega328 datasheet the EEPROM READ operation causes the CPU to halt for 4 clock cycles, guessing that is roughly the read access time. SPI wouldn't be as fast as that, but, who cares? For the most part you spend your EEPROM access time writing (for logging, I'm guessing), not using it as scratch space (just like a PC uses its RAM for scratch space for time-critical functions, not its hard disk...)
So thinking about it some more, for EEPROM I don't think you'll notice much of a speed difference between internal EEPROM and external SPI or I2C accessible EEPROM as long as you run the bus nice 'n fast. SPI being the better of the two.
For SRAM (volatile scratch space operations), obviously you'll net a substantial drop in performance doing tons of operations against SPI or I2C-accessible SRAM versus the internal SRAM, but if you had XMEM capability it'll probably be a closer match. Heck I'm almost itching to play with that one of these days. Need to control my hobby expenditures though
"A bigger picture would be, if I put 8 EEPROM chips on the IC2 bus, could I store 16K of info and process it just as quickly as if it was internal to the Atmega chip?"
Just about - the slowness with EEPROM is the writes - so write internal, write external, won't see a lot if difference.
Reading back viea I2C will be pretty quick - you're basically reading back in via external shift register, if you read back blocks at a time will be faster than reading individual bytes:
select device, select address, read the data. Vs select device, select starting address, read a bunch of bytes.
"Or would the process of transferring the data back and forth make typical sketches run excessively slow? " EEPROM writes slow either way - start the write, do other stuff while the write self-completes. Writing blocks will help.
"To continue with that idea would adding the RAM or EEPROM make a typical Atmega a lot more useful for more projects." Project dependent. For one doing a lot of number crunching, maybe. Skyjumper has a huge program running on a 1284, way beyond what most folks would do. I imaging that more often than not, just stepping up a processor level would be sufficient.
Thank you CrossRoads and Spirilis those were great answers and now I have a much better understanding of using external memory! This has really gave me some food for thought!
IIRC last time I looked into this the Mega had all the XMEM signals available on the headers, so you could easily add external RAM if you wanted to, as much as you want but in 64k pages so you also need some decoders and/or IO pins to select the pages.
I think you can access from C it by just using a pointer set to the appropriate value.
Take a look at F-RAM from Ramtron (and Toshiba?) as well. Similar to EEPROM in terms of code and interface, but much, much lower write latency and higher write cycles. In other words, much faster performance than either flash or EEPROM. It's a tad more expensive though (warning: understatement).
Search for "Ramtron" on Mouser to get an idea of the selection and pricing. The parts became extremely scarce after the Fukushima disaster but supply lines seem to have opened back up; Mouser has a good selection available now. Ramtron also does samples if you ask nice .
Crossroads, are you aware of any SPI or I2C interfaced DRAM (or similar non-static memory)? Seems there would be a market for such a beast, but I haven't come across anything in my searching.
hm, that is interesting, first time I've seen nonvolatile memory chips that literally only store 2 or 4 bits and cost around $1 ... applications primarily for controlling valves/machinery after a power failure, as the description says. The good memories require ~3.3V input but hopefully they're 5V tolerant on their inputs... and yeah pretty expensive but not totally out of line if you need to burst the data I guess.
spirilis:
hm, that is interesting, first time I've seen nonvolatile memory chips that literally only store 2 or 4 bits and cost around $1 ... applications primarily for controlling valves/machinery after a power failure, as the description says. The good memories require ~3.3V input but hopefully they're 5V tolerant on their inputs... and yeah pretty expensive but not totally out of line if you need to burst the data I guess.
I think you selected an odd part The interesting parts have capacities from 4k - 1Mb (i2c) or 2Mb (SPI). The FM24V02-G is a 256K part (32Kx8), will run about $6 through Mouser. Really depends on your use case...
"Crossroads, are you aware of any SPI or I2C interfaced DRAM (or similar non-static memory)? Seems there would be a market for such a beast, but I haven't come across anything in my searching."
I can't see that being at all useful - DRAM needs constant periodic refreshing, yes? Who wants to tie up resources for that?
spirilis:
hm, that is interesting, first time I've seen nonvolatile memory chips that literally only store 2 or 4 bits and cost around $1 ... applications primarily for controlling valves/machinery after a power failure, as the description says. The good memories require ~3.3V input but hopefully they're 5V tolerant on their inputs... and yeah pretty expensive but not totally out of line if you need to burst the data I guess.
I think you selected an odd part The interesting parts have capacities from 4k - 1Mb (i2c) or 2Mb (SPI). The FM24V02-G is a 256K part (32Kx8), will run about $6 through Mouser. Really depends on your use case...
That is a great find! A lot of memory can be had with a small parts count! It seems you can only use 2 of those I2c chips on the same buss at a time but, you do get more bang out of each.