Go Down

Topic: How to know if a Arduino has enough memory for a project (Read 2 times) previous topic - next topic

liudr

Nick, you dont have to always be right, like not every needs mega. Read long comments retroplayer wrote to make up for the lack of extensive exper ien you got with uno and standalone projects. The whole point, I repeat whole point of having a dip chip in the world of surface mount, is clearly to be able to prototype and remove the chip to make a standalone project or damaged chip. If you designed as many arduiblno standalone projects as I did, while not having the steady hand or skills as I dont, you wil know surface mount 100+ leg chips are absent from these designs.

Nick_Pyner



Many people leave in Serial.begin for example when they aren't using the serial port in their final design. This adds in the entire serial library to the compiled code. By removing just that one line, you leave out a ton of code that you weren't using anyway.


This is one of the best rambles I have seen on this forum. While I recognised that the serial port may be only used in debugging, it never dawned on me that there is a prize for dropping the serial begin command.  As it turns out my jobs need the serial for bluetooth but this is a trick to keep in mind.  I had the view that, while I was took a future bluetooth card as a final reason for moving to the Mega, this had turned out to be the only reason for not moving. Apparently that was not quite true after all......

Retroplayer

Yep. Just tested it:

For a blank sketch:

Code: [Select]

void setup(){

}

void loop(){
 
}


It compiles to 466 bytes.

Just adding Serial.begin(9600); in the setup:

Code: [Select]

void setup(){
Serial.begin(9600);
}

void loop(){
 
}


Results in 1.75K compiled. Just one line! That's beacuse it is now including Serial and all support libraries for it.

Obviously you aren't going to save 1.75K by removing it because many of the same support libraries are used by other functions, but every bit makes a difference.

Code: [Select]

void setup(){
Serial.begin(9600);
}

void loop(){
  digitalWrite(3,HIGH);
}


Compiles to 2K. While:


Code: [Select]

void setup(){

}

void loop(){
digitalWrite(3, HIGH);
 
}


Compiles to 732 bytes. Nearly 1.2K is used by the serial library and we weren't even using it.

Here's my raw measurements:

466 bytes for blank sketch
1,744 bytes for blank sketch with Serial.begin() in setup
2K with digitalWrite in loop
732 bytes without serial.begin
1K for just analogWrite in loop
2.3K for analogWrite in loop and Serial.begin in setup

PeterH


It may not seem obvious to someone first starting out, but there is "Arduino, the hardware", and "Arduino, the software." And they are really separate from each other.


I would go a step further - there's really:
Arduino, the hardware.
Arduino, the runtime software.
Arduino, the integrated development environment.

The hardware and runtime software is great.
The IDE isn't great but it's free, and makes it easy to get started in firmware development.
I only provide help via the forum - please do not contact me for private consultancy.

Nick_Pyner

#24
Feb 07, 2013, 04:28 pm Last Edit: Feb 07, 2013, 04:48 pm by Nick_Pyner Reason: 1

Nick, you dont have to always be right, like not every needs mega. Read long comments retroplayer wrote to make up for the lack of extensive exper ien you got with uno and standalone projects. The whole point, I repeat whole point of having a dip chip in the world of surface mount, is clearly to be able to prototype and remove the chip to make a standalone project or damaged chip. If you designed as many arduiblno standalone projects as I did, while not having the steady hand or skills as I dont, you wil know surface mount 100+ leg chips are absent from these designs.


Assuming I have read your garbled first sentence correctly, I said nothing of the sort. What I said was

"..... tralala... and that is where the memory goes........In my case the cosm library was the straw that broke the camel's back......I think it would be fair to say that, if you want to have a proper system sending  data the to internet, a Uno will not suffice. ...... "

By this, I would have thought was quite clear, I mean it is likely to have insufficient memory to do the job. I will stand corrected in the light of a proper demonstration to the contrary, but I have yet to hear of one and therefore rely on my own experience in the same arena. Both the experience and the arena are not so different from the OP's, hence my comment. I have read Retro's post, unsterstood it perfectly, and awarded it the applause it deserves. I don't see the slightest relevance in your blather about 100 leg chips, your definition of a standalone project is dubious, and none of this has anything to do with the issue at hand - memory.  As it happens, my 32K board has a soldered-in chip anyway. This has nothing to do with the reason for retiring it, but having a 42k project has quite a lot to do with it..

Go Up