0

So I have a Duemilanove board and am utilizing 7 output pins, I power a Pixy camera and pan/tilt servos from the ICSP header, i also power an HC-SR04 sonar snsor directly from the board.

Of those 7 output pins, 4 are PWMs for the motors (don't ask why), 3 are for servo control (tower pro mg-995)

when I try to output these 7 pins simultaneously things don't work, i get "components at a time" behavior. Like servos turn first, then the motors spin (servos stopped).

Initially we thought it must be a power supply problem (8 1.2v NiMh bat series) which powers the l298n h bridges (two of them) and also powers the board and servos. But now im starting to fear that it's the board itself and that it can't handle simultaneous outputs.

I've read from here (method #10) that taxing the board more than 200mA is a problem. But what exactly happens if you do just that? And is my case exactly like this one? If so, how to fix it?

  • Edit +

Here's how the circuit looks. enter image description here

Edit:

Yes i do think there is a need for decoupling capacitors but im not sure where to put them. They dont seem to work. The bounty goes to the best answer on the proper decoupling of this circuit.

Edit:

Here's some images on the Pixy camera

enter image description here enter image description here

Edit:

Actually from the original problem I noted when I posted this question, things don't work as expected. WHen the big servos move, the pan/tilt camera don't move when they are supposed to, or the motors briefly stop. I'm wondering if is also an Arduino idiosyncrasy because when I don't run the servo.attach(servo_pin) code everything works fine.

  • 1
    Try having the power wires go directly from the battery to the motors/h-bridge, instead of via the Arduino. Adding an capacitor to the power rail might help too. – Gerben Feb 15 '15 at 19:29
  • I think the main issue with your circuit is a lack of decoupling between the various big current consumers (motors, servos). Adding a few decoupling caps should help. – jfpoilpret Feb 16 '15 at 5:58
  • 1
    You should not be trying to run servos off the Arduino's 5V regulator. Give them their own. – Chris Stratton Feb 20 '15 at 17:10
2
+50

My experience of high power draw from an Arduino is that it endlessly re-boots so maybe not the issue for you.

The Servo library and PWM pins are probably sharing the same timer therefore motors stop while servos are running.

You could try a different Servo library.

This article is useful to understand the timer/pwm/pin relationships

  • the second sentence is spot on... it happens. If you could provide a solution for the motors stopping while servos are running? – Mywiki Witwiki Feb 22 '15 at 0:27
  • okay but let's be clear. you are not causing more than 500ma to be drawn through the Uno voltage regulator because you are going to get erratic and confusing results? – Visual Micro Feb 22 '15 at 0:46
  • i dont think i understand your question clearly. the only components directly powered by the arduino board are: Pixy (cmucam5), sonar (HC-SR04), two tower pro sg-90 servos (pan/tilt). – Mywiki Witwiki Feb 22 '15 at 0:55
  • You are right. Prob not a good question. Should have been what happens if you disconnect the power to the servos and the cam. Do the motors run without halting when you know the servos and cam would be working? You could use a debugger or serial messages to tell you when the servos and cam should be working. This test proves if the power is related to the any issue(s) – Visual Micro Feb 22 '15 at 1:08
  • ok good question. The servos being connected is not the problem. The problem is when there is that 'servo.attach(servo_pin)' in the code. – Mywiki Witwiki Feb 22 '15 at 1:22
2

From the Servo library documentation:

On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins.

This is, as has been suggested, because of conflicting usage of the timers. You should just move your DC motors to other PWM-capable pins.

1

Here are a few suggestions that might help:

  1. Provide its own power supply to Arduino UNO, so that no voltage drop can occur on the board itself due to high energy consumers as servos and DC motors. As someone suggested in an answer, a voltage drop on Arduino MCU may trigger the Brown-Out Detection (BOD) which will stop the MCU until voltage rises up again, above a given threshold. You could for instance power the UNO with a 9V battery (or the equivalent 7.2V rechargeable pack). Those batteries don't have much energy but it should be OK as long as they are not used for powering motors. Of course, then you'll have to remove the Vin wire to your 8-batteries pack.

  2. Add decoupling caps (between V+ and GND) as near as possible to every energy consumer: that means adding decoupling for each motor driver power-in pins, for each servo power pins, and ALSO for the HC-SR04 sonar sensor (in my experience, it can drop voltage a lot, more than you could expect); note that you may also need decoupling for the camera, but I'm not sure on this one, because I have never used one yet.

Note on decoupling caps:

The value of caps to use depend on many factors, which would be too long to explain here (and I admit that I don't necessarily understand each of these); but typically, you would use a small cap (100nF) when you expect fast (and short) voltage drops, and a bigger cap (>=10uF) when you expect longer voltage drops.

When you don't know, you can just experiment and see what works best.

Using both kinds of caps at the same time (in parallel) does no harm (I have done this in several situations).

For higher caps, you will have to use an electrolytic cap, which is polarized: do make sure that you wire them correctly (+/+, -/-) otherwise they may blow up.

Also, choose a breakdown voltage for the cap that is much above (I'd say 50% above is fine) your power voltage; 16V is a common value that would fit your needs; of course, you can use higher breakdown voltages as well.

  • the pixy camera, along with the pan/tilt servos, are powered through the SPI header in the Arduino board. When the bigger servos are moving, the pan/tilt servos don't move when they're supposed to (im assuming they are experiencing brownouts). How do you propose to decouple a connection through the SPI header? – Mywiki Witwiki Feb 22 '15 at 0:31
  • I don't see the pan/tilt servos in your circuit; you mean they are directly part og the pixy camera and get their power directly from the SPI header? I'd be surprised about that! I could not find a complete datasheet for TowerPro SG90, but I think it should be powerable by your 7.2V AA batteries pack. – jfpoilpret Feb 22 '15 at 7:33
  • If those servos are really powered through the same SPI power pins as the pixy camera then, I'm afraid you will have to set an extra 5V power supply (regulated) just for it. – jfpoilpret Feb 22 '15 at 7:35
  • yes they are powered by the pixy camera by regulating power off the 5V SPI power pins. Im planning to power them from the regulated 5V of the Arduino board instead. Would that be fine? – Mywiki Witwiki Feb 22 '15 at 15:42
  • That would be the same: the SPI 5V is the Arduino regulated 5V. I can't remember the max current you can draw from here, but I guess it must be quite limited. I doubt just adding a decoupling cap here would be enough. – jfpoilpret Feb 22 '15 at 15:51
0

I know this is after the fact but "Back EMF " is more than likely the issue with the starting and stopping of the servo's and most likely the DC motors. The power supply could receive a pulse 4 to 5 times its supply voltage. The cpu could be scrambled or reset. Or pulses sent to servos corrupted. Divert the energy of a motor's collapsing magnetic field back into itself with a diode, cathode to the positive supply rail. Basically any time you stop or start a motor its magnetic field has to go somewhere.Digital hates that.

-1

When power goes through a wire, it heats up the wire. The more current you draw, the more it heats up. The "wires" inside a chip such as the one that adjusts the power aresmall, which means it heats up more, and also it takes less to burn it out.

A fuse is essentially a very thin wire. If you draw too much current (amps) through it, it will burn out (melt the wire). Wires inside a chip or on a PCB are much the same, It may recover when it cools down, or not. Some devices have protection, some do not - you may find the arduino shuts itself off to protect itself, to restart after a period. Or it may not.

As has been suggested, you can bypass the board to power the h-bridge - there should be one or two pins to power the h-bridge separate from the signalling, specifically for this reason.

Also, if the board is powered by batteries, the batteries may not be able to supply the current, causing one or more parts not getting enough power.

If you do bypass the voltage regulator and use power directly from the power source, remember that you are using a different voltage - the voltage from the power source, not +5v.

If you are powering your board from USB, then be aware that there are limitations to the power able to be supplied via USB - the USB specs say 150milliamps; any higher power has to be negotiated with the host (PC), so you may get different answers for a laptop vs. a desktop vs. a mains power adapter.

  • as a matter of fact im using 2 h bridges to drive 4 motors. 4 PWMs connect to the in1, in2, in3, in4 of the drivers (the drivers share a pin for the same "in"). – Mywiki Witwiki Feb 15 '15 at 20:30
  • I noticed that my assumptions about powering direct were wrong, and rewrote about half the answer. – AMADANON Inc. Feb 15 '15 at 20:32
  • my circuit power supply is a series of 8 1.2V NiMH AA batteries. It directly powers the arduino and the motor drivers. Refer to the uploaded image. – Mywiki Witwiki Feb 15 '15 at 20:51
  • when i try to output all the 7 pins to drive all the components (yes all), the board keeps flashing. And the servos merely jitter instead of turning, the motors turn from time to time but not how they were programmed to, and the Pixy (including pan/tilt) doesn't even work. – Mywiki Witwiki Feb 15 '15 at 21:00
  • i also noticed that at this state, when I pull off some of the control wires from the output pins, things start to work for the remaining control pins. – Mywiki Witwiki Feb 15 '15 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.