Quote:
|
Originally Posted by Astronouth7303
What are people doing to control their motors? Specifically, those dealing with arms and positions (not drive).
What I have going is a set-up that reads an array of structures containg pointers to the PWM values & input variables, analog in for the pot, and all the constants needed. Just before the call to putdata(), this is called to handle all the inputs. This same code is used for both autonomous and user modes.
There is also a debugging advantage to this: If part of arm doesn't work, I can point to another part and say, "That works; the code is fine," because it's the same code with different values.
|
That's pretty close to what we use for our arm and joint.
We have a tcr_joint struct that takes in:
pointer to pwm output, pointer to joystick axis, pot ana_in, current pos, servo gain, servo flag, min pot position, max pot position, pot counts per degree travel numerator, pot counts per degree travel denominator, pot position for zero degrees.
We have the counts per degree (integer math as well) so we can set degrees using our scripting interface. The min and max are limits before the hard physical stop.
We actually servo to position, being called after the joyaxes are updated but before put data. We have both a gas shock on our arm and the globe motor while the slider has dual windows (no backdrive).
This allows us to set a position in degrees and once there, the motor will keep the arm at that degree measure, not falling when a tetra is placed or otherwise.
Structs are the way to go though.