Newby question on programming and robot whine

I’m very new to Vex and RobotC. While searching for an answer to a problem I was facing I came across a description that talked about motors whining because code was being cycled through every few miliseconds, causing motors to turn on and off rapidly. The post mentioned ‘new RobotC version’ or ‘newer motors’, or something along the lines of a ‘new version’ of something and the person posting their code for review had referenced the buttons in the ‘old way’.

So, while I understand this is very vague and imprecise, I’m still looking for any basic pointers on laying out RobotC code properly since some of our motors do whine, and sometime the robot wants to move a bit even thought the joysticks are in the center position. Maybe these two phenomena are unrelated, I’m not sure.

Any suggestions on where to start to get the basics of laying out the RobotC code correctly or ‘trimming motors’ which I saw in another post related to motor whining?

There are two issues that I think you are mixing when searching through old threads.

  1. Deadband.
    The motors can whine if they are being sent very small control values that cause current to flow but not actually move the motor. This happens often when the analog joystick control (Ch1 through Ch4) does not quite return to the zero position when you leave go. To mitigate this situation we often program in what we call a deadband, a small area near zero where we do not use the joystick values but instead just send 0 (ie. stop)

ROBOTC code controlling a motor without a deadband may look like this.

motor port2 ] = vexRT Ch1 ];

adding a deadband it would be like this.

if( abs( vexRT Ch1 ] )  > 10 )
    motor port2 ] = vexRT Ch1 ];
else
    motor port2 ] = 0;

if the absolute value of the joystick is greater than 10 then use it else send 0.

  1. Motors jittering
    This happens when you send different control values to the motor very quickly. This can happen if, for example, you are trying to control a motor with both a button and an analog joystick. A common error is to forget to use “else” statements as part of the control logic.