Call Search
     

New to Ham Radio?
My Profile

Community
Articles
Forums
News
Reviews
Friends Remembered
Strays
Survey Question

Operating
Contesting
DX Cluster Spots
Propagation

Resources
Calendar
Classifieds
Ham Exams
Ham Links
List Archives
News Articles
Product Reviews
QSL Managers

Site Info
eHam Help (FAQ)
Support the site
The eHam Team
Advertising Info
Vision Statement
About eHam.net

donate to eham
   Home   Help Search  
Pages: [1]   Go Down
  Print  
Author Topic: Arrays and eeprom reading and wrinting in Arduino  (Read 17514 times)
N5KBP
Member

Posts: 313




Ignore
« on: November 23, 2016, 01:16:02 PM »

I am trying to learn the Arduino platform and as a practical learning tool I am working on a YC-601 clone for the yaesu radios using the Arduino and a tm1638 display module. I need to be able to save an array of long integers to the eeprom upon power down and retrieve it upon initialization. My main question is can I read and write the entire array as one chunk or do I have to do it one array element at a time. I have looked at using the EEprom object but I have also seen the eeprom.update function in order to minimize writes to the eeprom. Or would it be better to create a structure and R/W it to the eeprom at once?  Also as far as the power down write. I plan on using one of the analog pins to sense the input voltage prior to the 5V regulator and initiate the write if it drops below a preset level. Is this doable?  My experience has been in Visual Basic 6 so I am negotiating the C learning curve. Any enlightenment would be appreciated.

N5KBP
« Last Edit: November 23, 2016, 01:18:54 PM by N5KBP » Logged
VK4FFAB
Member

Posts: 428




Ignore
« Reply #1 on: November 23, 2016, 04:54:48 PM »

Ok, if i am reading your questions correctly, limiting the read write to eprom is a good thing, they only have limited read write cycles anyway, so less here is more.

Next, if you are limiting when you write to eprom to only say on bootup and on shutdown, then doing it all in one call is a good thing, this becomes 1 write cycle to eprom

Code:
MyFunc(var_1, var_2, var_3);

and this while functionally the same is 3 writes,

Code:
MyFunc(var_1);
MyFunc(var_2);
MyFunc(var_3);

Now depending on how long your data string is, you might need to break it up into a couple of calls anyway, if you are hitting the memory limits and the like. Also, if you really need to read and write to file often, you might need to add an sd card to your project and read and write to file rather than eprom.

Hope I followed your questions correctly as was helpful.

rob.
Logged
KG4RUL
Member

Posts: 3081


WWW

Ignore
« Reply #2 on: November 24, 2016, 06:17:17 AM »

The EEPROM is good for an average of 100,000 write/erase cycles. 

You can only write one byte of data at a time to the eeprom with a write cycle time of 3.3 ms.  It is good practice to then read the location to verify the data.

If you are attempting to save data in a power loss situation, be sure that you can maintain adequate voltage to complete all required data writes/verifies.
Logged
KD0REQ
Member

Posts: 2023




Ignore
« Reply #3 on: November 24, 2016, 07:59:50 AM »

or just put on a SD card shield and write that.  if you believe the spec reflects fact, 100,000 r/w cycles, four times a day perhaps (start and shutdown twice a day), is 25,000 / 365 = 68 years. divide by the size of the array in bytes, and that's your reliability target.  there aren't all that many bytes on the board, so the array can't be ginormous.  if it is, add a shield and replace the SD card periodically after startup.
Logged
N5KBP
Member

Posts: 313




Ignore
« Reply #4 on: November 26, 2016, 11:27:16 AM »

Thanks for all the replays. I will be writing and unsigned long array of about 15 elements, so about 60 bytes at a time. The array will contain the offset values for 11 bands and last band, mode etc. used info. This will be read at startup. What my plans are is to power it 12v from the shack supply or wall wort. I will sense the 12v rail for a slip below 10v then write the array to eprom. I plan on having enough filter capacity to allow for the write before the 5v regulator drops out on the Uno board.  I might use a lm7808 between the 12v rail and the uno to keep dissipation of the 7805 on the uno down if it needs it. What do you guys think?
Marty
N5KBP
Logged
KD0REQ
Member

Posts: 2023




Ignore
« Reply #5 on: November 27, 2016, 11:36:03 AM »

the one interesting thing is if there is another cycle running, and you corrupt the write on power down.  I'd keep an A and B array, so there is always something there to fall back onto.  call the A "backup" and the B "active," or whatever flavor you prefer.  looks like you ought to have enough memory for this, and a short transfer routine.  pass parameters so if you choose to refresh the A from B, you don't have the overhead of writing the same routine over again, but backwards.
Logged
VK4FFAB
Member

Posts: 428




Ignore
« Reply #6 on: November 27, 2016, 04:25:13 PM »

I might use a lm7808 between the 12v rail and the uno to keep dissipation of the 7805 on the uno down if it needs it. What do you guys think?
Marty
N5KBP


Just use a 7805 and feed the Vin with 5v, its what I do on all my arduino based boards.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!