Uploading code to Arduino with Shield attached

Hey!

I have a simple question: Is it safe to connect the Arduino R3 to my PC to upload/tweak code with a Shield attached? This is the shield I have.

Do I really have to disconnect the shield every time or is it ok as long as I don't supply the system with more power than that which comes from the USB cable when it's connected to my PC?

Do you have anything plugged into the TxRx header on the shield? Just unplug that to upload.

Try it, but be prepared if the motors start to move during programming. Either disconnect the motor power supply or hold it so it can't drive off your desk and fall to the floor. (And can't injure you with flailing robot arms.)

MorganS:
Do you have anything plugged into the TxRx header on the shield? Just unplug that to upload.

Try it, but be prepared if the motors start to move during programming. Either disconnect the motor power supply or hold it so it can't drive off your desk and fall to the floor. (And can't injure you with flailing robot arms.)

Thanks for the reply! The only things I will have connected to the Shield is servoes and/or a DC motor. Nothing is connected to Tx / Rx / GND or 5V.

I will disconnect any power to the Shield aswell as switching off the power switch on the Shield itself.

@MorganS
Just unsure about the safety of my computer. In this video at 2:46 he says that "[...] overcurrent can damage your computer!". Is this only if I have anything connected to Tx/Rx? Is there any other solution that enables me to easily and safely upload code without disconnecting the servo shield?

Eophex:
@MorganS
Just unsure about the safety of my computer. In this video at 2:46 he says that "[...] overcurrent can damage your computer!". Is this only if I have anything connected to Tx/Rx? Is there any other solution that enables me to easily and safely upload code without disconnecting the servo shield?

As long as the Rx/Tx lines are not utilized, there shouldn't be any issues -- as long as there are no issues when you actually run the thing [with shield attached].
When you Upload a sketch to the Arduino, the MCU is held in Reset during the whole process, so nothing should exercise anything on the shield. The only possible caveat is if the new firmware causes something catastrophic to happen on the shield -- but, that's going to happen, anyway, in the scenario where you disconnect the shield during Upload, and then reattach the shield, and power it up. So, such a thing really can't be attributed to the Upload session.

ReverseEMF:
As long as the Rx/Tx lines are not utilized, there shouldn't be any issues -- as long as there are no issues when you actually run the thing [with shield attached].
When you Upload a sketch to the Arduino, the MCU is held in Reset during the whole process, so nothing should exercise anything on the shield. The only possible caveat is if the new firmware causes something catastrophic to happen on the shield -- but, that's going to happen, anyway, in the scenario where you disconnect the shield during Upload, and then reattach the shield, and power it up. So, such a thing really can't be attributed to the Upload session.

Im not very educated in electronics, but is it possible that the USB cable "pulls" too much current from my computer if the servo board want's to power let's say a DC motor and 10 servos? Is that possible and won't it damage my computer?

Eophex:
Im not very educated in electronics, but is it possible that the USB cable "pulls" too much current from my computer if the servo board want's to power let's say a DC motor and 10 servos? Is that possible and won't it damage my computer?

There are several questions in there, so:

Eophex:
... is it possible that the USB cable "pulls" too much current from my computer...

The USB cable will only "pull current", if the thing it is attached to demands current. USB cables, on their own, are not known for "pulling current", unless of course it's shorted, or something.

Eophex:
...if the servo board want's to power let's say a DC motor and 10 servos?

Can't say for sure, without more information regarding that DC motor and 10 servos, but the likely answer is a definite maybe [that it would probably be too much current] -- especially if all of them are run at the same time. I assume you're talking about powering the Servo Board from the Arduino 5V pin, right? If so, then yes that will draw all of this current from the USB port. Now, if only one, or a few, of these devices are run at a time, perhaps you could get away with that, but knowing how much current each might draw, is imperative for this evaluation [and it's important to look at Start-up current, and Stall current].

Eophex:
...won't it damage my computer?

If this arrangement demands more current than your Computer's USB port can safely supply, then there is a slight chance it will damage your computer. A properly designed USB port will prevent too much current from being *drawn *from the port, but it seems not all USB ports are properly designed. Bottomline, since a USB port that resides on a Mainboard, might be problematic to repair [or replace], best to prevent this from happening in the first place. Or, even better, use a USB power port -- one that plugs into a mains socket. Or one of those USB batteries.

Thank you very much for that answer!

ReverseEMF:
Can't say for sure, without more information regarding that DC motor and 10 servos, but the likely answer is a definite maybe [that it would probably be too much current] -- especially if all of them are run at the same time. I assume you're talking about powering the Servo Board from the Arduino 5V pin, right?

Yes.

ReverseEMF:
If so, then yes that will draw all of this current from the USB port. Now, if only one, or a few, of these devices are run at a time, perhaps you could get away with that, but knowing how much current each might draw, is imperative for this evaluation [and it's important to look at Start-up current, and Stall current].

If I supply the servo board with external power (6 V from an adapter like I have it when it's not connected via USB) while uploading with the USB cable, will any servos/DC-motors pull less current from the USB cable since it has "access" to another power source? Almost like having a "surplus" of current so that the servoboard won't pull too much from just the USB cable?

Also: Isn't it possible to completely ignore this problem by just disconnecting any servos/DC-motors or devices that require power from the board while uploading? Or alternatively have a button that starts and stops the Arduino. At the moment it just starts as soon as it has power. (Link to a tutorial?)

If I supply the servo board with external power (6 V from an adapter like I have it when it's not connected via USB) while uploading with the USB cable, will any servos/DC-motors pull less current from the USB cable since it has "access" to another power source?

As you have a 6V source this is greater than the 5V source from the USB so there is a chance you will force 6V through the USB cable and into your computer. That is a good way to damage a USB port on your computer, even a correctly designed one.

Isn't it possible to completely ignore this problem by just disconnecting any servos/DC-motors or devices that require power from the board while uploading?

Yes that would work.

Or alternatively have a button that starts and stops the Arduino.

No that is irrelevant to the situation.

Grumpy_Mike:
As you have a 6V source this is greater than the 5V source from the USB so there is a chance you will force 6V through the USB cable and into your computer. That is a good way to damage a USB port on your computer, even a correctly designed one.
Yes that would work.
No that is irrelevant to the situation.

Quick programming question: Does the "loop()" function ALWAYS run? I.e: can it run parallell to other functions?

Does the "loop()" function ALWAYS run?

Yes. Unless there is an infinite loop in the setup function that stops it getting to the loop function.

can it run parallell to other functions?

No this is a single core system so only one thing at once. But you can make it look like sevral things are happening at the same time with the correct programming.

Eophex:
If I supply the servo board with external power (6 V from an adapter like I have it when it's not connected via USB) while uploading with the USB cable, will any servos/DC-motors pull less current from the USB cable since it has "access" to another power source? Almost like having a "surplus" of current so that the servoboard won't pull too much from just the USB cable?

It's hard to be sure from the broken English description and lack of schematic on that Bang_good Servo Board catalog page, but it sure looks like connecting this Servo Board to its own supply [and NOT to the Arduino +5V supply], with the proper jumper arrangements, will result in all of the Motor/Servo current being drawn from the attached supply [6V in your example]. Then, with the Arduino ground connected to the ground on the Servo Board, will allow Arduino Outputs to control the Servo Board attached devices [such as your DC Motor and 10 Servos] via the Servo Board inputs. Such an arrangement should not draw any *driving current *from the Arduino.

Then it boils down to whether your 6V power source can properly power those Motor/Servo devices.

ReverseEMF:
It's hard to be sure from the broken English description and lack of schematic on that Bang_good Servo Board catalog page, but it sure looks like connecting this Servo Board to its own supply [and NOT to the Arduino +5V supply], with the proper jumper arrangements, will result in all of the Motor/Servo current being drawn from the attached supply [6V in your example]. Then, with the Arduino ground connected to the ground on the Servo Board, will allow Arduino Outputs to control the Servo Board attached devices [such as your DC Motor and 10 Servos] via the Servo Board inputs. Such an arrangement should not draw any driving current from the Arduino.

Then it boils down to whether your 6V power source can properly power those Motor/Servo devices.

The power adapter is configurable from 3 - 12 V, so if I need more servos and maybe a DC motor then I just crank up the voltage until every device is able to operate, right?

so if I need more servos and maybe a DC motor then I just crank up the voltage until every device is able to operate, right?

Definitely not right. That is the way to destroy things.

Eophex:
The power adapter is configurable from 3 - 12 V, so if I need more servos and maybe a DC motor then I just crank up the voltage until every device is able to operate, right?

It's been many decades since, following my acceptance of Ohm's Law, that I puzzled over the implications of the Laws established by Gustav Kirchhoff. One of them being: The same voltage exists across all parallel circuit elements. The other being that the sum of all the currents flowing into a "node" are equivalent, in magnitude, to the sum of the currents flowing out of that same node.

With a complete understanding of that knowledge, revealed to you will be the folly of your statement :wink:
Bottom line [other than your need to go through the ordeal of studying Kirchhoff's Laws] is that whatever voltage you supply to that "Servo Board", will be the voltage applied to each Motor and/or Servo you connect to that board. So, it's important to know what the nominal voltage [i.e. the proper operating voltage], is for each of the devices you plan to control with that board AND it's important that each of those voltages be the same and that they match the voltage applied to the Servo Board [and in the case of this board, there are two supply lines--one for Motors and one for Servos!].
Also, it's important to use a voltage that is within the range of voltages specified for that board [from the Catalog Page: "If short VM and VIN, and short VS and 5V, then CAN control the 2 Channel motor (with 6-18V) and 16 Channel 5V servo." That means, if you apply 6V to VIN, then all the DC Motors [sounds like a max of 2] must be 6V motors, and all the Servos [apparently at most, 16] must be 5V.

Also, it's important to get a summation of all of the currents involved. Each device [whether Motor or Servo], will draw a certain amount of maximum current. You must discover these expected currents and then sum them together. That will be the maximum current your supply [or supplies] will need to be able to deliver. So, in the case of this Servo Board, you will need to add up the maximum currents the DC Motor(s) will draw and make sure your 6V supply will handle such current AND you must add up the maximum currents those Servos will demand, and make sure the 5V supply will handle those. If the 5V supply turns out to be what is delivered by the USB port, then you must be certain it can deliver this worst case current -- OR be certain that not all of the Servos will operate at once, in which case, your current needs will be less. Same applies for the Motors -- if only one motor is to operate at a time, then only the maximum current of the Motor that demands the most current will determine the 5V supply's ability to deliver current.

And then, a good rule of thumb is to double these expected currents [or at least multiply them by around 150%].

ReverseEMF:
With a complete understanding of that knowledge, revealed to you will be the folly of your statement :wink:
Bottom line [other than your need to go through the ordeal of studying Kirchhoff's Laws] is that whatever voltage you supply to that "Servo Board", will be the voltage applied to each Motor and/or Servo you connect to that board. So, it's important to know what the nominal voltage [i.e. the proper operating voltage], is for each of the devices you plan to control with that board AND it's important that each of those voltages be the same and that they match the voltage applied to the Servo Board [and in the case of this board, there are two supply lines--one for Motors and one for Servos!].

Thanks a lot for that answer!

The servos I use are 3 - 7,2 V (SG90) and I've so far only powered them with 6 V but I suppose I can supply them with 5 V? As long as the current won't exceed the maximum that the board can take? Would you guys say that it's safe to use 16 of these servos at 5 V? I probably won't use 16 of them, but knowing that it's possible will make me feel more comfortable.

The DC motor I'll possibly use is this one. It won't go extremely fast at any point in my project, since it will most likely power a small conveyor belt or something like that. Does this mean that I only have to supply VM with the smallest voltage required (3 V)? It's rated at 9 V, but the lowest RPM it can produce is at 3 V so doesn't that mean that using more than 3 V will be unnecessary?

EDIT: Just realized that the input voltages are 6 -18 V so the lowest I can go is 6 V...

I have no idea how to actually control the DC motors with this servo board, but I assume that it's possible by configuring A+ & A- or B+ & B- in the program. Does anyone:
Know how to do this / know a good thread that teaches me? If this gets too much into programming I can bring it up in another post since I'll probably post another thread in "Programming" since I have a problem regarding that aswell.

Eophex:
Thanks a lot for that answer!

The servos I use are 3 - 7,2 V (SG90) and I've so far only powered them with 6 V but I suppose I can supply them with 5 V? As long as the current won't exceed the maximum that the board can take? Would you guys say that it's safe to use 16 of these servos at 5 V? I probably won't use 16 of them, but knowing that it's possible will make me feel more comfortable.

The DC motor I'll possibly use is this one. It won't go extremely fast at any point in my project, since it will most likely power a small conveyor belt or something like that. Does this mean that I only have to supply VM with the smallest voltage required (3 V)? It's rated at 9 V, but the lowest RPM it can produce is at 3 V so doesn't that mean that using more than 3 V will be unnecessary?

I have no idea how to actually control the DC motors with this servo board, but I assume that it's possible by configuring A+ & A- or B+ & B- in the program. Does anyone:
Know how to do this / know a good thread that teaches me? If this gets too much into programming I can bring it up in another post since I'll probably post another thread in "Programming" since I have a problem regarding that aswell.

So, notice, on that Bang-Good catalog page, for the JOHN-SON380 Motor, there is a list of specs. And one of them is Maximum current. And that value is: 3.8A
That is the current you need to make sure your power supply can deliver. I've never heard of a USB port that can deliver that much current, so most likely you will need to use an external supply.

Now, this current is the Absolute Max this motor is likely to draw--and that will usually be when the motor is starting up [though probably not that much current at start-up, unless it is heavily loaded], when the motor is heavily burdened, and especially when it is "stalled" [that's when something is causing the shaft to NOT MOVE].

You might be able to get away with using a supply that has a lower maximum current, IF you will not be loading down this motor [much], and IF you place a very large capacitor across the motor [so the capacitor can store up charge, and deliver that charge during those brief times the motor demands such extreme currents].

Are you getting a sense of the complicated nature of this topic?

The specs also include a No Load Current of 680MA. That's the current the motor will draw when it is just sitting there running, but not doing anything [i.e. with nothing physically connected to the motor shaft]. So, the actual average operating current will be somewhere in between 680mA and 3.8A.

So, either get a supply that can deliver 3.8A--all the time. Or, learn enough electronics to figure out the value of capacitance for supplying current bursts, when the motor demands it -- assuming the application will be "bursty". OR, use this as an opportunity to learn electronics and get busy experimenting ['cuz, that's how I/we learned it, fer kris sake :wink: ]!

As for the Servos -- yes, if they're spec'd to operate from a voltage range of 3V to 7,2V, then notice how 5V fits in that range? That means that you can run it/them on 5V. So, look up the specs for your Servo(s) and see what it says about current demand. There will, likely, be more than one current specification. If you can't make sense of it. Come back here and ask.

As long as the current won’t exceed the maximum that the board can take?

You don’t seem to be understanding this thing called current.

You are powering a servo, the board dosn’t “take the current” you are just generating a control signal. The real power comes from your external power supply, and as ReverseEMF just pointed out :-

So, the actual average operating current will be somewhere in between 680mA and 3.8A.

That is PER MOTOR, that is a lot of current however you look at it. But it comes from the supply not the board.