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
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.
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
"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.
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.
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.
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.
@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...
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.
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.