Arduino Forum

Using Arduino => Microcontrollers => Topic started by: bratan on Nov 17, 2012, 03:35 pm

Title: Arduino clones with more RAM than Uno?
Post by: bratan on Nov 17, 2012, 03:35 pm
I have no experience with other Arduino clones other than UNO R2/R3 and Hackduino which I made with atmega328p. Problem is my latest project (LED clock with Wave Shield) needs more than 2K RAM that UNO provides... I'm looking for cheap alternatives. Mega is way too expensive (I actually ordered one to test out) and I plan eventually to make these so I'd prefer to have DIP chips for easier soldering. I've seen some clones like Sagduino, Teensy and ChipKit, but I don't know how compatible they are with current IDE and libraries (I use a lot of advanced things, like EEPROM, fastWrite, etc.) and have no experience with these. What would you recommend?  I think I need at least 4K of RAM, and same amount (or little more) of I/O ports as in UNO.
Any advise would be appreciated! :)
Title: Re: Arduino clones with more RAM than Uno?
Post by: baselsw on Nov 17, 2012, 03:46 pm
- More than 4K of SRAM
- More pins (I/O) than atmega328p
- DIP package
- Support in the IDE and libraries etc..

====== Atmega644p or Atmega1284p... Here is a datasheet for the atmega1284p http://www.atmel.com/Images/doc8059.pdf (http://www.atmel.com/Images/doc8059.pdf). 644p and 1284p are essentially the same, just different flash/SRAM size.

And here is the core/bootloader for the 1284p "family". https://github.com/maniacbug/mighty-1284p (https://github.com/maniacbug/mighty-1284p)
Title: Re: Arduino clones with more RAM than Uno?
Post by: dc42 on Nov 17, 2012, 04:18 pm
Are you certain you need more than 2K of RAM? Have you used all the usual tricks of storing constants (including audio files) in PROGMEM?
Title: Re: Arduino clones with more RAM than Uno?
Post by: bratan on Nov 17, 2012, 04:31 pm

Are you certain you need more than 2K of RAM? Have you used all the usual tricks of storing constants (including audio files) in PROGMEM?

Yup, I'm storing all font arrays in Progmem. Audio is on SD card and I'm using Adafruit's wave library, I'm not sure if that data can be stored it Eprom...

- More than 4K of SRAM
- More pins (I/O) than atmega328p
- DIP package
- Support in the IDE and libraries etc..

====== Atmega644p or Atmega1284p... Here is a datasheet for the atmega1284p http://www.atmel.com/Images/doc8059.pdf (http://www.atmel.com/Images/doc8059.pdf). 644p and 1284p are essentially the same, just different flash/SRAM size.

And here is the core/bootloader for the 1284p "family". https://github.com/maniacbug/mighty-1284p (https://github.com/maniacbug/mighty-1284p)

Awesome! I'll check it, thank you so much!
Title: Re: Arduino clones with more RAM than Uno?
Post by: dc42 on Nov 17, 2012, 05:12 pm


Are you certain you need more than 2K of RAM? Have you used all the usual tricks of storing constants (including audio files) in PROGMEM?

Yup, I'm storing all font arrays in Progmem. Audio is on SD card and I'm using Adafruit's wave library, I'm not sure if that data can be stored it Eprom...


SD card is fine for storing the audio. But the Adafruit doc says the library for that wave shield needs around 600 bytes. So I'm puzzled that 2K isn't enough. Are you certain you have all of the actual font arrays in PROGMEM, not just some top-level pointers to them? Or are you knowingly using a lot of RAM for something else?
Title: Re: Arduino clones with more RAM than Uno?
Post by: bratan on Nov 17, 2012, 07:24 pm

SD card is fine for storing the audio. But the Adafruit doc says the library for that wave shield needs around 600 bytes. So I'm puzzled that 2K isn't enough. Are you certain you have all of the actual font arrays in PROGMEM, not just some top-level pointers to them? Or are you knowingly using a lot of RAM for something else?

Thanks, I was looking how much ram it needs, and couldn't find it..
You are right, I probably need to find what hogs all the RAM in the my sketch. I'm using a lot of different libraries (HT1632,stdio,Time,DS1307,stdlib.h,WaveUtil,WaveHC) might be some of the is at fault.
Title: Re: Arduino clones with more RAM than Uno?
Post by: nickgammon on Nov 17, 2012, 10:17 pm
A lot of chips are supported by the IDE, some natively, some if you install some extra files in the hardware folder. The Sanguino for example, can be programmed in it. (That's the Atmega644 I think). The 644 gives you 64 Kb of program memory and 4 Kb of RAM.

Or the 1284, which I assembled on a breadboard here:

http://www.gammon.com.au/forum/?id=11637

This has somewhat more RAM (16 Kb) and somewhat more program memory (128 Kb).
Title: Re: Arduino clones with more RAM than Uno?
Post by: bperrybap on Nov 17, 2012, 10:34 pm
Also keep in mind that C strings by default on AVR will copied to RAM as well.
So things like:
Code: [Select]
char *var = "HELLO";
serial.print("HELLO");


will eat up 6 bytes of RAM.

Build your code with the verbose option so you can locate the .elf file.
Then run nm on the .elf to see your symbols to be able to identify
what is using your RAM.

See the nm man page for more details but
here is a  sample useful command to get you started:
avr-nm -n -C -S *.elf > nm.out

In the nm output, the symbols with "B" near the bottom are the ones using up bss (RAM)
(This won't show the literal strings).

You can also get useful information from the objdump command.


--- bill
Title: Re: Arduino clones with more RAM than Uno?
Post by: SirNickity on Nov 17, 2012, 11:43 pm
Optimizing your code is good and all but there comes a time when you need to throw in the towel and pony up for more capable hardware.  Given the number of libs you're using, I wouldn't even bother trying to make it work on an Uno.  Get the 1284.

Opinions only, of course.  But you're asking a lot of 2K RAM.  If 8K isn't enough, then I'd start looking at object dumps.  Maybe I'm just lazy.  ;-)
Title: Re: Arduino clones with more RAM than Uno?
Post by: UnaClocker on Nov 17, 2012, 11:58 pm
It's not really a clone if it's a different chip, more like a spinoff.. I needed more ram when using the ENC28J60 ethernet chips. The TCP stack is in ram, rather than in the chip, so it takes most of the ram. So I used the Teensy++ 2.0, really cheap, uses the Arduino IDE just like I'm used to, and has like 8k of ram. Though nowadays, I'd use the Teensy 3.0, it's got 16k of ram and is cheap as dirt.
Title: Re: Arduino clones with more RAM than Uno?
Post by: bratan on Nov 18, 2012, 02:36 pm

Or the 1284, which I assembled on a breadboard here:
http://www.gammon.com.au/forum/?id=11637
This has somewhat more RAM (16 Kb) and somewhat more program memory (128 Kb).

Nice tutorial!!!  Thanks a lot for sharing!

Build your code with the verbose option so you can locate the .elf file.
Then run nm on the .elf to see your symbols to be able to identify
what is using your RAM.

See the nm man page for more details but
here is a  sample useful command to get you started:
avr-nm -n -C -S *.elf > nm.out

In the nm output, the symbols with "B" near the bottom are the ones using up bss (RAM)
(This won't show the literal strings).

You can also get useful information from the objdump command.


--- bill

Thanks for the tip! I was wondering if it was possible to see how much RAM will program take before loading it to the chip.  I assume all these options are not available via standard IDE tho?  I couldn't find verbose, etc. What do I need to be able to run all these commands? Some kind of AVR studio?  Will it be compatible with .ino/.pde sketches and libraries I have?

It's not really a clone if it's a different chip, more like a spinoff.. I needed more ram when using the ENC28J60 ethernet chips. The TCP stack is in ram, rather than in the chip, so it takes most of the ram. So I used the Teensy++ 2.0, really cheap, uses the Arduino IDE just like I'm used to, and has like 8k of ram. Though nowadays, I'd use the Teensy 3.0, it's got 16k of ram and is cheap as dirt.

WOW I'm leaning more and more toward Teensy 3.0  It's just $20 and it has more ram than $50 Mega! So small too, and for this money I probably won't even have to bother with making my own PCB and 1284 chip...

Thanks all for the useful info. I love Arduino forums, everyone is so helpful! I learned so much!  :)
Title: Re: Arduino clones with more RAM than Uno?
Post by: bperrybap on Nov 18, 2012, 08:44 pm

Thanks for the tip! I was wondering if it was possible to see how much RAM will program take before loading it to the chip.  I assume all these options are not available via standard IDE tho?  I couldn't find verbose, etc. What do I need to be able to run all these commands? Some kind of AVR studio?  Will it be compatible with .ino/.pde sketches and libraries I have?

To use the verbose mode, if on pre 1.x IDE press the <SHIFT> key when building.
If on the newer IDE you have go to the [File]->[Preferences] dialog.

To run the commands it depends on what OS you use.
They are run from the command line which is why you have locate
the directory where the IDE is building images.
If you are stuck using windows, then the commands are there, they are just a bit harder to locate
as they are down in a directory under where the IDE is installed.


But before I'd jump ship to another board/device, particularly one that is a different
architecture and limited to 3v, I'd definitely make sure to understand what the real issue is
and know what it using all the RAM to make sure that there is not some other quick solution to solve
it. (like moving string literals to flash).

--- bill
Title: Re: Arduino clones with more RAM than Uno?
Post by: nickgammon on Nov 18, 2012, 08:53 pm
Quote
I was wondering if it was possible to see how much RAM will program take before loading it to the chip.


Not really. The compiler can't know if you are going to do malloc a thousand times, for example. You can use some of the code around that reports the amount of free RAM after you loaded the program, that would give you a good guide if you don't do dynamic memory allocation (eg. use the String class).
Title: Re: Arduino clones with more RAM than Uno?
Post by: dc42 on Nov 18, 2012, 09:08 pm
From a post I saw a week or so ago, I have a feeling that the new version 1.5 IDE does report the amount of RAM allocated statically by your code.

Using dynamic memory allocation (including the String class) is a bad idea in small embedded systems.
Title: Re: Arduino clones with more RAM than Uno?
Post by: bperrybap on Nov 18, 2012, 09:51 pm

From a post I saw a week or so ago, I have a feeling that the new version 1.5 IDE does report the amount of RAM allocated statically by your code.

Using dynamic memory allocation (including the String class) is a bad idea in small embedded systems.


I'm not seeing it.
I only see the same stuff:
.cpp arduino munged files, .d dependency files, .o objects, .elf image file, and .hex image

I don't see any .lss or nm output files being created.

Do you have a link to that post?

--- bill
Title: Re: Arduino clones with more RAM than Uno?
Post by: UnaClocker on Nov 18, 2012, 11:47 pm
Check out this improved 1.0.2 IDE: http://arduino.cc/forum/index.php/topic,118440.0/topicseen.html
You'd think they'd roll those improvements into the new 1.5 IDE, but I guess not. Can lead a horse to water, can't make him drink....
Title: Re: Arduino clones with more RAM than Uno?
Post by: dc42 on Nov 18, 2012, 11:51 pm
That's probably the IDE that was referred to in the post I saw, not the 1.5 IDE!
Title: Re: Arduino clones with more RAM than Uno?
Post by: UnaClocker on Nov 19, 2012, 12:42 am
Well if the improvements don't make it into the final 1.5, I'm sure those guys will apply them to 1.5 afterwards, like they did with 1.0.2..
Title: Re: Arduino clones with more RAM than Uno?
Post by: bratan on Nov 20, 2012, 06:19 pm
I used FreeRam function to test how much RAM is being used.
Running my clock sketch it shows from 1167 to 922 available (depending which menu I'm in).
However as soon as I enable Waveutil.h library it jumps down to 110 bytes. I'm not even playing audio at this point. So I don't think there's anything I can do to optimize it (I don't want to mess with WaveHC library) other than upgrade RAM :(
Title: Re: Arduino clones with more RAM than Uno?
Post by: dc42 on Nov 20, 2012, 06:23 pm
How about posting your clock sketch?
Title: Re: Arduino clones with more RAM than Uno?
Post by: bratan on Nov 20, 2012, 08:38 pm

How about posting your clock sketch?

Ok :)
Title: Re: Arduino clones with more RAM than Uno?
Post by: bperrybap on Nov 20, 2012, 10:07 pm
Look at the nm output.
You can see what is eating up your space.


The wavehc stuff appears to be commented out however
a a quick looks show two 512 byte buffers in wevehc.

Another big guy is a 256 byte shadow buffer for the graphics.
That is quite a bit just right there.
Total BSS without wavehc is currently 0x2c8 which is 35% of your
total RAM. Add in 0x400 for the wavehc buffer1 and buffer2 buffers and you up to 0x6c8
which only leaves 0x138 for everything else including stack  and
I'm sure there are other variables in the library as well too.

There are several variables in the main sketch that look like they are not
changing and could (should) be declared const to eliminate some storage there.

The wavehc does run on m168 and will automatically drop the buffers down to 256 if on
that part. There are some other limitations that come with that (bit rate etc) but you
may want look in the wavehc header and see if you can get away with using the smaller
buffers by patching the defines like they are on a m168.

Best thing is to run nm and objdump to start looking at where the memory is going
and see if there is anything easy (like putting the wavehc in m168 mode) that can be done
to save RAM.

--- bill

Title: Re: Arduino clones with more RAM than Uno?
Post by: CrossRoads on Nov 20, 2012, 10:21 pm
Duemilanove-style 1284 is not hard to make.
(http://www.crossroadsfencing.com/BobuinoRev17/1284_thruhole2.JPG)
http://www.crossroadsfencing.com/BobuinoRev17/1284_thruhole2.JPG
I sell bare boards for $5 shipped to US locations, scrounge  the parts  you need or pick up for ~$15 at mouser.
On board (MIKROE483) or off board USB/Serial (FTDI Cable or similar) supported too.
PL here www.crossroadsfencing.com/BobuinoRev17/
Title: Re: Arduino clones with more RAM than Uno?
Post by: bratan on Nov 20, 2012, 11:02 pm


The wavehc stuff appears to be commented out however
a a quick looks show two 512 byte buffers in wevehc.

Another big guy is a 256 byte shadow buffer for the graphics.
That is quite a bit just right there.
Total BSS without wavehc is currently 0x2c8 which is 35% of your
total RAM. Add in 0x400 for the wavehc buffer1 and buffer2 buffers and you up to 0x6c8
which only leaves 0x138 for everything else including stack  and
I'm sure there are other variables in the library as well too.

There are several variables in the main sketch that look like they are not
changing and could (should) be declared const to eliminate some storage there.

The wavehc does run on m168 and will automatically drop the buffers down to 256 if on
that part. There are some other limitations that come with that (bit rate etc) but you
may want look in the wavehc header and see if you can get away with using the smaller
buffers by patching the defines like they are on a m168.

Best thing is to run nm and objdump to start looking at where the memory is going
and see if there is anything easy (like putting the wavehc in m168 mode) that can be done
to save RAM.

--- bill



Wow thank you! I'll give it a try. I also had no idea that declaring consts instead of variables will save ram.

Duemilanove-style 1284 is not hard to make.
I sell bare boards for $5 shipped to US locations, scrounge  the parts  you need or pick up for ~$15 at mouser.
On board (MIKROE483) or off board USB/Serial (FTDI Cable or similar) supported too.
PL here www.crossroadsfencing.com/BobuinoRev17/

That's a beauty!  I think I'll order a PCB from you. Will it work with 644p? I had hard time finding 1284, they seem to be out of stock almost everywhere. I did request 644p sample from Amtel and it's on it's way.
Title: Re: Arduino clones with more RAM than Uno?
Post by: retrolefty on Nov 21, 2012, 12:23 am
Quote
Will it work with 644p?


Yes, 1284p and 644p in DIP at least have same pin out.

Lefty
Title: Re: Arduino clones with more RAM than Uno?
Post by: cyclegadget on Nov 21, 2012, 01:32 am
@Bratan

  CrossRoads could probably hook you up with a chip. I have purchased several of CrossRoads PCBs and one of his Bobuinos that is loaded with features! CrossRoads does some great work!

  Also, on the subject of the 1284, I am using one of CrossRoads SMT 1284 boards to make a 20MHz version for fun. Someone recently made a bootloader so, that the chip will work properly at the higher frequency. I am considering putting a socket for the crystal to sit in so that I can try other frequencies. The socket will be easy to remove later if I do not like it.
Title: Re: Arduino clones with more RAM than Uno?
Post by: CrossRoads on Nov 21, 2012, 02:52 am
Thanks cyclegadget :)
Title: Re: Arduino clones with more RAM than Uno?
Post by: dc42 on Nov 21, 2012, 08:57 am
I took a look at your sketch. Which DS1307 library are you using?

As well as changing the variables that represent unchanging data (e.g. pin numbers) to const, another easy win is to replace Serial.println("text") in setup() by Serial.println(F("text")).

I was unable to find monthShortStr(), but I suspect the month strings are another candidate for moving into PROGMEM.

Table divider[12] occupies RAM but appears to be unused.

Variable tempString should be local to the function in which it is used, like timeString. Similarly for tempChar.
Title: Re: Arduino clones with more RAM than Uno?
Post by: john1993 on Nov 21, 2012, 12:57 pm

Duemilanove-style 1284 is not hard to make.
I sell bare boards for $5 shipped to US locations, scrounge  the parts  you need or pick up for ~$15 at mouser.
On board (MIKROE483) or off board USB/Serial (FTDI Cable or similar) supported too.


i had a similar requirement for large ram and was given one of your m1284 boards. im very impressed with the design. do you have a link to a bootloader? also can you tell me what avrdude command line would be used to load a small test program to that with a com5 dongle?
Title: Re: Arduino clones with more RAM than Uno?
Post by: cyclegadget on Nov 21, 2012, 03:20 pm

Here is the thread about the 20MHz bootloader for the 1284P. I have not tested it yet.  http://arduino.cc/forum/index.php/topic,128604.msg968632.html#msg968632

Here is the bootloader I use for boards from CrossRoads https://github.com/maniacbug/mighty-1284p

By the way, the board has to be selected as Bobuino or your pins will not match. There are other 1284 variants that have different pin mapping. The problem may apply to the first link I gave you.
Title: Re: Arduino clones with more RAM than Uno?
Post by: john1993 on Nov 21, 2012, 04:34 pm
thanks. im using the standard bobuino16mhz at the moment but both those links may prove useful. tom gave me a set of his customized bootloaders and while the m8 ones worked im having no luck with any of the m1284 ones. maybe for some of the reasons discussed in that thread. thanks again.
Title: Re: Arduino clones with more RAM than Uno?
Post by: bratan on Nov 22, 2012, 12:41 am
http://www.youtube.com/watch?v=Mj5q4dIM2Ik

It works!!! I just tried it with Mega 2560 and it has enough RAM to run my clock and WaveShield!!!  Mega 2560 was just a proof of concept, now I need to get it working on 644p (which just arrived). Thank you all for you suggestions!
Title: Re: Arduino clones with more RAM than Uno?
Post by: cyclegadget on Nov 22, 2012, 04:30 am

I like your work and your display! The voice sounds pretty good too!

What is the distance between LEDs on the display? I am thinking about making one similar but, I need to know how far apart to put the LEDs to make it look nice like yours.
Title: Re: Arduino clones with more RAM than Uno?
Post by: CrossRoads on Nov 22, 2012, 06:13 am
Those look like dual color 8x8 matrices.
Title: Re: Arduino clones with more RAM than Uno?
Post by: bratan on Nov 22, 2012, 01:05 pm


I like your work and your display! The voice sounds pretty good too!

What is the distance between LEDs on the display? I am thinking about making one similar but, I need to know how far apart to put the LEDs to make it look nice like yours.

Thanks! :)
I'm not sure about distance (probably around 2 mm), I'm actually using premade 32x16 bicolor board from Sure electronics  (DE-DP14112). It has 8 3mm 8x8 Green-Red LED matrices and driven by HT1632c ICs so it needs just 4 wires to connect to arduino (plus 2 for power supply). Previously I tried making display with other 8x8 LED matrices but it proved a little challenging to drive them. You can build your own and drive it with MAX7219 (2 per matrix) if you are good with PCB making. Those LED matrices arrange nicely, just put them back to back (most of them have grooves that allows them to arranged tightly next to each other, almost like lego).  I think it's more practical to use 8x8 LED matrices rather than making your own from separate LEDs, but of course it's up to you :)
Bicolor 8x8 can be found for as low as $1 each on eBay, and 32x16 display costs a little over $30.
Sure's matricies in DE-DP14112 are also much smaller than other 3mm 8x8 I was able to find. I don't know if it's good or bad, it will give you more DPI resolution, but smaller display overall...
But if you are planning
Title: Re: Arduino clones with more RAM than Uno?
Post by: tack on Dec 13, 2012, 01:00 am
It would be interesting to see if that could be made to work with the SimpleSDAudio library. That is now capable of up to (pseudo) 16 bit Stereo direct from 1-4 PWM pins and an SD Card adapter. The Wav shield could then be removed. I've used this library in 8 bit mono using a single pin and it sounded good enough for simple sound effects and voices. It ran some Red Dwarf and Stargate voice clips very well, just into a PC speaker input.
Title: Re: Arduino clones with more RAM than Uno?
Post by: bratan on Dec 13, 2012, 04:17 am

It would be interesting to see if that could be made to work with the SimpleSDAudio library. That is now capable of up to (pseudo) 16 bit Stereo direct from 1-4 PWM pins and an SD Card adapter. The Wav shield could then be removed. I've used this library in 8 bit mono using a single pin and it sounded good enough for simple sound effects and voices. It ran some Red Dwarf and Stargate voice clips very well, just into a PC speaker input.

Wow I never heard of this. Sounds amazing, I definitely give it a try. If I can get rid of wave shield it would be like a miracle. Thanks for the info!
Title: Re: Arduino clones with more RAM than Uno?
Post by: cobra18t on Dec 19, 2012, 10:19 pm
@bratan and tack

I highly recommend the SimpleSDAudio library. You get good audio with minimal parts. I am working on a board which has buffers and an amplifying filter to improve audio further, but it is pretty good as it is.

I am porting the SimpleSDLibrary over to ChipKit compatible boards to hopefully take advantage of more powerful computation at a lower price point. I have a video of the preliminary port (which I refer to as BasicSDAudio, to distinguish from the pure Arduino version) here:

http://cobrainnovations.blogspot.com/2012/10/basicsdaudio-chipkit-library.html

I am also editing a new ChipKit compatible board, the FubarinoSDt. It uses an 80MHz, 512k Flash, 32k RAM, 32bit PIC processor and has a microSD socket and native USB in a breadboard form factor. With built in SD, this board will prove very useful for audio projects. If I do decide to make them available for sale, $25 is the target price. Check it out:

http://cobrainnovations.blogspot.com/2012/12/fubarinosdt.html
http://cobrainnovations.blogspot.com/2012/11/fubarino-sd-new-pic32-dev-board-on-block.html


-Thomas