Limiting EEPROM write burnout.
Some of you may be familiar with my home project, but basically its a hillside lift that carries people and beer up and down a hill 150 feet.
My STAMP project, is to track the position of the cart to enable/disable switching plus some other stuff.· It will control relays that feed the motor controller.
I'm tracking the position of the cart by using an absolute encoder (0-5 volts for 0-360 degrees read by 12 bit ADC).· The cart is lowered on a cable, which is on a 12 inch drum.· It takes 44 drum rotations to get to the bottom.
One concern I have is to determine the cart location in the event of a power down and power up.· This happens all the time if we are not using the cart, we turn the key off which shuts down the power.· The cart could be at any point on the track.
My program maintains a drum count (how may times has it rotated a full revolution, 38 inches of cable) and the drum's current angular position from the encoder.· Upon power up, I can see the encoder position very easily since it is an absolute encoder, but the drum count is critical to know if the cart is at the top, bottom, or middle.
My plan is to write the drum count to the EEPROM each time it increments or decrements.· A full trip down and back up would be about 90 writes.· I'm using a BS2px which has a max (guaranteed) write cycle of 100,000 times.· I was amazed that the newer technology chip only had a 100K writes when the older modules (BS1, BS2) guarantee 10 million.
So at this rate, a slot would be used up after roughly 1,100 trips.· Although that would probably outlast many of the parts on my lift, I'd like to extend the life of my chip if can do it with a little programming.· I was contemplating having a scheme to rotate through the locations I write to, but this will require a fixed location to put the offset.· Question to the audience, have others done this, and if so, any things I should be considering?
FYI, I have all my inputs/outputs used up, so interfacing with an external eeprom would not be a good choice for me.
My STAMP project, is to track the position of the cart to enable/disable switching plus some other stuff.· It will control relays that feed the motor controller.
I'm tracking the position of the cart by using an absolute encoder (0-5 volts for 0-360 degrees read by 12 bit ADC).· The cart is lowered on a cable, which is on a 12 inch drum.· It takes 44 drum rotations to get to the bottom.
One concern I have is to determine the cart location in the event of a power down and power up.· This happens all the time if we are not using the cart, we turn the key off which shuts down the power.· The cart could be at any point on the track.
My program maintains a drum count (how may times has it rotated a full revolution, 38 inches of cable) and the drum's current angular position from the encoder.· Upon power up, I can see the encoder position very easily since it is an absolute encoder, but the drum count is critical to know if the cart is at the top, bottom, or middle.
My plan is to write the drum count to the EEPROM each time it increments or decrements.· A full trip down and back up would be about 90 writes.· I'm using a BS2px which has a max (guaranteed) write cycle of 100,000 times.· I was amazed that the newer technology chip only had a 100K writes when the older modules (BS1, BS2) guarantee 10 million.
So at this rate, a slot would be used up after roughly 1,100 trips.· Although that would probably outlast many of the parts on my lift, I'd like to extend the life of my chip if can do it with a little programming.· I was contemplating having a scheme to rotate through the locations I write to, but this will require a fixed location to put the offset.· Question to the audience, have others done this, and if so, any things I should be considering?
FYI, I have all my inputs/outputs used up, so interfacing with an external eeprom would not be a good choice for me.
Comments
The i2c versions function just like their eeprom counterparts. You can even remove the 10ms write delay in your code since FRAM parts can perform much faster write cycles.
Harrison
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
You could used the rotating location idea if you write a sequence number along with the position value. It sounds like there are only 45 positions, so this only requires 6 bits. You could use the 2 most significant bits as a sequence indicator. If you only use the values of 0, 1 and 2 for the sequence indicator the latest value will be indicated by a discontinuity in the sequence values. As an example, an 8-byte buffer could have the following values 0:13, 1:12, 2:11, 1:12, 2:13, 0:14, 1:15, 2:14. The value 2:11 would be the last one written because of the discontinuity in the sequence bit going from 2 to 1.
Dave
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·
Chris: You're right, surface mount chips are not what I prefer to deal with, and like I said earlier, I don't have the spare I/O lines for the serial.
Dave: I don't follow the 2nd paragraph.
Bean: I have considered this with a 3:1 reducer (45 tooth to 15 tooth) and a 15 turn pot. I have a 15 turn pot that would be perfect, its the size of a soup can cut in half. It would also be a nice way to have an additional "brake" for the drums if needed. Problem is that it would require about $200 of material.
Does anyone know why the bs2px only has 100K writes versus 10 million for the cheaper stamps?
Dave
#define BUFFER_SIZE 64
#define EEPROM_BUFFER_BASE ????
static int sequence_number = 0;
static int write_index = 0;
// This routine combines the sequence number and the 6-bit value and writes it in the EEPROM circular buffer
void WritePositionValue(int x)
{
··· int value = (sequence_number << 6) | (x & 63); // Combine the sequence number and the 6-bit value
··· WriteEEPROM(value, EEPROM_BUFFER_BASE + write_index);
··· sequence_number = (sequence_number + 1) % 3;
··· write_index = (write_index + 1) % BUFFER_SIZE;
}
// This routine searches for the latest postion value in the EEPROM by locating an incorrect sequence value
// sequence_number and write_index are initialized to the next values and the latest position value is returned
int FindLatestPostionValue(void)
{
··· int i, value, temp1, temp2;
··· temp1 = ReadEEPROM(EEPROM_BUFFER_BASE) >> 1; // Get the sequence number at the zero location
··· for (i = 0; i < BUFFER_SIZE - 1; i++)
··· {
······· // Get the sequence number from the next entry
······· temp2 = ReadEEPROM(EEPROM_BUFFER_BASE + i + 1) >> 1;
······· if (((temp1 + 1) % 3) != temp2) break;
······· temp1 = temp2;
··· }
··· // Extract the latest position value and initialize the sequence_number and write_index with the next values
··· value = ReadEEPROM(EEPROM_BUFFER_BASE + i) & 63;
··· sequence_number = (temp1 + 1) % 3;
··· write_index = (i + 1) % BUFFER_SIZE;
··· return value;
}
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 6/7/2007 7:20:13 PM GMT
So keeping the number in ram and writing it to eeprom with 2000 bytes to rotate through goves you 200,000,000 times to turn it on and off.
Simply initialize the eeprom with $FF bytes, when the stamp powers up search eeprom for a location that contains $FF, drop back one address and load the previous saved value, write the next value to the address that contained the $FF
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
metron9, that makes sense. It would save the need to have a location byte. That would cover 12 years of continuous use, lol.
temp1 = ReadEEPROM(EEPROM_BUFFER_BASE) >> 1;
should be
temp1 = ReadEEPROM(EEPROM_BUFFER_BASE) >> 6;
The same correction should be made for temp2 as well.
One thing I realized is that you could get by with a single bit for the sequence number. This bit would actually indicate a pass through the buffer. It would be zero for the first pass, one for the second pass, zero for the third pass, and so on. The latest value will be at the point where the MSB changes from 0 to 1, or from 1 to 0.
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
In the event of a major failure, or if I was having major problems with my stamp, I'm designing it so I can just turn the thing off and let it run with the normal motor controller logic which is fairly reliable.· I'm just using this controller to disable the "up" button when at the top, and disable the "down" button when at bottom.· Even though there are emergency shutdown limit switches, I'm the one that has to reset the system.· I'd like to kid-proof it.·
Also, I am adding a center landing point, and the "call" button which brings the empty cart to a waiting passenger will require the stamp system to figure out whether to send the cart up, or to send it down.
With the current setup, there are limit switches that tell the controller to ramp down the speed.· I'm leaving those because I trust hardware more than software, but the center stop will be software based.
Sorry, more info than you needed, lol.
A certain amount of experimentation and calibration·would hopefully give fairly accurate results.
Post Edited (skylight) : 6/8/2007 8:28:50 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
How about a pipe and just PUMP the beer to the top of the hill? 150 feet of PVC shouldn't cost much.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
-Phil
1. That is a lot of beer in a pipe, it is a warm or hot day and now the beer is warm.
2. Pipes need to be cleaned
3. thats 75 PSI at the nozzle from gravity. The beer is carbonated as well so I think you may just have foam now.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
I get it, now.
I don't know how many vertical feet of drop there is from the top to the bottom of the hill, but I am dreaming of the "beer pressure" at the spigot of that PVC located at the BOTTOM of the hill! [noparse]:)[/noparse]
My back yard ends in a cliff that drops (not straight down) to the lake owned partially by me and partially by the golf course. The vertical drop is only about 40 feet. I built some rock steps, but they are a true pain to navigate if you are caring anything. (Building those steps with 300 pound rocks is a story in itself!)
We are supposed to do some work on the lake next year. If we do, I am going to need plans for your device.
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
I'd be happy to share the plans with anyone.· My dad can even build the motor controller panel if you didn't want to use a stamp.· We use a motor controller that takes 220volts and drives a 3 phase VFD motor to run the cart up or down.
Here are some vids of it, but these are a little old.· I've done more to in since then:
http://www.youtube.com/watch?v=AbFDJBHZUqE
http://www.youtube.com/watch?v=-jNwK68F8ps
http://www.youtube.com/watch?v=CLjmnQte-JM
I'm in the process of programming a stamp to control/redirect inputs to the system because I want to add a center landing, and to do so, I need some logic to determine which way to send the cart when it is "called" (we have it setup like an elevator, you can call it to you if its on the opposite end).