Problem with driving multiple servos using an MCU - Page 1
Forum section: electronics / projects

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: October 03, 2018, 10:03:57 pm
content: Hello i have been working on a 5DOF robotic arm project and i have a problem driving all the servos.The arm consists of 6 MG996R servos and a generic Nema 17 stepper motor.Problem : When i power the thing up some servos twitch or not work altogether even though the signals from the controller are fine. I think it is a power supply and not a signal issue but i feel lost in how i should proceed troubleshooting it.Connections :Laptop Power Supply : 18.5 V ,3.5 A which connects to 5 V buck converter capable of 5 A , variable buck boost converter which outputs 6.2 volts for the servos capable of 100W and another buck converter that provides 12 V for the stepper driver.Logic :On the logic side the 5 V converter powers the arduino and the controller, the controller connects via 4 pins (Vcc , SCL , SDA , GND) and its component communicate via I2CThe controller components are : ADS1115 ADC which reads 2 joysticks , MCP23017 IO Expander which connects with some buttons as well as the joystick buttons and rotary encoder and at last an 16X2 LCD with a I2C driver for it.The arduino has an adafruit PWM servo driver clone which gets connected via I2C to the MCU and the servo power is provided by the 6.2 V 100 W capable converter and a DRV8825 stepper driver which drives the stepper motor.Note 1 : I use the 5 V converter for the logic with some caps to keep the ADC readings and the Joystick voltages stable.Note 2 : The controller and the stepper are working fine i just wanted to give the full picture to troubleshoot my problemNote 3 : I know that chaining up all these converters is not ideal and the wrong way of doing it but i am asking here to get a better solution.Thank you in advance everyone.

author: Dubbie
author_rank: Unknown
timestamp: October 03, 2018, 10:11:18 pm
content: Do you have an oscilloscope?

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: October 03, 2018, 11:01:44 pm
content: I have a DSO cheap one that comes as a kit and picks up the mains frequency from the power supply but I will give it a try

author: Mechatrommer
author_rank: Super Contributor
timestamp: October 04, 2018, 12:19:24 am
content: Quote from: ChrisGreece52 on October 03, 2018, 10:03:57 pmmotor can easily suck few 10's of amp during startup, if say 10-20A transient is for each motor, 1 motor requires 120W to startup, you power supply is just 60W, you have 7 motors there (servo has higher load due to gearing and friction)... if all try to start at the same time, PSU can easily be choked. you'll need beefier PSU... the most comfortable is 2X transient my uneducated guess, 2 x 120 x 7 = 1.68KW PSU. maybe you can get by with 450 - 600W PSU with some hope.

author: Dubbie
author_rank: Unknown
timestamp: October 04, 2018, 12:24:49 am
content: I'd check first that the servos have power. then secondly check that they are getting the expected control signals.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: October 04, 2018, 08:54:04 am
content: The servos are connected on to the PWM servo controller which provides them with the power. The problem i not at startup but during operation the startup process is fine.https://www.adafruit.com/product/815

author: rstofer
author_rank: Super Contributor
timestamp: October 04, 2018, 03:24:42 pm
content: Random thoughts:Power for servos comes from a different source than power for the Arduino. If not, power supply design will get complicatedGround for both supplies tied together - this is really important but it may be handled on the driver boardEven without a scope, you can measure the servo voltage and the Arduino voltage. You might be able to measure the noise by using a low range ACVUse a different example for driving the servos. Something that simply ramps them back and forth. Get rid of the analog stuff for a while.Make sure your analog ground ties in close to the Arduino and not over on the servo boardTry to measure noise on the analog supply if it is separate from the Arduino supply

author: IDEngineer
author_rank: Super Contributor
timestamp: October 04, 2018, 03:45:45 pm
content: I second the power supply as the primary culprit. You need to examine the power rail(s) when the servos are told to move, which is why someone asked if you have a scope. I suspect it will be very enlightening. Most people don't give enough thought to power supply issues, particularly when big loads (like motors) are being switched. I've seen entire (or, worse, parts of) logic systems reset themselves when the supply glitches below their threshold(s). Such problems cannot be evaluated with a meter, you need a scope to see sub-microsecond events.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: October 04, 2018, 04:57:55 pm
content: The servos were driven from the PWM driver. Every converter is sharing the same GND connection. I figured out my using my oscilloscope that the problem was the PWM driver. It does not output anything when told to move a motor. I am now trying to replace it by connecting all the pwm pins of the servos to digital pins directly and use I2C on the controller only.Also to simplify this thing a bit i will try powering the arduino and the servos from the same 5v converter (hope 5 A would be enough current capability) and the stepper from the other converter. As for the ADC readings i hope they stay stable.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 04, 2018, 06:29:41 pm
content: Just a side note regarding "robotic arms" driven by servos.Be very careful when powering your system on. Since servos are position-controlled, unless you can guarantee that they will each get exactly the same pulse width at power-on that they did at their last position when powered off, they WILL move. They may move so much as to make your robotic arm dangerous. So be very careful and never get anything too close to it when powering it on.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: October 04, 2018, 07:16:18 pm
content: Believe me i had to deal with this a few times...

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: October 04, 2018, 08:29:00 pm
content: Also when i tried driving the servos directly from the arduino it was acting weird after hooking up the logic analyzer i saw a lot of bouncing between the pulses.... why is that?

author: rstofer
author_rank: Super Contributor
timestamp: October 04, 2018, 11:18:09 pm
content: Quote from: ChrisGreece52 on October 04, 2018, 08:29:00 pmUse serial IO to output the analog values. Or get the analog out of the loop and use a simple up/down in a 'for' loop counter like some of the Examples.Serial IO is your best friend

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: October 05, 2018, 11:13:59 am
content: I did not get what should i do. I also think i messed up with the power supply so i am going to use a single 20W converter to get 5 v for the digital electronics as well as the controller , a 200 w capable converter for the servos at 6,2 V and last a 20 W converter at 12 V for the stepper motor.I have currently disconnected the stepper motor and the controller to focus solving the issue with the servos.The servos are driven by the digital pins of an arduino mega but i get a hum (at least with the 5V 5A converter which i use now) even when a single servo is connected and i try to drive it.

author: ChrisGreece52
author_rank: Frequent Contributor
timestamp: October 05, 2018, 03:01:06 pm
content: After a few tests and many problems i sorted the power supply issue and i am now able to smoothly move the servos ... after some good coding it is going to be done.a big THANK YOU to everyone that helped.

author: IDEngineer
author_rank: Super Contributor
timestamp: October 05, 2018, 04:41:59 pm
content: Sounds like this turned out to be a good learning experience. That's what happens when this forum is working the way it should... people help one another by sharing their knowledge and experience and everyone gets smarter. Congrats on threading that needle, and keep us posted!