Go Down

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

Nick_Pyner



The IDE isn't great


Getting into the Arduino IDE was traumatic enough so I don't think I will change in a hurry, but is the AVR Studio Retro mentions really a better way? Are there better freebie IDEs?


Retroplayer

#26
Feb 07, 2013, 04:50 pm Last Edit: Feb 07, 2013, 04:52 pm by Retroplayer Reason: 1



The IDE isn't great


Getting into the Arduino IDE was traumatic enough so I don't think I will change in a hurry, but is the AVR Studio Retro mentions really a better way? Are there better freebie IDEs?




A "better" way? That's subjective. Your code will likely be smaller, faster, and more efficient. But far more complex since you have to do everything yourself like setting up timers and registers, and such. If you use libraries over there, you run into the same issue anyway (though it will still likely be smaller code).


Arduino is great because it is simple and does a ton of work for you and hides all the really scary bits. But you sacrifice on code size. You are trading some things for another. In the end, you can actually just write the same code in the arduino IDE as you can in AVRStudio. Both are using avr-gcc as the compiler. You can access everything directly if you want.

Nick_Pyner


I have skimmed off a few K before just by changing the way I do things. 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.


By way of interest, how big is the ton? I am producing three three stations and the code is about 42k. I don't expect to do anything about the remote ones using Megas, but I could "change the way I do things" and just might be able to get the Uno back into service here at home. I could dispense with the serial altogether and read the card instead and I will change the display to a 4x20, which may reduce demand, as I believe its library is smaller and the relevant code will be a lot less. 

liudr

I apologize if you don't understand me Nick. I meant your remark on UNO being given the death sentence was wrong.
FYI,

Quote
The only advantage a Uno has is its size, and I imagine it will be squeezed from both ends and die a natural death - rather like the VIC-20.


A standalone project is a project that mostly uses the ATMEGA328 instead of the entire Arduino in the project with a custom built board. There is no official definition.

If you now can understand my point of the usefulness UNO and stand alone project, good for you.  I have seen you and me don't see eye to eye. Don't let all the negative attitude you have against me show to the public.




liudr

Nick,

Pretty sure "ton" in not a real code measurement unit. Retroplayer was just proving a point that many people can easily shed code and memory space by being a bit careful with what they don't use. To understand the "ton" qualitatively, Retroplayer gave a couple of examples. I would extend the example to include Serial.print(float) vs Serial.print(integer,integer);

If you output a float then you need the overloaded print(float) but if you make a simple integer(before decimal).integer(after decimal), you save a "ton".

You can also save half a "ton" by modifying the core to not instantiate the Serial or Serialx (MEGA) if you don't need them.

A "ton" can also be saved by using arrays, functions, understanding PROGMEM, f(), length of integer vs. that of char etc. Sometimes resorting to MEGA is an indulgence of one's own inability to cut wasteful spending in code mall. So I always give an extra push to someone "running out of space" to learn to optimize code before getting a MEGA, instead of a nudge in the MEGA direction regardless. Don't take this as me against you. I only take a stand on issues not who raised them. I do this even if the other side is Grumpy or Paul but seldomly find them to have anything I can nitpick about.

Go Up