|
Re: Camera to motor setup
There are 2 solutions available using proportional control if you are either
1) steering a gun turret using the pan and tilt output from the camera data packet; or
2) slaving the turret in the x-plane by fixing the camera to it
First, if you are using an optical encoder to measure the rotation of the turret and Tmid is the midpoint measurement of the turret and Cmid is the midpoint servo output for panning, then once the camera finds the target,
the desired turret position, or turret_dx, is given by Tmid*(1+((pan/Cmid)-1)). If we set error_x = turret_dx-OE, then the pwm output to the motor powering the turret is 127-Kp*error_x, where Kp is a proportionality constant.
Second, if the camera is afixed to the turret in the x-plane, then the error is simply Cmid-pan. The pwm output is then 127+Kp*error_x.
You can refine these equations to make a PID controller if needed. The math should be optimized for integer math by multiplying and dividing by 100 to avoid truncation error.
Post your own solutions!
Jon Mittelman
Team236 Programming Mentor
|