Can you discuss to me about EEPROM of BASIC STAMP 2
dontryme0300
Posts: 44
in BASIC Stamp
Hi guys. I`m confuse about reading and writing in EEPROM. Can you teach me or explain to me differ about EEPROM. Because i have a project right now called "BELL RINGER", i can`t start my project because right now i`m still confused on EEPROM. My question is how can i store a ""HH:mm" format of time in EEPROM. For example the time of GPS antenna is "10:30" and there is stored "10:30" also in EEPROM. the basic stamp will be high and the bell will ring on that specific schedule. Can someone help me? Thanks in advance guys.
Comments
Remember that EEPROMs wear out, so you don't want to keep saving the same value over and over again at high speeds. Typically a location in EEPROM is good for 10^6 writes. A good way to help this is to read the location first and compare the new value to the saved value and only change it if the new value is different:
READ location,temp
IF temp <> newValue THEN WRITE location,newValue
You will need 4 locations (bytes) for each time, so for the schedule you posted you would need 24 bytes for each day and 168 bytes for the full week.
There is a limit (typically about a million) to how many times you can write to the bytes but unless the schedule gets updated hundreds of times a day it is not a concern.
If your schedule has entries that do the same thing at the same time on several days you can set it up so you only need one table entry. Make the individual bits of the first byte of each time entry represent the days of the week, and the next four bytes the time. Then to ring the bell at 10:30 on Monday to Friday the data in the table would be:
%00011111, "1", "0", "3", "0"
I was thinking of suggesting something similar but held off doing so because it did not seem worth the effort in this particular case. It would cut table size by 50% at the cost of some extra code so it depends on how compact the compiled code would be.
I think converting the time to four hex digits would make the code simpler and shorter while providing the same space saving. I am tempted to get a Basic Stamp with my next order to see.
I understand. There really is no universal "best way" to do a lot of things, including time/date applications. What I was suggesting works well for this particular application where there are a small number of events, very limited memory to work with, and dealing with time being input in ascii format, but it would not work well in a lot of other cases.
That depends on how complicated your software needs to be. If it is as simple as parsing the GPS data to get the time and reading the schedule to ring the bells you could probably get two hundred or more entries in the eeprom.
The best way to figure that out would be to write the software to do what you want and see how much memory is left over for data. Even if you find you need to add an external eeprom almost all of the software could be re-used.
I see Mr. kwinn.. I`ll keep in touch in you guys... because my team is making our hardware first...
Need some details to be of any more help.
Im using only the NMEA format that recieving by basic stamp. Usually this is the format:
$GNRMC,235951.800,V,2307.120372,N,12016.442898,E,0.00,0.00,050180,,,N*69
I will see what I can do to help. Just keep in mind that I do not have a BS2 to test the code with.