|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: how to creat a home button
Thanks I will try it tomorrow. If you could post some screen shots that would be great
|
|
#2
|
|||
|
|||
|
Re: how to creat a home button
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. |
|
#3
|
|||||
|
|||||
|
Re: how to creat a home button
You may be running away from your setpoint if the motor and the pot are reversed and returning the opposite of what the code is expecting. Your max and min may be reversed.
You can use a probe running in debug to see if the actual pot value is getting further from the setpoint as you run. A simple test is to reverse or negate (-x) the output of the PID icon for the motor set. |
|
#4
|
||||
|
||||
|
Re: how to creat a home button
Quote:
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). |
|
#5
|
|||
|
|||
|
Re: how to creat a home button
Quote:
For the home button i want to be able to push a button and no matter were the turret is it returns to home position automatically when button is pressed. Last edited by pickett : 12-03-2012 at 21:53. |
|
#6
|
||||
|
||||
|
Re: how to creat a home button
Pickett --
See attached .vi I created which should do what you're looking for. Note that there are a lot of different ways to perform the same task in code, and the way I wrote this is just one example (the way I would write it). First off, I am converting the voltage from your pot to an actual angle (by scaling against the min/max values). The output is a value of 0 to your turret limit. I like working with positive numbers rather than using "0" as a home position. Instead, 0 represents one limit, and the Range represents the other limit. Then I check to see which buttons are being held down -- If button 4, set the setpoint to 0 deg. If button 5, set the setpoint to 180 deg. If button 6 ("home button"), set the setpoint to 90 deg. You would have to change these values based on your actual desired setpoints. If no buttons are being pressed, the setpoint is your current position. That would tell the PID loop to stop moving the motor. Remember to put all this within a loop, such as in Periodic Task (or Teleop) Let me know if this helps... |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|