Changed from using a rate and while loop to using timer callback. It makes the code a lot cleaner than I would have thought and testing showed it to be pretty accurate timing.