MotionMagic Not Going Backwards

motionmagic

#1

We are using a a MotionMagic control mode for our elevator this year. Everything appears to be working correctly, however I cannot run the Elevator down after it reaches a target position above where it was. How can I get it it to lower with the same control mode?

elevatorA.configMotionCruiseVelocity(9500); elevatorA.configMotionAcceleration(15000); elevatorA.set(ControlMode.MotionMagic, targetPosition); elevatorB.follow(elevatorA);

#2

When you try to go down, are you giving it a negative or positive cruise velocity? Probably should be negative, going down.


#3

What are the Talons LEDs blinking when it’s not moving the way you think?


#4

You should be able to just send it a new target position. For instance our elevator starts at target position 0 and to go up we specify a target position of 1000. To bring it back down we just specify a target position of 0. We don’t mess with the cruise velocity or acceleration after we initially set it.


#5

LEDs are neutral when I command it to lower


#6

Yeah I even tried negative Velocity and Acceleration but it didn’t change anything.


#7

Are you using any limit switches on your elevator that might be stuck in the on position?


#8

It was not mechanically hitting any switches but I will test it without the limit code in


#9

Blinking orange or solid orange?


#10

solid


#11

This is incorrect. Cruise velocity and acceleration should remain positive for all MM cases.
To OP: Got any source code? Have you tried tying the target position to a joystick axis and seeing if it works then?


#12

How do you setup the Talon?

In your code, do you configfactordefault before setting any of your PID values?

It also seems like your elevatorB.follow(elevatorA); should be before you set elevatorA but I’m not entirely sure about that.

It seems like you have some odd Talon config that keeps you from moving the other direction, like perhaps configNominalOutput is set to 0 or something and we’ve just overlooked it.


#13

Lots of things to check.

  1. Is your Talon “in phase” with your encoder. i.e. Green Talon lights = Encoder values go up, red lights - encoder values go down.
  2. You set the follower mode of a Talon way back when you open the master. It’s a one-time configuration at start-up.
  3. Acceleration and Cruise are also always positive and also a one-time configuration at start-up.
  4. Check all the configuration values of your Talon using Phoenix Tuner. Make sure you have no soft limits enabled that would be causing this. Make sure you have nothing set to limit maximum voltage in one direction or the other.

All I can think of that would trip up MM off the top of my head.


#14

If you are still stuck after trying all these things take screen shots of your talon config. Do a self-test while running MM and take screen shot. Post it the screen shots here. If your code is available on github add a link. The more info you provide the better people can help you figure out what is going on.


#15

Definitely post your code - it sounds like the set point is not what you think it is, or there are limits somewhere.


#16

Update

After a lot of testing and me getting distracted I learned that I had my limit switch code goofed up, and the MM control scheme works great on our practice frames. Thanks for the help. That being said in the future test it without any limiting code, and do no make your Velocity and Accel. negative.