BEST Robotics, twitchy servos

user tcrenshaw4bama posted a programming question to easyC tech support.
I’m reposting here to Commuity answers:

Both code sections look reasonable, but they are not the whole code for your robot.
The usual issue with twitching servos and unresponsive motors is multiple assignments in the same loop. Early in the loop, the joystick command tells the servo to go to position 0, late in the loop, you set it to set it to some other position.

example BAD

  arcade2(   control motor port  1,10);
  joystick2motor(  control motor port 3);
  # user code to also set motor port 3 as servo, based on P2,P1,P0
} # end while

This is typical when adding user created code for a motor port to the BEST default code, without commenting out the prevous BEST default code for that motor port.

Some tests for this hypothesis:

  • comment out your code, move the joysticks to see if your servo moves.
  • comment out the BEST default code, see if your code works without twitch.

The correct way to do it would be

  arcade2(   control motor port  1,10);
  char Switch = GetDigitalInput(1);
  if ( Switch == 1 ) {
   } else {
     joystick2motor(  control motor port 3);
} # end while

kingofl337, I believe you have misunderstood the BEST Robotics application request, and so have presented the wrong solution as correct. While your solution will prevent the servo from twitching, but it will not implement the required 3 digital input to 8 servo position decoder, as the common implementation of the dataport reader display used for the BEST2010 game “Total Recall”.

I am a big fan of programming, however, I have run it to this problem and tried to program my way out of it. I ramped the servo to try to slow down the speed at which it moved. Unfortunently this solution did not work because the servo did not move as instructed, rather it waited until a sufficient position error was present then jerked into motion traveled new position then waited there for the next significant error before responding again.:frowning:

The solution that actually worked was mechanical. I decoupled the servo arm from the attached item. Then inserted a piece of rubber that was attached to both items. This provided a mechanical ‘low pass filter’. That gave the servo the opportunity to transmit the motion, but damp of the vibration when it occured.:smiley:

I answered this users request, “Make the servo’s stop twitching” In this thread.

There are other threads in the easyC forum asked by BEST teams that probably could be used to help answer the challenge that has been presented to the BEST teams.

Here is an example: