Aargh, I must admit that I really forgot about active bouyancy from dive-planes.
4 variables: dive-planes, batteries, pumps, compressed air.
problem too complex
I better restrict on programming instead of thinking about Uboat technology.
Fortunately, there are some competent guys to help me.