[fixed] Connecting Mega 2560 & Sainsmart 4 axis arm, avrdude and port # changing

Summary: Why can I upload sketches to a Mega 2560 board by itself, but not when it is connected to a robotic arm?

I am using a Mega 2560 with a sensor shield v2 from Sainsmart to control a 4-axis robotic arm.

The 2560 is connected to a Mac and to power using a two-pronged USB cable. One prong goes into power, and the other into the Mac to upload code. The prongs join together into one cord and are connected to a printer cable, which is then plugged into the 2560.

When my robot arm is not plugged in to the board, I can successfully upload any sketch to the board. When I plug the arm in, select the port that has the Arduino tag, and click upload, I get the following errors:

avrdude: ser_open(): can't open device "/dev/cu.usbmodem861": No such file or directory
ioctl("TIOCMGET"): Inappropriate ioctl for device
ioctl("TIOCMGET"): Inappropriate ioctl for device
avrdude: ser_send(): write error: Bad file descriptor
avrdude: stk500_send(): failed to send command to serial port
avrdude: stk500v2_ReceiveMessage(): timeout

... some more repetitions of "write error: bad file descriptor", "failed to send command", "timeout"...

avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude done.  Thank you.
the selected serial port 
does not exist or your board is not connected

When I next click on the port button, the port number has changed. When I select the new port number and try to upload, I get the same errors and the port number changes again.

I have tried: restarting the IDE with the board plugged in, using a different USB port, different printer cable, and searching Google and various forums. One person suggested opening the sketch from the program list instead of by clicking on the .ino file. I don't know how to get to this program list, because when I click to launch the Arduino app, the sketch I am working on pops up. I was also advised to connect the negative outputs (grounds) of my power supplies together, but I am not sure how this works in the context of my USB powering (as opposed to connecting a power supply to the screw terminals on the shield.)

The only way to upload sketches that will work on the arm is to disconnect and re-connect the 12 wires that go from the board to the arm.

How can I upload programs to my board without disconnecting the arm every time I want to make a change? I'm a newbie to Arduino and would appreciate if anyone could point me in the right direction. Thanks for your help!

UPDATE: I am now powering the arm through the screw terminals instead of the y-usb cable. This has fixed the error.

Not enough power from USB port for your robotic arm.

ieee488, thanks for the reply. I have my USB cord connected to an outlet as well as the computer (I described it in more detail in the post). Could the power in the outlet be insufficient, or is something wrong with my wiring?

artemis_arduino:
ieee488, thanks for the reply. I have my USB cord connected to an outlet as well as the computer (I described it in more detail in the post). Could the power in the outlet be insufficient, or is something wrong with my wiring?

First, I have no idea what your USB cord looks like.

Second, I have no idea what is the current draw of your robotic arm especially peak.

My USB cord looks like this one.

The male ends are plugged into

  1. a USB port on my computer
  2. a sugar cube, which is plugged into an outlet
    The female end is plugged into a printer cable, which connects to my Mega.

I am not sure what the current draw of my arm is, but according to the product page, the 4 servos need a "working current" of 100mA each, or 400mA in total. Given that an outlet can provide 15 amps (according to Google), 400mA doesn't seem like too much.

Would it be better to forget about powering through a USB altogether and just use the screw terminals?

I would do away with the Y USB cord.

Use a USB cable from the cube to power only the robotic arm.

Use a data+charge USB cable for your Mega.