|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
Depending on the servo and controller (I might be completely wrong, I've only tested this on the arduino) you might run into an error where you receive no real feedback from the servo. Some arduino libraries will only report the last value you've sent to the servo, which makes testing for values useless. It might be worth your time to test this hypothesis out with the hardware you plan on using to make sure it truly reports its absolute location and not what the software thinks.
|
|
#2
|
|||
|
|||
|
Re: PID Loop Controller with a Servo
I am getting a test bed built to do some testing with it. The current servo angle you could store as a separate variable and use that to update the new location. Then replace the variable with the new location
|
|
#3
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
Forgive me for not knowing, but how do you get feedback from a hobby servo? Don't they already have PID built in too?
|
|
#4
|
|||
|
|||
|
Re: PID Loop Controller with a Servo
Quote:
I think they do. The more I think about this the more I'm thinking of not using a PID loop and using the distance to the target as a ratio of the angle. The only problem is that the distance away from the target will change that ratio. For instance if you are two feet away changing the angle by one degree will be different if you are five feet away |
|
#5
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
Angle to center of target is independent of distance.
You will need to make less adjustment the further away you are but the error reported will be less as well. What you may run into is a lack of resolution to adjust the servo accurately. That's why I mentioned using microseconds instead of degrees. ie. (~ 1000 vs. ~180) |
|
#6
|
|||
|
|||
|
Re: PID Loop Controller with a Servo
Quote:
|
|
#7
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
That would likely dictate that you would need to not direct mount to the servo. You would probably have to build a specific interface with gearing to account for the extra degrees of motion.
|
|
#8
|
|||
|
|||
|
Re: PID Loop Controller with a Servo
What I meant is how would you control the servo in code using microseconds?
|
|
#9
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
Servos are written a signal that is 1000-2000 uS high, then 20ms low. The number of uS you write is directly proportional to the angle; 1000uS is 0*, 1500uS is 90*, and 2000uS is 180*. There is some error but for relative angle movement (turn 5* to the left) it should be fine.
|
|
#10
|
|||
|
|||
|
Re: PID Loop Controller with a Servo
Quote:
|
|
#11
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
There might be a way to access it in the Servo classes for the RIO, but I'm not familiar enough with it to say for sure.
You could also manipulate timers directly and make your own class for interfacing with them. Or you could send data to an Arduino, which has built-in Servo libraries, at the cost of lag time. |
|
#12
|
||||
|
||||
|
Re: PID Loop Controller with a Servo
A typical (non-continuous) servo already implements closed-loop control onboard, so a PID loop is unnecessary. Just set it to the angle you want and it will handle going there. Servos are quite effective at moving to positions quickly and without overshoot.
You can set a servo in wpilib using Servo.setAngle(degrees) |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|