View Single Post
  #4   Spotlight this post!  
Unread 18-02-2010, 11:31
DCRich DCRich is offline
Mentor
FRC #2180 (Zero Gravity)
Team Role: Mentor
 
Join Date: Nov 2008
Rookie Year: 2006
Location: Steinert H.S., Hamilton NJ
Posts: 21
DCRich is an unknown quantity at this point
Re: Programming Pots

PID is the best way to approach a set point. But in this case, it may be over engineering. The problem is that "not equal" in your while loop. In pure math equal or not equal is well defined. In real world engineering there are always tolerances. The A/D will have a noise floor for every signal so when you look to find a specific voltage you may never actually see. Change the while loop to less than High_Pot and then it will stop once it reaches the value or just a tad beyond - unless you are running so fast that the CPU does not see the change (not very likely with the cRIO). Good rule of thumb is to never use = or != when dealing with sensors.