Quote:
Originally Posted by pickett
I am having trouble getting the potentiometer to work. when I run the code the window motor hooked up to the turret runs continuously in on direction. can some on take a look at my code attached below?
I am looking to control the turrets turn radius and create a home button.
|
I'm trying to interpret exactly what are are looking to do with Button 4 and Button 5.
As-is:
It appears that when nothing is pressed, the PID target is always 1.17 (pot min)
When Button 4 is pressed, the PID target becomes 3.9 (pot max)
When Button 5 is pressed, the PID target becomes -(3.9 - 1.17) + 1.17 = -1.56 (out of range)
For this "Home" button are you trying to drive to a mid-value?
If so, when a button is pressed, you should be setting the setpoint to [(3.9-1.17)/2]. You can just put this into a Case structure where the selected Button determines the Case, and if True, run the PID loop. If false, use your other turret logic to specify your motor power.
If this is not what you are trying to do, please describe explicitly your desired function (what you want each button to do, etc).