New Servo worked...and then it didn't - Please help!

125 views
Skip to first unread message

Hamza Qureshi

unread,
Oct 6, 2021, 11:28:49 AM10/6/21
to Crow Box Kit
Hi all, 

I purchased a new Servo as the last one was the wrong make. This time I got the 180 degrees one (the correct one): https://www.botnroll.com/pt/servos/2641-servo-towerpro-mg995-servo-180.html

During the boot up and entry into Stage 1, it rotated more times than I expected it to. However, it ended up parked open. So that kind of worked. 

Stage 2, clicking the perch switches did activate the food lid, however, like in the boot-up, it rotated more times than I expected it to. Also, it did not pause while open. Instead, it kept sliding back and forth halfway, and then eventually closed incrementally. So half correct. 

Stage 3, it worked! It worked perfectly. See here: https://www.youtube.com/watch?v=gDOyRloRX5A

After a short while, Stage 3 stopped working. I switched to Stage 4, and it didn't work properly either. See here: https://www.youtube.com/watch?v=J8ygK2GyM68

After another short while, Stage 4 started doing something very strange. It entered a loop:  https://www.youtube.com/watch?v=gkFu2a1PpWw

During this loop, I could not change stages or do anything else. So I unplugged the Arduino and wanted to reset the EEPROM. I uploaded a simple sketch:

#include <EEPROM.h>
void setup() {
  // put your setup code here, to run once:
  // initialize the LED pin as an output.
   pinMode(13, OUTPUT);

   for (int i = 0 ; i < EEPROM.length() ; i++) {
      EEPROM.write(i, 0);
   }

   // turn the LED on when we're done
   digitalWrite(13, HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
}

And reuploaded the cros OS. Starting from Stage 1 again, everything still occurred like it did before (incorrectly, that is). 

So I thought that perhaps I have received another faulty servo. I decided to run a test software on the Servo this time. I wanted the Servo to spin 180 degrees one way, and back again. I wanted this to be repeated in a loop. Here is the simple sketch I uploaded to the Arduino: 


#include <Servo.h> // include servo library to use its related functions
#define Servo_PWM 9 // A descriptive name for D6 pin of Arduino to provide PWM signal
Servo MG995_Servo;  // Define an instance of of Servo with the name of "MG995_Servo"

void setup() {
  Serial.begin(9600); // Initialize UART with 9600 Baud rate
  MG995_Servo.attach(Servo_PWM);  // Connect D6 of Arduino with PWM signal pin of servo motor
}

void loop() {
  Serial.println("0");// You can display on the serial the signal value
  MG995_Servo.write(0); //Turn clockwise at high speed
  delay(3000);
  MG995_Servo.detach();//Stop. You can use deatch function or use write(x), as x is the middle of 0-180 which is 90, but some lack of precision may change this value
  delay(2000);
  MG995_Servo.attach(Servo_PWM);//Always use attach function after detach to re-connect your servo with the board
  Serial.println("0");//Turn left high speed
  MG995_Servo.write(180);
  delay(3000);
  MG995_Servo.detach();//Stop
  delay(2000);
  MG995_Servo.attach(Servo_PWM);
}

And it worked. Perfectly. Check it out here: https://www.youtube.com/watch?v=Y0tDVEZWXxo

I left it running for a while, and it did not falter. So now I am really confused. This does not seem to be a servo issue. It does not appear to be a power issue either (this is the unit I am using:  https://www.botnroll.com/pt/alimentadores-acdc-5v/878-alimentador-5v-dc-2a-.html ). 

Is there an issue with the code? Perhaps it is the Arduino? Although the Ardunio is working with everything else. I am using the original Arduino Uno R3. 

Please if anyone could help me, I would really appreciate it! I would like some input from the Crowbox team before I purchase a really expensive servo. 

Thanks :) 

Hamza Qureshi

unread,
Oct 6, 2021, 11:33:00 AM10/6/21
to Crow Box Kit
Just to add, everything else works fine. The servo responds to the coin sensor, and it also responds to both of the perch switches. The issue here is that it is responding incorrectly. 

Josh Klein

unread,
Oct 7, 2021, 10:22:59 AM10/7/21
to CrowB...@googlegroups.com
Hamza,

I saw your latest post - does that obviate the notes in this one? I.e., did the 180 server solve your problem?

- J

--
You received this message because you are subscribed to the Google Groups "Crow Box Kit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to CrowBoxKit+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/CrowBoxKit/90a63a18-9c8e-40f4-99ed-f754c1ddbf9fn%40googlegroups.com.

Hamza Qureshi

unread,
Oct 11, 2021, 4:52:10 AM10/11/21
to Crow Box Kit
Hi Josh! 

So the 180 degree servo definitely did solve one of the major issues (which was that the 360 degree servo would not stop spinning, for obvious reasons as that is what it was designed to do). So I then purchased the 180 degree servo and my post above shows how it worked at the beginning, but then fails to work afterwards. It appears to be running into similar issues as Leigh Anne's servo. 

However, I have noted that the servo I ordered was not the servo I received. It appears the company have sent me a much cheaper servo brand than the one I ordered (I ordered the TowerPro which goes for around $11, and received a WAVGAT issue, which goes for around $4). I am going to try ordering another servo from a different company. I'll test that and will be able to let you know how it goes! 

I would also just like to confirm, is the code working for everyone else with good quality servos? As per my original post in this thread, when I ran a test code for the cheap servo, it still worked. So could it possibly be a bug in the code that is causing the servos to enter a weird loop? If not, then it must just be the poor quality servos on the market. 

Josh Klein

unread,
Oct 11, 2021, 7:16:58 AM10/11/21
to CrowB...@googlegroups.com
Hey everyone - please do weigh in if you're having success with your servo, and if so the brand/model you bought. We've heard from a couple folks that are having similar issues and as far as we can tell it's servo related, but it would be helpful to hear if anyone else is getting the same problem!

- J




Hamza Qureshi

unread,
Oct 11, 2021, 2:06:46 PM10/11/21
to Crow Box Kit
Hi! 

I think it might be a power supply issue rather than a Servo issue. I tested simple code on the servo while the Arduino was plugged into my laptop via USB and the Servo was connected to the 5V2A power supply (e.g. making it spin to certain degrees and back again after some time). It worked as expected. I then unplugged the Arduino from the USB cable (so now, the Arduino and the Servo were drawing power from the 5V2A power supply) and it displayed erratic behaviour (e.g. spinning uncontrollably, not delaying for the specified time etc). 

I tested this again, this time with the Crowbox OS. First, I tested it where the Arduino was unplugged and connected to the 5V2A power supply (via the breadboard, as per the specifications on the Crowbox website). The behaviour remained erratic (as in the videos I uploaded above). I then plugged the Arduino into my laptop via USB. It worked! The Crowbox functioned as expected. Every stage performed well after several tests. 

I contacted the shop where I purchased the Servos from and they confirmed that all their servos should be working well. They suggested I use a 6-7 volt power supply. I have done a bit of research online and I noted that people have been suggesting to use a power supply that offers more current as well. 

What are your thoughts on this? I will be purchasing a stronger power supply. Is it possible that different Arduinos draw more or less power? I am using the standard Arduino Uno R3, purchased from one of their designated distributors (so it is not a clone). 

Rodion Mutsolgov

unread,
Oct 11, 2021, 2:50:01 PM10/11/21
to Crow Box Kit
Hi!
Please give me a connection diagram of all components (photo). I think it's a problem with connection. 

понедельник, 11 октября 2021 г. в 21:06:46 UTC+3, qureshi...@gmail.com:

Rodion Mutsolgov

unread,
Oct 12, 2021, 9:13:57 AM10/12/21
to Crow Box Kit

If you are powering your servo and your Arduino from different power supplies, you must make a common ground. You should run a wire from the arduino's GND pin to the ground of the power supply from which the servo operates.
понедельник, 11 октября 2021 г. в 21:50:01 UTC+3, Rodion Mutsolgov:

Leigh Anne

unread,
Oct 12, 2021, 10:37:57 AM10/12/21
to Crow Box Kit
Hi Hamza

I think you're onto something!  Here are the tests I mentioned I did based on your posts:

1. Connected the Arduino into the laptop via USB only; not connected to the 5V2A power supply - it worked, but I had only tested it twice (this was a previous test a few weeks ago)
2. Connected the Arduino into the laptop via USB only; not connected to the 5V2A power supply - it failed, this time I tested it more than twice and it failed on the third try and continued to fail 
3. Connected the Arduino into the laptop via USB AND connected the servo to the 5V2A power supply - it worked!  I ran the test over 15 times on different phases

If you purchase a new supply and it works without needing to connect the Arduino to the laptop please post which power supply you got.

Thank you again,
Leigh Anne

Hamza Qureshi

unread,
Oct 12, 2021, 11:39:37 AM10/12/21
to Crow Box Kit
Hi Rodion, 

Here is a picture of my Crowbox wiring. I have checked and it does follow the wiring guide provided by the Crowbox team: http://www.thecrowbox.com/wiki/lib/exe/fetch.php?media=kit:crowbox_wiring_chart.pdf

Thank you for offering to check out the wiring! 

CrowBox wiring.PNG

Josh Klein

unread,
Oct 13, 2021, 5:17:32 AM10/13/21
to CrowB...@googlegroups.com
Just a word of thanks to everyone for pitching in on the debugging!! If it is in fact the power supply that is causing all the problems that’d be a huge help to learn.

- J


Rodion Mutsolgov

unread,
Oct 13, 2021, 2:43:24 PM10/13/21
to Crow Box Kit
I think, yes. It can be a problem with the power supply, but it's very strange. I have a power bank 5V 2A, it works fine,  but I have a different connection scheme so that it does not cut off the power due to low consumption. if you are interested, I can send it.

среда, 13 октября 2021 г. в 12:17:32 UTC+3, Josh Klein:

Josh Klein

unread,
Oct 14, 2021, 5:25:05 AM10/14/21
to CrowB...@googlegroups.com
Rodion, if you could send it for reference if nothing else that would be very helpful!

- J

Rodion Mutsolgov

unread,
Oct 14, 2021, 12:58:04 PM10/14/21
to Crow Box Kit
https://www.instructables.com/Current-Pulsing-Keeps-Power-Bank-Active/ I use this connection scheme. It generates a pulse (it can be regulated using resistors and capacitors). It is a connection scheme of my crowbox. I think, Josh, you can add  this, in your website. It is a very good scheme. With this you can use any power banks606c861c-7f11-4086-b143-49340fdf5f98.jfif
четверг, 14 октября 2021 г. в 12:25:05 UTC+3, Josh Klein:

Josh Klein

unread,
Oct 18, 2021, 4:00:48 AM10/18/21
to CrowB...@googlegroups.com
Hamza, did you have any luck with the power supply?


Hamza Qureshi

unread,
Oct 18, 2021, 5:12:37 AM10/18/21
to Crow Box Kit
Hi Josh, 

No luck just yet. I was actually in the process of switching the Arduino out for the NodeMCU ESP32. I've just finished doing that and ran a few tests but am coming across the same issues. So far everything works just fine when the Arduino/NodeMCU is plugged into a different power supply e.g. my laptop. I've also done a bit of reading and asking around on forums, a lot of people seem to think that powering the Arduino and the Servo from the same power supply is bound to run you into trouble. I'm wondering if you have ever experienced anything going wrong after a while? Apparently, the Arduino may shut down/restart due to the noise produced by the Servo on the power line. This might also have to do with the cheap influx of Servos you mentioned previously. Most suggest powering the two from separate sources whilst maintaining the same GND connection. However, I imagine two power sources would make things quite clunky and is not feasible. 

Josh Klein

unread,
Oct 19, 2021, 7:12:25 AM10/19/21
to CrowB...@googlegroups.com
This is useful detective work, thanks! I haven't seen anything like it with the servos we've used, but as noted there's been a big influx of much lower-quality ones in the last year or two that could be contributing to the problem. I think you're right about the two power sources; can you confirm that the problem is "noise" created by the servo?

- J

Reply all
Reply to author
Forward
0 new messages