Sometimes understanding the process is the difficult part. When I am asked to help modify a machine from manual to auto I will set up a video recorder so I can study the complete sequence the machine is expected to go through.
In my last post I forgot a variable. You will need a variable to remember how many times the machine has been started. Let's call this M_S.
The first time the machine starts all EEPROM locations will have the value of zero.
So the first thing will be to increment M_S to 1 and save that.
Now the machine will go into normal operation.
The TOTAL is incrementing. Saving to EEPROM.
The Parts_Run is incrementing. Saving to EEPROM, this location could have the name of PS_1.
The machine is shut down and re-started.
The TOTAL EEPROM location(s) is read and the value is placed into var TOTAL.
M_S is read and if it is 1 then two things need to happen. M_S will now be incremented and saved back to EEPROM. Now the Parts_Run value will need to write to another EEPROM location, this location could be named PS_2.
The number of parts ran the first time will be unchanged. You may want to display this on the LCD.
The same thing will happen each time the machine re-starts withe the Parts Run value saving to a different EEPROM location.
Lets say you set this up for 5 re-starts.
Code:TOTAL VAR WORD 'STORED IN EEPROM LOCATIONS 0 AND 1
PS_1 VAR WORD 'STORED IN EEPRON LOCATIONS 2 AND 3
PS_2 VAR WORD 'STORED IN EEPRON LOCATIONS 4 AND 5
PS_3 VAR WORD 'STORED IN EEPRON LOCATIONS 6 AND 7
PS_4 VAR WORD 'STORED IN EEPRON LOCATIONS 8 AND 9
PS_5 VAR WORD 'STORED IN EEPRON LOCATIONS 10 AND 11
M_S VAR BYTE 'STORED IN EEPRON LOCATIONS 12 AND 13