Making an arm moving to a specific location and staying there

Hi can someone please explain to me how can I make an arm move to a specific location , I know it has something to do with encoders but I didn’t figure it out can someone give me an example code? Thanks

Um, I might recommend if i can find some code on github, but we have typically used limit switches in the past. Limit switches commonly used in FRC are usually small plastic boxes with a small piece of metal protruding from the box ( ) (Sorry that link is so long) Last year, we had pivoting arms on an elevator that when raised would contact a limit switch, resulting in us being able to maintain quick movement times- sorry, tangent. These limit switches simply return if they are pressed or not. In your situation, you could power the arm, and then apply code so when the arms make contact with the switch, the code stops the motor which powers the arms. Again, i’ll look around for code, but am typically more associated with the mechanical side of FRC, so it might not be exactly what you’re looking for.

Update: Limit switch sample code published by team 4940:
(edit for update)
(edit for my poor spelling self)

The more general approach is to use an encoder on the mechanism and PID running either on the roboRIO or a smart motor controller (Talon SRX/FX or Spark MAX). If you explain your setup a bit more (what motor controllers and motors) I can point to some compatible example code.

1 Like

PID with feed forward is your friend.

Interactive arm tuning example

Our 2019 example, which includes both PID and trajectory planning… maybe not what you’d want if this is your first go-around, but here it is anyway.

Keep in mind - this is as much a programming problem as it is an overall system design and modeling problem. Expect to spend some time understanding the math of your system, and designing what you want it to do, long before before typing lines of code.


We use a mini cim with talon srx

Ok thanks

Thanks I don’t think that I could implement a limit switch in this case but thinks anyways

Of course

Here’s a general resource for understanding PID loops:

For actually programming them, the Phoenix documentation goes through everything you need to get it working:

Make sure you also follow the sections before that about sensor and motor controller bring up when you’re ready to test on an actual robot.

1 Like

What are you applying this to? A specific example would allow people to relate it to their previous designs/general knowledge and give more specified advice.

I don’t have an image but it’s a basic arm like in 2019

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.