i just post one that use Timer1 interrupt on another thread

Here

Maybe not too handy in your case but to start... i'll do one applied to your need. Later

BTW i read your specification and i know where to begin to do some example.