This may be of some help:
http://www.chiefdelphi.com/forums/pa...gle&paperid=10
This was before my time, but it's the code used on our 2001 robot for balancing on the ramp. I realize that this is a different sensor, but I'm assuming the same general idea is there. Good luck!