I've been following this thread, and I'm a bit curious. Is this a job you have been tasked with, or was it assigned to you as a learning experience? There are quite a few ways to go about this, and all of them can work equally well, but when you are asking questions about which instruction to use, it seems you are completely new.
What is your time frame? There is a nice bit to this, perhaps you should set up a test bench and work through some tutorials if it is an option. You really don't want to try and "learn" to do this on the fly on a live production system.
We know the task at hand, but give us a bit of background and help us help you.
So two questions for you:
1. How did you come about getting tasked with this project?
2. Has the IO (aka sensor) even been wired up yet?