reinventing the wheel again

Having churned out hundreds of Arduino based projects over the last 3 years, and being a less than organised person, I sometimes come across one of my little controller boards ( with a 328 chip and ISP header on ) in a module , and cannot remember which sketch I loaded it with .

When I saved sketches, I put remarks at the top to describe the project, but have only included the line:-

Serial.println("setup"); - to show something is happening-

which doesn't help identify the sketch or what the chip does if I commented out all the other SerialPrints in the sketch.

I might be missing something here , and you guys might have been doing this all the time , but now I put all my sketch descriptions in setup, so that I can plug in any chip and look at SerialMonitor and get the whole story.

Serial.println (" Harrys wall mounted display, using alphanumeric 5x7 pcbs from" );
  Serial.println ("  5s footabll with MAX7219 chips");
  Serial.println (" (2)(32)123456(3)   format  start of text, space, data, end of text.");
  Serial.println ("saved as allprojects/softwareinproduction/Harrysfixeddisplays/allworkingwallunit.ino ");
  Serial.println ("writes to eeprom when serial comes in, reads from eeprom each loop to save");
  Serial.println ("garbled display if power glitch etc. ");
  Serial.println ("using my new zero blanking routine,  display up to 999999 - there modified one 199999");
  Serial.println ("Auto dimming, but with long average time to reduce flicker as only 15 levels of brightness");

Incidentally I have finally moved over to v1 .ino sketches ( I didn't have a chance to copy the libraries over for the last year or more ! )

Very recognizable, not doing it for all my sketches but yes, learned it the hard way;)

So I use in my sketches (if they are more than an experiment) - a title and optional a version number -
And also in my source code I use this header

//
// FILE: .ino
// AUTHOR:
// VERSION: 0.1.00
// PURPOSE:
// DATE:
// URL:
//
// Released to the public domain
//

Can you read that from the source code if you just have the chip ?

Boffin1:
Can you read that from the source code if you just have the chip ?

No, because comments aren't compiled and never get as far as the chip.

Nice.

You could use the F macro to not use ram.
Doing this of course requires the serial support code which uses up memory which may be nearly used up in some applications.

Runs once at power up, takes no time and totally brilliant!

I will certainly be trying this when I get more than one Arduino project.

Having moved on from Picaxe and having numerous chips lying around, it is a good way to ID the program.

Weedpharma

LarryD:
Nice.

You could use the F macro to not use ram.
Doing this of course requires the serial support code which uses up memory which may be nearly used up in some applications.

Maybe PROGMEM.h uses less?

I don't go near as far as Boffin but especially when working with others a startup print with program name and version is a must-have.

Edit: ROFL! A startup print won't happen without some kind of Serial! DOH!

I wonder if you could make a little macro or something that would blink an LED (pin 13 most likely) in a pattern for a number (ie - 3 blinks, pause, 2 blinks = "32") - then look that number up on a spreadsheet or something?

Have it do that constantly until another pin is brought LOW or something, then dump into the rest of the code. It would be smaller than needing the serial lib, you wouldn't need a serial port available (maybe you're in the field?) - and it would use less memory/flash.

Shave and a haircut? (the secret knock)

LarryD:
Nice.

You could use the F macro to not use ram.
Doing this of course requires the serial support code which uses up memory which may be nearly used up in some applications.

I wonder if a small function that hits the hardware serial directly to print out a simple char string so no need of Serial and all it's RAM use? This all assumes the program does not normally use Serial.

It's more about the RAM that char arrays, dialogs, prompts and labels.
If you're not going to run Serial then you might be needing much of those.

However if you do then use PROGMEM to keep constants in flash, not copied straight to RAM.

BTW, PROGMEM is a library in your IDE.

I don't remember if the Serial stuff can be optimized out if they're not used, but if so, a simplistic, hard-coded serial routine can be really tiny. RAM usage could be temporary, and little more than a couple bytes. Flash space would be a couple hundred bytes tops, most of that being the contents you want to transmit.

A sticker with a Rev number on it works also :wink:

LarryD:
A sticker with a Rev number on it works also :wink:

More permanent is a coat of typist's correcting fluid over part of the top of the chip. Write on it with a pen when dry.

cr0sh:
I wonder if you could make a little macro or something that would blink an LED (pin 13 most likely) in a pattern for a number (ie - 3 blinks, pause, 2 blinks = "32") - then look that number up on a spreadsheet or something?

Have it do that constantly until another pin is brought LOW or something, then dump into the rest of the code. It would be smaller than needing the serial lib, you wouldn't need a serial port available (maybe you're in the field?) - and it would use less memory/flash.

PC/XT's used to beep and you might have to look that number up.

Thinking about the memory savings, I have simply included the path and sketch name in the serial print, and then have the comments at the top again commented out.
Thanks guys.

By memory savings you mean flash, right? Because

Serial.println( F( "this string stays in flash, not ram" )); // will show in a hex dump as well as print

Now you are confusing me again :slight_smile: I mean one line of text as a serialPtrint in setup, must be more economical chipwise than the 10 lines I was trying ?

Yes. :smiling_imp:

The data can be kept totally in flash and print from there using the F( ) macro.
Flash is where your program lives, it's what you download sketches into.
Flash also holds constant data like strings (messages, prompts) and lookup tables.

An UNO chip ( ATmega328P ) has 32K of flash and 2K of RAM. Saving RAM is paramount while saving flash only matters when you really push program and data limits, not a usual practice.

If your 10 lines have useful data then stick them in there. Version, Usage, Errors, use them all.

You have the syntax down?