Servos stop working randomly - Robotic Dog Build

Hey guys
Ive got a bit of a problem here. Im trying to build a robotic dog and my servos sometimes just go limp sometimes. Also its not an power issue its the Arduinos PPM-Signal that just stops for a short moment sometimes. Im using an Arduino MEGA. Coudl it have something to do withe the delay() function?
Help is greatly appreciated thanks.

The code is quite long so I attached it as an .ino file.

ZERBERUS_1.3.ino (15.1 KB)

Since your code uses the Servo library which is interrupt driven, there's no danger in using delay,
this is almost without doubt a problem with inadequate power supply, contrary to your assertion.

Your code uses 4 Servo objects, so 4 servos in the thing? What power supply? Which servos?

It has to be a problem with the PPM Signal because I probed the pins on the arduino with an oscilloscope and the signal really stopped. Also if this happens it starts the HOME void again so its like it cant signal the servos

You say that it is not a power problem but 90% of all servo problems are power problems.
Let's talk that thought first.
What is your power supply?
How is that power supply connected to the servos?
Which servos?
How heavy is the robot?
Can you provide a wiring diagram? Pencil, paper and a camera are good enough.
Oh, also send pics of the robot. Cool project!

AaronSilas:
It has to be a problem with the PPM Signal because I probed the pins on the arduino with an oscilloscope and the signal really stopped.

If you are powering the servos from the Arduino 5v pin that is probably because the Arduino was overloaded and reset itself - hence @MarkT's comment.

...R

Hey guy thanks for the replies
The robot is powered by two lab bench power supllies that are connected in parallel. They together provide 9V at about 6A. The servos are powered of some sort of switch mode power converter ive got from ebay. The servos have 15kg of torque each but I dont know the exact name anymore. They draw about 1.5 A each at max. I dont know how heavy the robot is but it is currently on a stand anyways so it shouldnt be an issue.
Pics are attached :slight_smile:
Also Ive probed one of the pins without a servo beeing attached and it still stopped sometimes.

You must never connect voltage supplies in parallel, this could fry them or your circuit.

Oh ok thanks for the warning why is that?

I can't figure out how your program is supposed to work. The only function that is called from loop() seems to be kneevl().

And it seems to be a very higgledy-piggledy way to write a program that (I presume) should be very responsive. There are long delay()s all over the place as well as blocking WHILE loops and (for example) analogRead()s and servo.write()s of the same thing in multiple places.

I suggest a complete re-write so that all the analogRead()s take place in one function. Another function does any calculations that are needed and another function to update the servo positions with the new data.

Have a look at Planning and Implementing a Program

And I do appreciate that none of the above may impact on the servo problem - but it might make it easier to find.

Putting a Serial.print("Arduino Starting"); into setup() would allow you to see if the Arduino is resetting for some reason.

...R

Thanks for the answer
Ok ill have a look at that site. The thing is im not a very talented programmer (as youve probably seen :sweat_smile: ) The knee... loops control servo units that consist of a dc motor and potentiometer so I cant think of another way to do it. Do you know what I mean ? And if so what would be your approach to that? Basically what those voids do is turn the motor then wait for the correct potentiometer value and the stop the motor.
And the reason there is only this one thing in the loop is because the programm isnt finished yet. I just wanted to test out if one leg would make a step

Ok if kinda solved the problem by working around it. I used another Arduino and paired them with I2C by that I can use the Slave Arduino to drive the servos and that works pretty good. So maybe it was a Hardware Issue? It could be because I used Arduino Clones and they maybe arent the best quality so...

But still if anybody has an idea what the problem was id be very much interested in hearing about that

AaronSilas:
I used another Arduino and paired them with I2C by that I can use the Slave Arduino to drive the servos and that works pretty good.

That's like hoping that mophine will cure a broken leg :slight_smile:

...R

AaronSilas:
Basically what those voids do is turn the motor then wait for the correct potentiometer value and the stop the motor.

AaronSilas, I have to admit that I am confused. Don't worry, That is a common state for me. :slight_smile:

My confusion is based on 2 different method you are using.
One
You use the servo library. This lets you use the library methods to talk to any device that supports the servo library interface. Hobby servos are one such device. Hobby ESCs (electronic speed controls) are another such device. Hobby servos have a motor to move things, a pot to detect position and electronics to drive the motor until the pot reads the desired position.

Two
Your quote above. You turn the motor and wait for a correct pot value and then stop the motor.

Are you managing that behavior with arduino code? If so, where does the servo library fit in?

Robin2:
That's like hoping that mophine will cure a broken leg :slight_smile:

...R

Yeah I know its not very elegant but it seems to work

vinceherman:
AaronSilas, I have to admit that I am confused. Don't worry, That is a common state for me. :slight_smile:

My confusion is based on 2 different method you are using.
One
You use the servo library. This lets you use the library methods to talk to any device that supports the servo library interface. Hobby servos are one such device. Hobby ESCs (electronic speed controls) are another such device. Hobby servos have a motor to move things, a pot to detect position and electronics to drive the motor until the pot reads the desired position.

Two
Your quote above. You turn the motor and wait for a correct pot value and then stop the motor.

Are you managing that behavior with arduino code? If so, where does the servo library fit in?

The robot uses a combination of servos and selfmade linear actuators so the servos are of course controlled by the servo library but the actuators are controlled by the kneevl / hipvr and so on voids in the program. If you look at the photo ive posted youll be able to see the linear actuators.

:slight_smile: I did look at the photo. Impressive!

I had not seen the hobby servos though so I was confused. With that cleared up, lets talk about other details of your project.

You have 8 of the actuators? So you have 8 pots to read, and then adjust the motors until the pot readings are where you want them?

Thanks man
Oh ok they are hidden in the black boxes at the top of the legs

vinceherman:
You have 8 of the actuators? So you have 8 pots to read, and then adjust the motors until the pot readings are where you want them?

Yes that is true
And my approach is indeed problematic it sometimes turns in the other direction its like the value is somehow substracted and not added to the target value.
Like I said im not a ver ggod programmer by any means so Id be very thankful for any tips how I could make that code more reliable.

AaronSilas:
Like I said im not a ver ggod programmer by any means so Id be very thankful for any tips how I could make that code more reliable.

See Reply #8

...R

I meant specifically the actuator stuff.

AaronSilas:
I meant specifically the actuator stuff.

I do understand that you would like to avoid a complete re-write. However my sense of things is that without a re-write it is difficult or impossible to identify the code that specifically relates to the actuators. At the moment the code for inputs and outputs is all mixed together.

...R