Motors aren't recieving constant power

I’m using a button to control two motors that lift an arm. When I press the button to give the motors full power, the motors jolt and jitter instead of moving the arm at a constant rate. Does anyone have any ideas of what the problem could be?

I’m using robotC, here is the code I am using to control the arm. I’m using two 393 motors. Each motor is connected to a seperate port on the vex cortex.


 if (vexRT[Btn7U]== 1)
    	{
    		motor[elbow]=127;
    		motor[elbow2]=127;
    	}

  if (vexRT[Btn7D]== 1)
    	{
    		motor[elbow]= -127;
    		motor[elbow2]= -127;
    	}

Here is the quickest fix you could do: (all it is is making the second if statement into an else if statement)

 if (vexRT[Btn7U]== 1)
    	{
    		motor[elbow]=127;
    		motor[elbow2]=127;
    	}

 else if (vexRT[Btn7D]== 1)
    	{
    		motor[elbow]= -127;
    		motor[elbow2]= -127;
    	}

The reason that your motors are “Jittery” is because the value can be set twice in the code you are using (if both buttons are pressed, then it quickly sets both motors to values +127 and then -127)

I’m just guessing, but you’ll probably want the motors to not move when nothing is pressed. in order to make this happen, just add the following right after the above code:

 else
    	{
    		motor[elbow]= 0;
    		motor[elbow2]= 0;
    	}

A little while ago I was in the forums and found the following method of setting a motor value based upon two button inputs, and I have loved it ever since (it’s so concise!):

motor[elbow]= (vexRT[Btn7U] - vexRT[Btn7D]) * 127;
motor[elbow2]= (vexRT[Btn7U] - vexRT[Btn7D]) * 127;

Thanks, Steve! That helped alot and the motors function much better. However, the motors still aren’t completely smooth and have a little jitter to them. Do you think it is the motors or the program?

well, i complied that program to my spare cortex and tried it with my motors, it worked fine, only thing i can suggest is changing the motor controllers and changing ports of the motors and seeing if that effects it …

we had a similar problem ages ago with a motor, when we changed the motor controller, it worked fine

hope this helps

Since you only provided a program snipet, instead of attaching the entire code, my guess is that it is likely the code. The usual reason for jittery motors is setting them more than once per loop.

The Scientific method (make a guess and try to disprove it) is helpful.
Guess1: its the motors
Test1: make the simplest possible program to test just these motors and nothing else.

Guess2: its the program multiple set
Test2: Post the entire code, and/or search for all motor sets. There doesn’t need to be more than one motor command per motor in your entire program.