Need reset?
lardom
Posts: 1,659
Is it possible to code a software reset? I'm trying to finish up·a project which will allow me to preserve settings through a reset. If, for example, I program my motor to move 10 centimeters I could do it in one of two ways: I could make it move 10 cm continuously in say, two or six seconds or whatever time I choose. I could also program the motor to move that same 10 cm in 2 cm increments or 1 cm and so on.·Each·mode of operation·saves·three variables. The problem is I have to reset the device twice before I can save all three. I could live with one reset if necessary.
Comments
But why do you need to reset?, I don't quite understand. From your previous threads if you are trying to save your variables to EEPROM though which sounds like this should be the question, then remember that the EEPROM is busy for a few milliseconds for practically every "write". So if your software ignores that it is busy and tries to write the next variable too soon, it will be ignored. The Q&D way of getting around this is to simply wait 5ms or so (after each write). Some I2C objects poll the I2C device and wait until they respond in which case these objects do not need a delay as they will talk to the EEPROM the very moment that it is no longer busy.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
· The 'Mode_Id' variable writes a 1 or 8 to the eeprom. After a reset the 1 or 8 gets copied to the 'select' variable. 1 calls "continuous" and 8 calls "Stepped". I designed the program to·loop through a series of method calls by pressing the 'A' key on a 4x4 keypad. If·I program 'Stepped', 7 cm and·6 steps I only have to press the 'A' key repeatedly which is what I want.
'B' choose between "continuous" or "Stepped".
'A' to accept and start and write Mode_Id to the eeprom
'D' to move curser·to change settings
'#'·will·display numbers that have been keyed in to the LCD and write them to the eeprom
'A' to start
I haven't had time to look at this properly but I couldn't help but notice the strings of IF xx == nn statements. Have you heard of CASE statements? Here is part of your code rewritten:
BTW, since I don't have the hardware hookup or that much time can you just give me a heads up on which methods specifically that are called and from where.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
·You said; "BTW, since I don't have the hardware hookup or that much time can you just give me a heads up on which methods specifically that are called and from where."
·
· I suspected that my last post might·expose sloppy thinking on my part. I will clear it up.
The keypad routine is certainly one that can change. It's a matrix so use repeat loops to scan through columns and return with a code, don't try to toggle backlight or do anything else in this function, just return a code. Don't you have a copy of my keypad matrix routines?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
· I'd like some help figuring why the app hangs if I key in '13 cm' in the 'continuous' mode. It works fine up to '12 cm'.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (lardom) : 4/26/2010 5:34:10 AM GMT