Arduino and Servos - Same external power supply

Hello everybody! I hope that somebody may help me with an issue that I’ve been facing for more than two weeks with my ArduinoMega2560.

I’ve created a structure that, using some photoresistors, chases the sun according to the signals sent by them. To make things simpler, I’ve tried a sweep function, without any photoresistor, for both the servos.

My intention is to supply both Arduino and the servos (mg995) with my solar panels only. Since the solar panels don’t provide a stable voltage/current, I’ve bought a proper buck converter that works fine, scaling the input panels - 20V - to a 6.8V output, used to supply Arduino and the servos. The converter supplies up to 2.5 (more or less) short-circuit current, so since the servos don’t need much current they should be properly supplied (see later regarding their consumption).

I’ve tried to connect the same, common supply to Arduino and to the two mg995 servos, whose max supplies are 6,6 Vs, but 6.8V also works well, and the servos load-free currents are 0.17A, while when inserted into the structure, they use 0.35 A each one because of small friction.

Here is the problem: they don’t work properly. I’ve connected in parallel this supply to both Arduino and the servos. I’ve also connected the ground of Arduino to the ground of the Servos in order to give the same voltage reference. This doesn’t work. If, instead, I only leave one servo connected to only one pin it works fine. As soon as I connect, instead, the second servo the motors go crazy and do whatever they want, they block, they jitter or they follow random behaviours. The code is rather simple, it’s just a sweep (from 45 to 135 degrees for the two servos, one after the other one, using the Servo.h library).

If, instead, I connect the external power supply (same as before, with 7V) to the servo only, the Arduino via usb to my laptop and the grounds of Arduino and servos together it all works fine.

Do you have any ideas to fix the problem? Is it something related to the ground or, maybe, to the V that is not stable enough? I’ve tested everything wih my multitester and all (Vs and Is) seem to work fine. Is it something related to spurious signals/noise that the servos send to the Arduino board while using the same supply and that cause the pwm signals to not work properly? Is it something related, maybe, to the fact that I’m using two servos together? Is it something related to the code? I also think that some problems may arise from the fact that the cables that I’ve used to connected the motors to the breadbord are quite long, maybe the pwm signal doesn’t work properly.

I also know that if I incline the panels the current will drop, but in any case I’ve setted the vertical and the horizontal movents of the servos to a small range in order not to loose light.

Any help will be really appreciated. Let me know if any other clarification is needed. Thanks in advance to everyone.

Thank you so much in advance! Here is the code and a scheme of the circuit.

Code:







```
#include <Servo.h>

Servo myservo;
Servo myservo1;
int pos = 90; 
int pos1 = 90;// variable to store the servo position

void setupcolor=#000000[/color] {
  myservo.attachcolor=#000000[/color];
  myservo1.attachcolor=#000000[/color];
}

void loopcolor=#000000[/color] {
  for (pos = 45; pos <= 135; pos += 1) {
      myservo.writecolor=#000000[/color];             
    delaycolor=#000000[/color];                     
  }
  for (pos = 135; pos >= 45; pos -= 1) {
    myservo.writecolor=#000000[/color];             
    delaycolor=#000000[/color];                     
  }
for (pos1 = 45; pos1 <= 135; pos1 += 1) {
      myservo1.writecolor=#000000[/color];             
    delaycolor=#000000[/color];                     
  }
for (pos1 = 135; pos1 >= 45; pos1 -= 1) {
    myservo1.writecolor=#000000[/color];           
    delaycolor=#000000[/color];                     
  }
}
```

|

It's almost always power with servo problems. It sounds like it here. Google found me a stall current for those servos of 1200mA each. The current measurements you're seeing sound way off. Perhaps they really reflect all your panels can manage to provide, which would explain why trying to run two of them is so freaky.

Thank you for your reply!
Yes, this sounds a good idea, but I don’t think this is the problem. Let me explain.

  1. When I tried to connect Arduino to the laptop USB, providing 5V and, at most, 500mA, I put a digital tester between the USB and Arduino that was supplying a single servo (5V pin, ground pin and a pwm), drawing a 240 mA peak current in total while the servo was sweeping. Now, the servo has, as far as I know, a stall current of 1.2A (as you also said), but I know that that current is only provided at maximum work, not with no load as in that experiment. Therefore, Arduino and the servo were only drawing a small current. Moreover,the panels can provide p to 2.5A, that should be enough to move the 2 servos at the same time even at stall, I think. And the code also contains separate movements for both the servos: one moves and other one moves after the first one, so they should not draw double currents (e.g. 300mA per servo, thus drawing 300 mA because they don’t move at the same time)

  2. Other thing: I also noticed that when connecting the pins of the servo directly to Arduino the servo was working, but when I connected the 5V pin, ground pin to an external breadboard, connected the breadboard to the servo and the pwm cable of the servo to Arduino it stopped working. Is it maybe something related to the breadboard or to some disturbs in the pwm signals in the moment I’ve used the external breadboard?

  3. Today I’ve also tried to supply both Arduino and only one servo with the solar panels, using a combination of 9 cables to create longer wires: 3 for 6,.8 supply V, 3 for the ground, 3 for the pwm. The single servo was working. The moment I’ve detached a cable, obtaining 2-2-2 cables for supply and pwm it suddenly stopped working. I thought it was something related to the length of the cables (longer cable = more resistance = more problems), but I can’t explain what happened. It seems all casual.
    Off topic: was my drawing quite clear? I didn’t know what to use to make decent drawings.

  4. Regarding the electrical connections I use the solar panels, connected to a buck converter that provide a 6,8V output. Is it safe to use the breadboard to create a common supply line for both Arduino and the servos (also using the same, common ground?) I’Vve soldered a jack input to some cables that take the 6.8V from the breadboard and I use this jack attached to the jack receiver of Arduino. In parallel, using the breadboard, I’ve also connected the servos. Is it a good thing?

  5. These are the servos that I’m using.
    https://www.towerpro.com.tw/product/mg995/

Thank you in advance :slight_smile:

Your wiring description is confusing. Draw a paper and pencil diagram, scan or photograph and post.
Post image

Ok, I’ve taken some pictures regarding the electrical connections. I’ve also modified them today.

1st picture: 4 solar panels (21v open circuit, 250 mA short-circuit) connected in parallel to create a 20W supply.

2nd picture: the cables of the solar panels all meet into the plastic mammuts, creating the same potential…

3rd picture: connections to create 2 parallel supplies, one for ever step-down voltage converters

4th picture: the 2 converters, having 21V in inputs, are supplied in parallel to create, for Arduino, 9V, and 6V for the servos supplies. I’ve connected, using 2 other mammuts, the servos in parallel to the same voltage converter. The pwm cables of the servos go towards the 9th and the 5th digital pins of Arduino, each of them giving a pwm signal. The grounds of Arduino and of the servos are connected via the black wire coming from Arduino.

The servos seemed to be working in the sweeping mode for a while, then I changed the program giving a smaller delay for the sweeps (40 ms) and the servos started jittering too.

I’m quite desperate, I’m loosing my mind.

Any help/suggestion will be appreciated.

Hi everyone,

I’m new in this forum and I’d like to hear some opinions regarding two servos that I’ve bought. Their brand is TowerPro and their model is mg995. I’d like to use these motors for a dual-axis solar panel tracker, but they seem not to be working very well: sometimes they seem working, sometimes no. (See my previous post for some specifics if interested).

Also, I’ve read some bad reviews about these servos. Which brand would you suggest to buy? I’d like to buy similar servos, but maybe from a better constructor. Would you suggest a robotic servo?

I’d also like to use two servos (using an external power supply, given from my panels and a step-down converter) in together. Would you suggest to me to buy a motor shield, such as the pca 9685 to drive them instead of using the arduino pwm?

Thank you everyone in advance.

gabb95:
I'm new in this forum and I'd like to hear some opinions regarding two servos that I've bought. Their brand is TowerPro and their model is mg995. I'd like to use these motors for a dual-axis solar panel tracker, but they seem not to be working very well: sometimes they seem working, sometimes no. (See my previous post for some specifics if interested).

If you want someone to view another Post then please provide a link to it.

If you already have a Thread about your servos then one wonders why you have started a new one?

"seem not to be working very well" does not provide any useful information from which to help you. You need to describe the symptoms in detail.

My wild guess is that you don't have a suitable power supply for the servos.

...R

If you want someone to view another Post then please provide a link to it.

If you already have a Thread about your servos then one wonders why you have started a new one?

"seem not to be working very well" does not provide any useful information from which to help you. You need to describe the symptoms in detail.

My wild guess is that you don't have a suitable power supply for the servos.

...R

Hi Robin,
thanks for your suggestions. I'm still a noob here, but I want to learn as much as I can, please forgive these errors.

this is the link to my previous post. I've started a new topic because this was specifically related to new, possible servos, while in the other one I've just talked about my esperiments to make them work, I'd just like here a suggestion for a new brand, since I've read some bad reviews. I've heard that Futaba\Feetech are good brands for servos, do you agree?

If you are still interested, I've explained some of the problems regarding the connections and the supply as well, I think (but still not sure) that the power supply related to the servos is quite good enough. Let me know if I've been quite clear, thank you!

gabb95:
If you are still interested, I’ve explained some of the problems regarding the connections and the supply as well,

Where?

If (as I suspect) it is in your other Thread then I suggest you click Report to Moderator and ask to have the two Threads merged so we have all the info in one place.

I’m too lazy to shuttle between Threads to pick up information.

I noticed that your other Thread has several image attachments. Please display your image(s) in your post so we can see it(them) without downloading it(them). See this Simple Image Posting Guide

…R

Where?

If (as I suspect) it is in your other Thread then I suggest you click Report to Moderator and ask to have the two Threads merged so we have all the info in one place.

I’m too lazy to shuttle between Threads to pick up information.

I noticed that your other Thread has several image attachments. Please display your image(s) in your post so we can see it(them) without downloading it(them). See this Simple Image Posting Guide

…R

Robin, thank you somuch!

You are right, it’s easier to see an already visualized image on an externl host with respect to an image to be downloaded… I’ve just reported to the mod as you have suggested. Hope that you will follow now the whole thread :slight_smile: Thank you for the suggestions up to now! :slight_smile:

Gab.

I’ve just uploaded the images on this external site, such that a download is not needed anymore. Thanks for everyone in advance!

http://imgur.com/gallery/o12OkP4

I've merged the threads as requested.

Regards,
Per

I’ve merged the threads as requested.

Regards,
Per

Thank you very much, Per! Sorry for everyone if I have made things confused with the two posts, but any suggestion, as you can see, is precious!

gabb95:
I've just uploaded the images on this external site,

Please just make them visible here - I gave you a link to the instructions.

Help us to help you.

...R

Oh, I think it didn't work because I've done what you told me...I'll check it again.

Edited: it didn't work because I had directly posted the link from the album, not the link of every image
The first image is not working, but they were only the panels alone




Are the images in Reply #14 the same ones that you uploaded to Reply #4? If so I'm not sure why you didn't just link to them.

At this stage I have lost track of what the problem is and what the images are intended to display.

Also. you never responded to the request in Reply #3 for a simple drawing showing how things are connected. That will be a lot more informative than pictures of the hardware.

Have you tried powering the servos from a pack of 4 x AA alkaline cells (6v) with the battery GND connected to the Arduino GND? That is a simple way to see if the problem is inadequate servo power.

...R

Are the images in Reply #14 the same ones that you uploaded to Reply #4? If so I'm not sure why you didn't just link to them.

At this stage I have lost track of what the problem is and what the images are intended to display.

Also. you never responded to the request in Reply #3 for a simple drawing showing how things are connected. That will be a lot more informative than pictures of the hardware.

Have you tried powering the servos from a pack of 4 x AA alkaline cells (6v) with the battery GND connected to the Arduino GND? That is a simple way to see if the problem is inadequate servo power.

...R

Hi Robin.

  • Yes, they are the same, but I've uploaded them on the external website after having used them as attachment. I've posted them here to make the readers to avoid opening new links. In any case, I've put the scheme (as an attachment) in the first post of this thread, I'll now modify the post in order to show the image directly in the site. if you want look at that scheme in the meanwhile, but now, as I'm going to explain underneath, I've tried to change a little the scheme.

  • I still haven't tried to use the external power supply to check the servos. But the guy in the electronic store showed me that, using a particular instrument to check if thw servos are working, he made both the servos either sweep or move accordingly to a potentiometer, so they worked fine. Also, I still haven't checked the supply using the batteries because, as I'm going to explain in the next rows, maybe I've finally made the servos work properly, only using the solar panels.

  • Ok, the problem is this one. I'm trying to use the same power supply (4 solar panels put in parallel) as a power supply for both Arduino and the Servos and the servos seem not to be working, even without any load. According to the producer, the servos draw 170 mA while working with no load, and up to 1.2A at stall. Looking at the scheme, let me explain -step by step- how I've connected everyting. I've tried to modify part of the original scheme, so just refer to the one that I'm attaching now.

This is the circuit that I've tried today.

Supply: 3 equal panels in parallel (21 V open circuit, 250 mA short-circuit for each panel) for the servos. 1 solar panel (same as the other ones) for Arduino.

Converters: 21V to 7V for Arduino using the dedicated panel. Another 21V-to-6V for the 3 other panels to supply the servos. The servo converter draws up to 2.4 (more or less) Amps in short-circuit, meaning that the supply should be enough (I think) to move the servos, that (as said a little later) absorb a peak of 400 mA when moving in the structure.

Arduino: output of the dedicated converter connected to the jack of Arduino (I've soldered the output of the converter to some cables and I've soldered the cables to the jack entry of Arduino). I don't know why, but the servos worked well for a few minutes even if I didn't connect the gnd of Arduino with the gnd of the servos.

Servos: I've connected the output of the V converter of the servos to the inputs of the servos, and the pwm cables of the servos to the 9th and 10th digital pins of Arduino. Today, when the panels were under 12am sun, the servos seemed to be working fine (a small sweep in vertical and horizontal axes with respect to the position of the sun), absorbing something like 400 mA (tried with a tester in series) each one as peak current. The servos were also put in the structure, that moved smoothly.

These are the pins that I've soldered to the cables that 've bough and, close to them, the soldered cables and pins, covered by a thermo-shrinkable tube.

  • Problem: yesterday, with the previous scheme (see first post in the topic) the servos didn't like to work, they jittered or made random movements. Today, using separate panels for Arduino and the servos, they worked quite well for half an hour. Then I've disconnected everything (I was home but I couldn't occupy the entire balcony with the structure and the circuits) and I've repeated the experiment after a few hours, orientating the servos towards the sun, but then the servos refused to make any kind of movements.

  • Sketch: I've tried the same "sweep" program as in the 1st post of the thread, only reducing the degree ranges to make the solar panels stay more or less perpendicular to the sunlight.

  • I have many questions: why did the servos worked correctly for half an hour and then, after some hours, they didn't?

Is it possible that the problem is related to the wiring? Let me explain: I've tried to use the just-mentioned scheme with the Arduino kit cables (the dupont wires) and I've noticed that, even slightly touching the wires, the servos either stopped or restarded working. I'take some copper (and with a larger diameter) cables and I've soldered them to some thicker pins that I've used to connect everything and the servos worked for that half an hour. Then something suddenly seemed to change.

May it be that the servos disturb each other? May it be a good idea to put some diodes to prevent noise coming from the servos to the converter and that may disturb each other since they are in parallel?

(I'll verify tomorrow morning, when the sunlight is more powerful) when the servos stopped working today (after the experiment in which they worked correctly at 3pm) the sunlight was not so powerful, it was 7pm and, even if the panels were under direct sunlight, it wasn't the same, powerful sunlight that I've found earlier.

Would buying a motor shield be a good idea? I've heard that they are good for solving these kind of problems.

  • Did I express myself well now?

Gab

gabb95:

  • Did I express myself well now?

It's rather long, but at least it is all in one place.

A few comments.

You have a dotted GND connection in your wiring diagram - the GND connection is essential.

Without being there to watch you I can have no idea why it worked for 30 minutes but not later.

The servos won't disturb each other except the possibility that two of the working at the same time draw too much current. Projects with multiple servos are very common. As I said earlier, power them with batteries to see if that works - eliminate the simple things first.

Powering something directly from solar panels without a battery to store the solar energy is very dodgy. The quoted output from solar panels is only relevant in full midday sunshine in a clear sky with the solar panel perpendicular to the sun. Any variation from that can result in a huge drop in output and shadows or clouds can cause an instantaneous drop in output - solar panels have no energy storage.

...R

I’vejust read, I’ll try doing what you have suggested. Please look at the video in the link, these are the sweeping panels with the circuit that I’ve shown you before. It seems that the motors work but they jitter a lot, now the weather is cloudy.

Sweeping panels

I can’t see anything in your “Sweeping panels” link (apart from the housekeeping). Maybe a YouTube video would work better

However there seems little point in testing with solar panels UNTIL AFTER you have a reliable battery powered system.

…R