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 (https://www.zoro.com/honeywell-premium-mini-swch-3a-spdt-lng-strt-lever-v7-2b17d8-048/i/G4550217/?gclid=CjwKCAiApOvwBRBUEiwAcZGdGBHkKtdBOCk1YEKC8riASW2wDPUJ3t5ebkX2H87vl9W0KeUkQawalhoCLbAQAvD_BwE ) (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: https://gist.github.com/StewEsho/68871eb0a2c541ee2b07
(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.

3 Likes

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: https://frc-pdr.readthedocs.io/en/latest/control/pid_control.html

For actually programming them, the Phoenix documentation goes through everything you need to get it working: https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html

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.