Pages: 1 2 [3]   Go Down
Author Topic: How to know if a Arduino has enough memory for a project  (Read 1638 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11179
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

I think you need to be clear whether you're referring to the Arduino IDE or the Arduino runtime libraries.

There are various things about the IDE that really irritate me. But it's good enough to get the job done.

There are other IDEs that you can use to write sketches and these can make use of the identical Arduino runtime libraries and the hardware abstraction that these libraries provide. Or you could write the source in any text editor and build the image manually - you don't *have* to use an IDE.

It's also possible, as you suggest, you avoid the Arduino runtime libraries completely and write your own code that interfaces directly with the hardware. For people already familiar with working in this environment, that would be a reasonable solution. But the Arduino runtime library does take away a lot of the pain and complexity of dealing with the hardware and if you aren't certain whether you need it then I'd suggest the answer is that you do. But you can use the Arduino runtime library without using the Arduino IDE, if you want.

Possible alternative IDEs are the AVR IDE, Eclipse and Visual Studio. No doubt there are others too. If you're already familiar with any of them, you might want to search for explanations of how to use these to build Arduino sketches.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Or you could write the source in any text editor and build the image manually - you don't *have* to use an IDE.

Yep. In fact, I typically write my sketches using ultrastudio because I enjoy the function list feature and the code-folding. It also has autocompletion, but I am finding that more of a pain than help.

Does anyone know if you set up visual studio for the arduino, does it include code completion similar to what you get with visual basic and the like? I liked that it listed all the methods of the objects for me. Something to help keep track of variables and their scope would also be nice. Typos, forgetting how a function is called, or forgetting whether I used a capital or not in my variables is my biggest source of frustration.
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 30
Posts: 1682
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Obviously you aren't going to save 1.75K by removing it because many of the same support libraries are used by other functions

I had completely missed your reply #22 when I was asking about the ton. I guess the above explains  why, when you develop a project with various libraries, the increase in memory required can be deceptively gradual. You can't tell what is really going on because a new facility you add might be demanding resources that are already in place. Then you get one that doesn't have the resources in place, and it all  hits the fan........
Logged

Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not that I said anything truly profound or magical, but it is stuff like this that should really be put up somewhere with tips, tricks, and gotchas. With the arduino, it is so easy to use libraries. I try really really hard not to unless I understand completely how they work just to keep my code from getting bloated. Even when I am well under the 32K and 2K marks, I still loathe the idea of wasting space. I guess that comes from the Commodore 64 days.
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 65
Posts: 6908
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Not that I said anything truly profound or magical, but it is stuff like this that should really be put up somewhere with tips, tricks, and gotchas. With the arduino, it is so easy to use libraries. I try really really hard not to unless I understand completely how they work just to keep my code from getting bloated. Even when I am well under the 32K and 2K marks, I still loathe the idea of wasting space. I guess that comes from the Commodore 64 days.

I once was scr**d by a library a particular popular DIY store published for OLED. There are so many commands that don't work and they don't even have specsheet. They put the displays on the market with that library anyway. It bothers me if I can't even use lcd.clear(). I tend to look inside library code just to see how neatly the code is written. That tells you the quality of the library. Coming from x86 back ground, I'd argue the same thing about wasteful behavior of then c compilers. If I write an assembly source program that stores as 2K on a floppy, the compiled and linked executable is always less than 2K. I have many comments but still was amazed how some programs are megabytes large.
Logged


Pages: 1 2 [3]   Go Up
Jump to: