Bricked Photon after driving a servo, need help to avoid a repeat

I recently decided start working with the Photon and IoT in general and came across this Instructable cat feeder project. I went ahead and bought the Maker Kit to get acquainted with Particle and various hardware components.

I was successful at the “Gong” example in driving a servo. However, the kit’s servo, is not up to the task of driving a cat feeder and decided to get the servo the Instructable recommended, an LS-8101F. Here is the spec sheet. When I got it, I hooked it up based on the Instructable. I utilized the following code, similar to the “Gong”, to drive the servo:

Servo myservo;
int servoPin = A5;  // variable to store servo pin

void setup()
{
    myservo.attach(servoPin);   // attach servo pin
    Particle.function("feed",triggerFeed);  // declare feed function
}

// feed function
// since feed can be invoked by 3 different methods (button, voice, schedule)
// we need to account for 3 different commands
int triggerFeed(String command)
{
    myservo.write(0);   //start turning the servo
    delay(330);     //how long the turn turns in ms (may need some adjusting)
    myservo.write(92);  //stop turning servo
}

So + was connected to VIN, - to ground, and control to A5. The Photon was powered by USB, connected to my 2012 MacBook. I was holding the servo in my hand and it did have a load.

Everything seemed to be in order, so I invoked the feed function and the servo started moving, quickly, but almost immediately the sound changed from sound sounding like it had a purpose, e.g., turning, only to sound like a voltage drop or the servo hit its hard stop, but the control line was still active. I then noticed that the Photon’s status light had gone dark and shortly after that, the Particle console told me that the service call had failed. The servo at this point was still active. I didn’t look close enough to see whether the servo was still turning or just making noise. I then removed the USB power and then plugged it back in, but now the Photon did not light nor did the servo react.

Afterward, I was able to test the VIN and 3V3 pins and found that the VIN still seemed to be fine, but the 3V3 pin was now dead. I submitted a ticket with Particle and they confirmed it was toast.

I did read in the comments for the Instructable that it sounds like someone else had a similar problem. Per my ticket with Particle, without a load, the Photon shouldn’t have had a problem driving this servo, though the spec sheet says it could draw up to 2.7 amps, well over what the particle can handle.

To avoid a repeat, I have purchased a 5V AC adapter that can provide 5 amps. If I use this and power both the Photon via VIN/GND and the servo in parallel, will I be OK to use this servo without future harm? Or do I need some electronics that will isolate the Photon from the servo.

Make sure you have the servo powered by VIN, or even better your external 5V power supply.

If you connect the power line (red) to a GPIO pin or 3V3 you’ll likely cause serious damage as the GPIO is limited to 25 mA and 3V3 on the Photon 100 mA.

Only the VIN has a higher power output.

With a servo, the motor should be powered by the red and black lines, and the orange line is the control line, which is low power. It’s a PWM signal, and the duration of the pulse is what determines the angular position of a standard (not continuous rotation) servo.

4 Likes

So the following image should be an acceptable way to power the Photon and Servo?

Yes, that is correct.

2 Likes

Out of habit I’d just add a 100nF and 47µF (or bigger) cap next to the Photons Vin/GND pins.

2 Likes

Thank you both for your input, I am including an updated picture to make sure I understand the addition of the capacitors.

Per another post, I saw something similar on the 3V3 pin. I opted for a schematic as it was getting cumbersome to try and represent this in the bread board view, but essentially, I understand the capacitors to straddle the power supply lines to the photon.

@ScruffR, can you comment or provide a link as to what adding these two capacitors accomplishes? I saw another post mentioning something about filtering, but didn’t get into details.

Again, thank you for you help with learning something new.

Yes, exactly that.

In a nutshell and not very technically put:
Servos, motors and such are notorious producers of noise and ripple on their power lines.
Hence something wants to be done against that noise upsetting the µC.
And for that, low value (e.g. 100nF) capacitors are good for "shorting" high frequency noise down to GND while high value (e.g. 47µF) caps are good as buffers to add extra oomph when a demanding load requires more power than the supply can comfortably provide.

1 Like

Also in your code above, the delay of 330ms (whoops-originally wrote us) is too small for the servos I have used. If you change the position too quickly, the servo just jitters a little and hums without really moving much.

I read the datasheet for that servo and it wants 400mA at 6V and has a stall (maximum) current draw of 2.7A at 6V. You show a 5V at 5A supply–I hope that is correct.

Another helpful test to run is to power the servo off your 5V supply but power the Photon from a USB phone charging battery or similar. You would want to disconnect the +5 supply from Vin for this test. You do need to grounds connected still.

2 Likes

Everyone, thank you for your help. I was able to get it up and running this weekend and managed to not kill another Photon based on the schematic in my previous post with the help of @ScruffR. Everything behaved as it should have.

As far as my observation about the two different sounds I heard from the servo when I burned out, I believe this has to do with this servo being a continuous 360 servo. The first write caused the servo to go full speed in one direction, while the second write brought the pulse to the servo almost back to center which would stop the servo’s rotation, but my servo has slightly different neutral point. In the code example I followed:

    myservo.write(0);   //start turning the servo
    delay(330);     //how long the turn turns in ms (may need some adjusting)
    myservo.write(92);  //stop turning servo

92 was neutral for the author’s servo. In my case, 92 did not stop the servo from turning, but was turning very slow. I had to adjust it to 93 to get the servo to stop, anything bigger and the servo would reverse direction. After the adjustment, the servo would turn for ~330ms with each invocation of the function.

@bko, thank you for your input. Looking at the spec sheet:

1-3 Operating Voltage Range 5V - 7.2V

I am on the low end with a 5VDC 5A supply, but it shouldn’t impact the function of the servo aside from a lower upper end torque. I’m not sure why they didn’t provide more detailed specs at 5VDC too.

If I’m not mistaken, delay() takes a value of milliseconds, not microseconds. And with a continuous rotation servo, it’s not about driving it to an angle as much as turning at a variable rate of speed for some amount of time. Once I actually get the servo attached, I’ll adjust the speed and time the servo turns to get the proper amount of food dispensed.

For the moment, since I’ve had a successful test run by driving everything with a more powerful supply, I’ll forgo testing with two separate power sources.

Thank you all for your input.

3 Likes

Thanks–I corrected my post above to say “ms” instead of “us”. My bad–sometimes my fingers are too quick.

@klog I've encountered similar issues using digital servos and Photons that isn't necessarily related to power draw issues, but more to noise on the servo's power lines, and how often you were polling the servo position updates. The 'ringing'/oscillation/feedback loop can destroy a Photon's voltage regulator, when the Photon struggles sharing power with the noisy digital servo, while at the same time trying to signal the servo via PWM. In my case, without filtering caps, the 186mA digital servo consistently murdered Photons when the servo arm moved to its extremities at high refresh rates. While the voltage regulators can be replaced, it's not something to do on a constant basis.

Here's the discussion below from that episode. tl;dr: besides catering for sufficient power supply, add filtering caps and check how often you're updating the servo position.

1 Like

You cannot drive non resistive loads with GPIO pins. Even if it is a small load within the very restrictive drive capabilities (<25 mA)! Servos are non linear and non resistive loads (have reluctance or complex impedance Z = R + jX) X is non zero. This can easily latch-up the GPIO output transistors.

You MUST us an external H-bridge when dealing with complex loads to protect the GPIO pins. You can get them for < $1.

One must read the datasheets to determine appropriate pin loads.

MSEE

Hi @marmageek

He was not driving a servo motor with GPIO pin, but using a radio-controlled (RC) vehicle type servo and driving the control input from a PWM pin on the Photon. This is fine since all the motor control is in the RC servo.

1 Like

Still having issues?

What distance GPIO–RC data inputs?
Is the servo data expecting 5VDC digital signals?

Here is a tutorial:

https://learn.sparkfun.com/tutorials/hobby-servo-tutorial

I believe the original poster is having power supply noise trouble that is not really related to the GPIOs.