Moving to Mega 2560?

It is now clear that I will not get what I ultimately want into the 32k on my EtherTen. I am looking at getting some Mega 2560s. Is the programming much different? Is the IDE is different? How does it know I can use more memory?

https://cosm.pachube.com/feeds/83153

Is the programming much different?

Depends on whether you are using things like direct port manipulation, or not.

Is the IDE is different?

Yes. Everything is upside down.

How does it know I can use more memory?

It doesn't. It is STILL up to you to limit yourself to the available memory.

All I want is what I’ve got, but with more memory. I have (just) enough ports. The IDE tells me how much memory I have used, and what is available, and if I want too much it refuses to compile and tells me why. I am now getting the impression that the board has to be connected in order to compile. If so, I guess the IDE does know.

I am now getting the impression that the board has to be connected in order to compile.

No. It should compile with no board connected. It will not upload the sketch tho.

When you select the board type in the IDE, it gets that information from the boards.txt file.

NickPyner: All I want is what I've got, but with more memory. I have (just) enough ports. The IDE tells me how much memory I have used, and what is available, and if I want too much it refuses to compile and tells me why. I am now getting the impression that the board has to be connected in order to compile. If so, I guess the IDE does know.

No, the verify button will also compile the sketch without a board being attached to the PC. Also the IDE and compiler uses the IDE board selection menu to determine what kind of chip you are using and it's flash memory size limitations.

Lefty

When you select the board type in the IDE, it gets that information from the boards.txt file.

Thanks. That's what I needed.

I couldn't remember selecting the board. So it's the same IDE, and it then knows I have more memory. I guess the simplest thing to do is set up an IDE for the Mega stuff in another folder. I understand there are a couple of pin differences, but all I really need will be about 50% more memory.

retrolefty: No, the verify button will also compile the sketch without a board being attached to the PC. Also the IDE and compiler uses the IDE board selection menu to determine what kind of chip you are using and it's flash memory size limitations.

Which means you don't even have to wait until you get a mega2560 or even a mega1280 before you try to test compile your code. Just select the relevant board type you are interested in from the drop down list under Tools|board, then press select Sketch|verify/compile (or Ctrl-R, or press the "tick" button).

BTW, the mega1280 can be had for small change these days (old stock -- look on ebay, etc.) and even though it only has 128K flash as opposed to 256K flash of the mega2560, in reality, it has nearly identical utility to the newer (and generally more expensive) mega2560, since you can currently only program the first 128K or so of a mega2560 using the Arduino IDE anyway, due to limitations of the older gcc toolchain it is using. Why pay the premium for flash you can't use anyway? Other than the flash memory, the rest of the specs are pretty similar.

The IDE tells me how much memory I have used, and what is available,

Not for all kinds of memory. Only for 1 of the 3 kinds - Flash memory. SRAM and EEPROM usage are not reported.

pico:
Which means you don’t even have to wait until you get a mega2560 or even a mega1280 before you try to test compile your code.

Thanks Pico. I had a “Geez, I wonder if…” moment on this matter under the shower last night but I went straight o bed.

BTW, the mega1280 can be had for small change these days (old stock – look on ebay, etc.) and even though it only has 128K flash as opposed to 256K flash of the mega2560, in reality, it has nearly identical utility to the newer (and generally more expensive) mega2560, since you can currently only program the first 128K or so of a mega2560 using the Arduino IDE anyway, due to limitations of the older gcc toolchain it is using. Why pay the premium for flash you can’t use anyway? Other than the flash memory, the rest of the specs are pretty similar.

I had already done a pretty good deal on eBay for 32k+Ethernet as a package yesterday, they also offer a package with the 2650, which prompted this thread and I am now trying to arrange a change to my order. They offer the 1280 but not as a package and they don’t seem to be selling the shield separately. I’ll settle for the 2560 as I don’t want to complicate things. But I take your point, I’m sure 64k would be more than enough, and I will probably get a 1280 soon.

pico: BTW, the mega1280 can be had for small change these days (old stock -- look on ebay, etc.) and even though it only has 128K flash as opposed to 256K flash of the mega2560, in reality, it has nearly identical utility to the newer (and generally more expensive) mega2560, since you can currently only program the first 128K or so of a mega2560 using the Arduino IDE anyway, due to limitations of the older gcc toolchain it is using. Why pay the premium for flash you can't use anyway? Other than the flash memory, the rest of the specs are pretty similar.

I've just experienced that, I'm surprised and disappointed :/ What must I do in order to use all the available flash?

NickPyner:
It is now clear that I will not get what I ultimately want into the 32k on my EtherTen.
I am looking at getting some Mega 2560s. Is the programming much different? Is the IDE is different? How does it know I can use more memory?

https://cosm.pachube.com/feeds/83153

The MEGA 2560 has 256K of flash (8K used by a bloated bootloader that easily trims down to 2K), 4K of EEPROM and 8K of SRAM. Quite a bit more than the UNO.

But let me ask you this… WHAT memory are you running out of?

You may be defining a lot of strings as const char *string = { “I am a string” }; and using up all your SRAM when you could be using PROGMEM and storing your static strings in (plentiful) flash memory.

As far as the IDE… it’s exactly the same - everything is the same - you just tell the ide which board you are using (Tools / Board / Mega 2560).

When you configure the IDE, it loads a different set of constants that tell the IDE how much memory you have, what clock speed, etc… when you upload you will see it says your sketch is “xxxx out of 258058 bytes” (or something of that size) versus “xxxx out of 32256 bytes”).

The MEGA 2560 has a lot more ports… 16 analog inputs instead of 6, all the regular digital ports (0 thru 13) are PWM capable, rather than just some, and there’s a whole extra row of 18 pins x 2, which (not counting the power and ground pins) gives you 32 more digital ports!

All Arduino daughterboards (oops “shields”) plug into the MEGA just fine.

One thing to think about first is… do you REALLY need a bigger board, or can you use your smaller board more efficiently and fit your code into IT?

Hope this helps.

… Roger

Thanks for your comment, particularly on shield compatibility. I’m not interested in all the extra ports, My stuff is mostly I2C or one-wire bus and I just want to be sure my existing proto boards are OK.

As for the memory, yes I understand the flashmem has run out as the IDE tells me the sketch is too big and I now see it hovering over 30k when I backpedal.

The whole business snuck up on me from behind when I wasn’t looking. My first development was going fine accumulating probes, display, clock and SD, and using about 18k, so I never thought I might have a problem.

I then started on the WAN. I was having so much trouble with cosm that I went right back to scratch, just to get a signal, then with just two probes.

https://cosm.pachube.com/feeds/83153

Yesterday I tried to merge the EtherNet code into the more comprehensive code and promptly ran into the wall. I suspect the main problem is the extra libraries. I started trimming it by clearing out the serial commands that I don’t really need, but I’m sure I’m just kidding myself, since

  1. I have one more temperature probe to go. No big deal, but inevitably more data manipulation.

  2. There is another sensor, a water turbine that I haven’t even started on yet. No extra libraries though.

  3. I want to at least prepare the ground for ditching the LCD and using a Nokia 5110 instead. The Nokia looks like it brings a substantial memory penalty as it uses look-up tables.

  4. I also want to prepare for using bluetooth, and I know nothing about it, but there is sure to be another library.

For all that, I’m sure I won’t need anything like 256k, 64k will probably suffice.

Right now, even without an I2C display I have enough pins for all my sensors. Through a comedy of errors, my original success was with 2x DS18B20s on separate lines. It is only recently that I have changed to one-wire and that only because it was easier to adapt code to get data onto the network. No libraries are required with individual data lines and I suspect there is a big memory cost in using the Dallas libraries in order to save two pins that would then be unemployed. Nonetheless, I don’t think ditching one-wire would save me.

What I intend to do on the weekend is re-launch the Arduino IDE from a new folder and set it for 256k. I will then continue to merge the two sketches. When I get something that looks sensible and compiles kosher, I will post it on a new thread.

It never occurred to me that the other memory might be in strife too. I see no suggestion that it might be but how can I check that?

I respect your question but I am right now trying to change yesterday’s order for two 32k to 256k Megas. I really need three devices right now but only two are remote. The 32k I am currently using can stay here as already works and it is not that important to have it on a network, so I have refrained from getting a third 256k. In view of this, and your comments, I will pursue compacting the code, but I can do that at leisure - which is just as well, as I’m getting a bit past this stuff. Twenty-two years ago, I formed the firm view that programmers should be forcibly retired at 50.

I take your point on the efficient code, I will be set up to try it, and I would rather use 32k boards anyway, if only because the 256k board will be stretching the friendship in the enclosures I have. I have never heard of PROGMEM and will check that out. Could it be that PROGMEN is just what the Nokia display needs?

Thanks again

NickPyner:
But I take your point, I’m sure 64k would be more than enough, and I will probably get a 1280 soon.

All things being equal (like price), I’d get a mega2560 r3 rather than a mega1280. But sometimes you do see the old mega1280 boards at low clearance prices, so it’s just something to keep an eye out for. Just a FYI comment, really,

Krupski: All Arduino daughterboards (oops "shields") plug into the MEGA just fine.

Not true, unfortunately. Some boards that use SPI interface designed for the Uno may not work with a Mega, for instance. Indeed, this was true of earlier versions of the Ethernet shield (although most recent designs seem to have fixed Mega compatibility.)

So don't assume shield compatibility. Do your homework, or risk disappointment.

OK I am trying to get the 2560 and EtherNet as a package, so they had better work together..... From what I can see, the SPI library goes with everything to do with ethernet.

Which ethernet shield did you order? Do you have a link?

All the newer "standard" designs work with the mega now, so you'd be unlucky to get one that wasn't compatible.

One thing to consider: How many ports do you need open at the same time? The W5100 chip based shields only allow 4 ports. The W5200 allow 8 ports.

And none can do anything involving secure layer connections. Not even a Due would be able to manage that.

The Arduino as an Internet server or client is actually a pretty limited device. Once you get past a certain level in your requirement, there is no point in trying to cajole an Arduino to do the job -- they just don't have the resources. You really need to step up to a next level device.

pico: Which ethernet shield did you order? Do you have a link?

This is the eBay number 271092572676 it is W5100, same as what I have now on the EtherTen. The gear looks pretty lonely on the Mega board. You would think they could have found some space for prototyping there, even if just for a clock!

One thing to consider: How many ports do you need open at the same time? The W5100 chip based shields only allow 4 ports. The W5200 allow 8 ports.

Hummm, I had not considered this. Three of my four sensors need to be permanently operational, the LCD is mostly decoration, and cosm is only visual. I suppose this is just a matter of allocating the sequences in the loop, ensuring that the sensors and the SD have priority?

The Arduino as an Internet server or client is actually a pretty limited device. Once you get past a certain level in your requirement, there is no point in trying to cajole an Arduino to do the job -- they just don't have the resources. You really need to step up to a next level device.

I now realise that the real recorder is the SD card, not cosm. I naively thought cosm held great swag of data in CSV. I imagine Arduino still suffices though. What I want is much the same as the weather stations etc. that are common on cosm.

NickPyner: Hummm, I had not considered this. Three of my four sensors need to be permanently operational, the LCD is mostly decoration, and cosm is only visual. I suppose this is just a matter of allocating the sequences in the loop, ensuring that the sensors and the SD have priority?

If you are only uploading to cosm, only one socket connection/port will be used at a time, so you should be fine.

If for any reason you needed to have more than 4 connections open at once, though -- not fine.

I misunderstood you.

Yes, I expect I will only be connected to cosm. I now understand that I can retrieve history from there!

Thanks