Set Velocity command makes motor spin only forward

When I try to speed up a motor that is coded through the remote like this, it causes the motor to only spin one direction. Anyone know what is happening?

1 Like

I don’t know why but just put it like this

I think that the predefined functions only change velocity to ±100% depending on the button. They then just spin it forward. Therefore, always setting velocity to +100% will always cause forward movement. That line is unnecessary I think.

2 Likes

When I code the motor manually though, the velocity line does just what it should. changes the velocity forward or backward to whatever it is set to. I know that I could just code it like this instead, but I just want to know if there is a reason that it works this way, and not when put onto the controller through the motor interface.

image

Because it’s what your code is telling it to do

when start
loop forever
run 100%

so even if you adjust the speed somewhere else with code… this forever loop will keep resetting back to 100% speed

image

1 Like

We don’t know exactly what/how the predefined buttons work. That makes this process a lot harder.

It’s very easy in blocks to write code for motor control, and you’ve got some already. So unless you’re just doing research… just write your own control code.

If you really want to look further… I would add some lines that display motor speed/stats to the brain… maybe you can figure out what’s going on in the background.

We can look at Vex Code Pro V5 to know that the loop is like

if (Button1.pressing()){ Drivetrain.setVelocity(100,percent);} else if (Button2.pressing()){ Drivetrain.setVelocity(-100,percent);} if(Button1 OR Button2.pressing(){Drivetrain.spin(forward;}
Hopefully you understand my pseudocode. Im in sch, so I can’t access blocks to show you in blocks.