If you have an 18F2431 on-hand you can do it all in hardware with the motion feedback
module capture. It will record the time for every state change. Very handy for learning
different remote control encoders, IR signals, etc..

I have a code example if you're interested.