Help with logging

Hey everybody

I'm brand new to arudino and I am currently writing an investigation report for a project and one part of the report asks me to calculate if there is enough writable memory on an arduino UNO board to keep a full log of program events over a 5 minute deployment where I anticipate events will be happening every 5-10 seconds. We haven't actually recieved our board yet so I haven't had a chance to play with it, nor do I have any experience with anything similar...

Any help anybody could provide would be greatly appreciated :slight_smile:

Thanks!

No idea until you specify exactly which form the message will take.

Then it is just simple arithmetic. Assuming you use the FLASH -- which is normally program memory -- Count the bytes -- determine the amount of available memory and there is your answer. Of course then you will add a program which will subtract from the flash...

But do you mean to collect the data in flash memory, the SRAM or the EPROM -- all different issues.

There are libraries for the EPROM and the FLASH and other posters here are far more knowledgeable on how to do that.

Get the Arduino Cookbook -- see Project Guidance.

It will answer every question you should have. And for about $20 -- cheaper than my rates. :grin:
http://arduino.cc/forum/index.php/topic,52154.0.html

thanks for the reply :slight_smile:

I think it should be collected in the EPROM memory because it isnt actually used in the running of the program - or am I wrong here? I'm fine with the maths but I'm just lost as to how much memory the message will take, and how much space it will consume

What's the information you want to log?

It will just be things such as sensor readings, and what the program's reply to them was..

for instance if a bump sensor hits something the motor speeds will change

"but I'm just lost as to how much memory the message will take"

You are the designer of the program -- right?

So you will decide.

I assume that you have a written description of what the program will do. Post a summary.

(And the answer you just posted is of no use at all.) And that is because you need to know EXACTLY what you will be logging -- "a bunch of stuff" does not cut it as a design statement.

If you can't do that -- then I just pointed out your first mistake. If you don't understand this comment I have no idea how I could possibly help you.

Create your design -- then ask for help.

Ok, I've been reading a bit, found out its 1byte per character so that answers the question of how much data each log entry will take - as I said I am very new to this

Essentially the program is controlling a watercraft that is driving around a pool, changing directions whenever a collision (sensed by a bump sensor) occurs. The task sheet wants a log of decisions and actions to be created - so a log entry would need to be made at each collision signifying that one of the motor speeds has changed to turn the boat around, then when the motor returns to normal speed another log entry should be created.

I am thinking that the log statement should have a 3 digit timestamp (the test is run over 5 minutes) signifying the seconds since the start of the test, followed by a code something like "RMU" or "RMD" (right motor speed up or down).

So I guess I'm now asking, which memory should I be writing this too - Flash or EEPROM?

A place to start would be to figure out how many different event types you will be logging. That'll give you the number of bits required to distinguish between them. Then you need to know if you need to keep any additional data about the event. For bump detection, perhaps you'll have a bump event and you'll want extra data to say which sensor was bumped. How many different action types can you take? Is there extra data for each action? Motors may be set to different speeds for example. Is there timestamp data associated with each event that you want to keep? Probably. What level of accuracy?

Once you know those things, you can figure out a message structure that represents what you wish to store. Then you can do the math to figure out if the arduino has enough memory. Bear in mind, that you can use bit twiddling operations to minimize your use of memory. By which I mean that if you have sixteen event types, don't use a full byte to store them, use only the four you need.

Thanks for the idea about the sensor I cant believe I forgot that :slight_smile:

The craft will be behaving in the same way each time a bump occurs so it is not as important to log that I dont think.

The timestamp that i mentioned in my previous post....logging the duration in seconds since the start of the test should be sufficient

I really am not sure what 'bit twiddling' operations are but hopefully I can shorten the log enough to not need them.

Is storing the log in the EEPROM ok or should it be in the flash memory?

Is storing the log in the EEPROM ok or should it be in the flash memory?

Storing in flash isn't an option, unless you're up for rewriting the bootloader, so EEPROM it is.
You could add external EEPROM, if you're short of space.

Thanks for all the help everybody :slight_smile: I think I've got enough of an understanding for now :slight_smile:

I'm fairly sure the task doesn't allow us to communicate with the Arduino once the test starts but I will check up on adding external EEPROM :slight_smile:

once again thanks for all your replies :slight_smile:

AWOL Said: Storing in flash isn't an option, unless you're up for rewriting the bootloader

It is actually. I have seen the code. I did not test it. I think someone posted the code on one of these forums as well.

Sorry that I don't have time to hunt it down.

You're getting the idea.

Now:
(1) write that document on how you are going to do the project and
(2) then do some flow charts for the events
(3) decide what your log record will look like.

Then try again... but if you do the above and buy that Arduino Cookbook I doubt you will need much help except for small details.

It is actually. I have seen the code.

As usual, if you have to ask the question, it isn't easy/possible.

@WillR:
Do you have a reference for writing to flash?

I know it is tricky, and 'cos of that don't want to spend too much time writing and rewriting boot sector code, but if it has already been done, a nudge in the right dierction would be great!

Groove:
@WillR:
Do you have a reference for writing to flash?

I know it is tricky, and 'cos of that don't want to spend too much time writing and rewriting boot sector code, but if it has already been done, a nudge in the right direction would be great!

See Chapter 17, section 17.4 of the Arduino Cookbook (Margolis, Pub: O'Reilly). If I could cut and paste I would... But at $20 from Kindle (Canada) it is a deal. Even without the frekin' download of sketches...

http://www.amazon.com/Arduino-Cookbook-ebook/dp/B004KKXYPE/ref=sr_1_1?ie=UTF8&m=AZC9TZ4UC9CFC&s=digital-text&qid=1300822966&sr=1-1

It uses ...
#include <avr/pgmspace.h>
I will try to type it in later. Just testing a new board I wired up...

UPDATE:
AWOL is right -- the program I saw uses a read technique he creates "large" pre-calculated tables that the author stuffs into memory in advance of actually running the program. i.e just arrays or strings.
It is a very useful technique -- just not what I thought. I guess it's EPROM or SD card. :fearful:

It uses ...

#include <avr/pgmspace.h>

WillR:
Suggest you open pgmspace.h, and search for the word "write".

AWOL:

Thanks for catching my goof. :roll_eyes:

You are right.

What he does is include large tables of data inside the program -- then READS them out using his program.

He is not WRITING flash -- he is reading only. I can see the usefulness -- but it is not what I thought.

I apologized for creating confusion.

No worries - you're not the first, and I doubt you'll be the last.

As I said, it is possible, but the only place you can write at run-time to program memory is from code executing in the boot segment, so you need to re-write the bootloader.

I guess it's those unconnected grounds in my brain.... rotflmao...