Sketch_Restart()

Ok,

I see where you are coming from - I can replace the bootloader code, so I shouldn't fuss with the reset.

That is probably the correct low risk approach as my simulated reset is never going to be quite right (as otherwise ATMEL would have a doc on their site saying how to do it).

But I am treating it as a learning exercise, to better understand the processor, while also preserving the ability to bootload the code.

My eventual objective is that I will be able to build quite complex strategies into the top level controller - with no need to have the logic that reverts each path back to a known starting point.

This is an extension of a well known approach in application development - called "Crash only software" http://lwn.net/Articles/191059/ - which states that you know your program will fail, so design for it to fail and recover gracefully, and quickly.

If you get it right (like I hope to) then you are free to actively use the fail & recovery path to simplify your system...

So for example, I will only code the control algorithms to a position that is defined in terms of the current position.

All the commands that request a change to a position determined from the boot up state will be saved in a EEPROM location and executed after restart.

This should reduce the amount of code I need to write quite a bit.

Dave