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];
}
}
```
|





