After reading many team’s hood code, l find that most teams use velocity closed loop control or PID controller and a feedforward controller to calculate the speed of the hood. However, l am curious that since the hood can only move in a limited range of angle, l just need to calculate the angle of it using encoder to get the units and then clamp it between the limited range. And set the position to the motor directly. So , why are so many teams using velocity to control the hood. Is there any advantage?
Can you give an example of what you’re talking about? What you’re describing sounds like a flywheel control, most hood controls aren’t like this. For example, 254’s 2020 hood control is quite simple (just goes with percentage output until it hits a limit switch).
The simple answer is to use a position control PID relative to some “Zero” this control PID could be trapezoidal or just PID. Zero being either a sensor or just a known location when the power is applied. (Ie we turned power on with the hood in it’s “down” position. We could also zero by a commanded negative motor power stalling the motor downwards, using output motor current to detect this.
Due to the simplicity of the mechanism we just used a simple P only this year and used the internal encoder of the sparkMax/NEO 550. Only significant change was we limited the PID output in the negative direction as gravity will help it fall and did not want the hood to overshoot negative too far. There are better ways but this worked just fine for us.
A continuously variable shooter hood is an integrating process. If the hood is stationary and the controller output increases, the hood position will continue to increase rather than find a new higher stationary position. P-only control is very effective for integrating processes, especially those with little or no time delay. The integrating nature of the process takes the place of the effect of the integral mode of the controller. P-only is not necessarily optimal for an integrating process, especially when other dynamics and time delays are present. However, for a fast integrating process like a shooter hood, it is likely to be plenty good enough.
P-only isn’t a good choice for hood position because the hood is simple. It’s a good choice because it’s a fast integrating process.
So, does anyone use CTRE’s mag encoder as the encoder to control thte hood PID? Can you share the pros and cons of using CTRE’s mag encoder as the hood encoder? Thanks!
We used “P-only” for our shooter hood this year. We just used the integrated encoder in the NEO 550. The hood started pushed down against a hard stop for our 0 position at the beginning of the match.
That said, adding additional control parameters is not counterproductive. A p-only control can do the job, however, there is still room for improvement. Doing the proper calculations can yield far better results. We utilized a full PID control loop to get near instantaneous ±.001 degree control. Nevertheless, a p only control would be fine for most teams if that level of precision is not needed.
The primary con of using a mag encoder for hood position control is the mechanical complexity of mounting the encoder and magnet. A hood likely does not provide a convenient way of mounting the magnet like would be the case if it was concentrically mounted in a wheel axle or something like that. Some type of offset mounting driven by a gear might be required. There is a hex bore mag encoder housing that might simplify mounting in some cases.
A pro would be if you are using the mag encoder in absolute mode to provide feedback to a PID controller, you would not need a separate way of measuring the startup position of the hood to initialize a relative encoder like would be present in Falcon or NEO motors.
A con might be that the mag encoder uses PWM for the absolute position signal. I’m pretty sure that neither a Talon SRX or Spark MAX accepts a PWM signal in the data port. Both have analog and quadrature inputs, but the mag encoder uses PWM for absolute mode. If the motor control does not accept PWM, the encoder signal would need to go back to the roboRIO for PID control there.
For sure and if a rotary encoder doesn’t lineup right, a flex joint such as tubing could be needed; it’s all hard to maintain especially in the pits between matches.
This season we mounted a short-range IR sensor pointing at a flat space nearby. Analog input and it’s absolute (once calibrated).
We used a 10 turn pot on our hood this year. I’m really liking that method…
We had a string pot on there for a while, which worked OK too. Kinda expensive if you don’t just happen to have some laying around from a test 5 years ago!
I answered that above with our experience the clearances were too tight and we had a terrible time aligning the shafts even with a flex coupling (rubber tubing). If you can get your fingers into the mechanism then sure we like it too. You do have to “calibrate” it if you move the mechanisms relative to each other and that was hard to do, too, unless you turn on the robot and rezero the hood position and put the new constant in the code.