Hi,

I have a big problem with your program ...

What is it intended to do ??? ( Which inputs give which Outputs ??? ) or explain what you try to drive.

Understand by that there's a problem related to input signals use ...

try to write it down clearly on a paper ... there's some " overkill " in your program ... and it can be much, much, much simplified ...

Alain