jmgelba,
The key is to only execute the lookup (or other) code once each time you actually CHANGE the setting - not all the time. If you insist on having it inside a big loop you need a flag to indicate that the setting has changed and that the dutycycle needs to be reset to a new base value.
Bookmarks