Woohaa i try to figure out but there's too much 'maybe this or that' in my mind.
Can you post your whole code and schematic?