Here is our code, there are no errors. The robot shakes because the program is continually cycling through the if statements, if we go through step by step it will work. However our question is why is it executing the code in the if statements if no buttons are pressed?

I am not familiar with the workings of the servos (I don't own a controller), but I noticed that you have code for when a button is pressed, but no code for when no buttons are pressed. Do you not need to stop the servos when you are not pressing any buttons at all? Could this be the source of your problems?

Enhance your program to add counters to the code in the "IF" statements to count how many times the code is executed. Then examine the values of the counters with the debugger to see if they are expected.

Try changing the "servoChangeRate" to zero instead of five and see if that corrects the problem. It shouldn't, but just check anyway. If it does solve the problem, post away.

But what I suspect is happening is the following:

You're using the servos to control a lifting arm and bucket.

The servos aren't really strong enough for the task.

When you reach a position, the servo applies a light "load" to hold in place.

Gravity causes the arm to lower.

After enough movement the servo in the arm applies enough "load" to cause the servo to move back to the hold position.

You can "cure" this type of problem with using two servos in parallel to provide twice as much holding power.

Another alternative explanation is that load on the servos is so heavy that the internal thermal overload is periodically kicking in and disabling either the servos or the HiTechnic controller. When the overload detector cools off it resets and the servo starts working again.

If you connect an unloaded servo instead of the actual servos connected to your lifting arm do you still get the jerking? If it disappears with the unloaded servos then it would point towards one of the above causes.

Another possible explanation is that you have the servo controller on one sensor port and the motor (or other servo controllers) on another sensor port. Instead of all devices on one sensor port. This can apparently create "Ground Loops" -- i.e. an electrical problem; one of the symptoms of ground loops is spurious servo pulses sent by the Servo Controller.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum