HELP!! I fried two Arduino Mega already. What am I doing wrong?

I'm using an arduino megaR3 to control the oriental motor BLH5100KC-100. Here is a wiring diagram for the motor controller that comes with the motor:

Here is the wiring diagram:
https://dl.dropboxusercontent.com/u/71339999/RoboNail%20Electric%20Diagram.pdf

Note: I've been using this arduino to control relays and bluetooth cards for weeks now. The power, usb, etc all works great. It never fried until I connected the motor.

I have four wires connected to the arduino Mega's pins 5 through 8. Also, the arduino is powered via USB and the Barrel Jack. Here is the code i'm using:

void setup ()
{
pinMode (5, OUTPUT); //black wire / startStop
pinMode (6, OUTPUT); // White wire / runBrake
pinMode (7, OUTPUT); // Gray wire / counterClockwise
pinMode (8, OUTPUT); // Green wire / speedInputPWM

digitalWrite (7, LOW); // Gray wire / counterClockwise
delay(10);
analogWrite(8,200); // Green wire / speedInputPWM
delay(10);
digitalWrite (6, LOW); // White wire / runBrake
delay(10);
digitalWrite (7, LOW); // Gray wire / counterClockwise
delay(10);

} // end of setup

Somehow I'm frying my Arduino. It completely stops working and none of the pins work anymore. At first I thought it was a fluke so I bought another arduino and the same thing happened.

What am I doing wrong?

Did you read the specs on the mega before you started using it ?

http://arduino.cc/en/Main/arduinoBoardMega2560

Microcontroller ATmega2560
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V

What is the red wire (+24V dc) connected to on the Mega (where) ?

FYI, you should also be using opto isolators

The 24v is connected to the motor controller. Not the arduino. the following four are ONLY connected to the motor controller:
Red = +24v from power supply
Black = -24V from power supply
Orange = Gnd to power supply
Yellow = -5V from power supply

The Arduino is powered via the USB port. And the arduino only has 4 wires connected (other than the USB) on pins 5 through 8.

Sorry for the confusion.

You need to connect the ground for the signals. That is the orange wire. Connect it to the Arduino GND. Do not connect the orange wire to the power supply.

Do not connect -5V from the power supply to the unit. Do not connect -5V at all. I think it will run without connecting VRH, VRM or VRL.

The power supply is connected to the red and black wire.

The control unit has two connectors: CN1 for the power supply and CN2 for I/O. Do not cross any wires between them. The Arduino only to CN2, and the power supply only to CN1.

The orange wire is connected to the ground. The power supply has a ground lug.

The c1 24v is completely isolated from the arduino.

So the only thing you think is wrong is connecting the -5v? But this is not even connected to the arduino. I am thinking there must be something else wrong

I don't know how those VRH, VRM and VRL are connected inside, so I don't know what did happen. But applying -5V is not intended.

What about that ground lug ?
Suppose the CN1 GND is connected internally to the CN2 GND. And the black wire from the power supply to CN1 GND is a little loose. When you turn it on, a large ground current could run like this: Power supply gnd -> ground lug -> ground in your house -> computer -> arduino -> to orange wire -> to CN2 GND -> to motor. A large ground current would fry the Arduino board.

You can avoid that with :

  • Arduino on battery power, disconnected from the computer.
  • Optocouplers between the Arduino and the driver.
  • A Power Supply for the driver that is not connected to mains ground or earth ground.
  • A resistor of 47 ohm (10 to 100 ohm) in the orange ground wire.

When you turn the driver on, you can measure if the inputs are not shortcut inside. With a voltage meter you should measure 5V, and the shortcut current to GND should be 0.5mA (because of the interal 10k pullup resistor).

huggybaird:
The 24v is connected to the motor controller. Not the arduino. the following four are ONLY connected to the motor controller:
Red = +24v from power supply
Black = -24V from power supply
Orange = Gnd to power supply
Yellow = -5V from power supply

The Arduino is powered via the USB port. And the arduino only has 4 wires connected (other than the USB) on pins 5 through 8.

Puzzled by your power supply. Is Black really -24V? And is the "ground lug" 0V on the output side, or a chassis ground (safety earth)?

I would expect Black to be 0V, for a 24V PSU. Do you have a spec for your PSU or some photos of it's terminals?

Note that anytime connecting an external PSU, it is important to verify that they are isolated or have 0V reference to earth. Some do not, which appears to be a common cause of smoked Arduinos.

Normally, you should have just Red/Black from the PSU (+24V, 0V) connected to the CN1 pins on the motor controller. Connect Arduino ground to Orange (pin 3 on CN2). There is no need to connect Orange to the PSU. Follow the diagrams on page D-145.

You shouldn't be connecting -5V anywhere.

Be careful driving the speed input (VRM). It expects a continuous voltage, the analog output from the Mega is a PWM signal, that will very likely screw up the motor control. I would leave it unconnected, until after you get basic start/stop working.

I would also suggest using opto-couplers is a good idea to preserve the life of your Arduino, as well as the life of the PC connected to it.

Draw a diagram of how everything is connected and post a photo of the diagram. It's the only reliable way to see what's going on. It's just too easy to get confused with verbal descriptions.

...R

Great tip. this is my first electric diagram... but I'm pretty sure it is correct

https://dl.dropboxusercontent.com/u/71339999/RoboNail%20Electric%20Diagram.pdf

bobcousins:

huggybaird:
Be careful driving the speed input (VRM). It expects a continuous voltage, the analog output from the Mega is a PWM signal, that will very likely screw up the motor control. I would leave it unconnected, until after you get basic start/stop working.

I think the problem has something to do with the VRM/VRL connections. When I first started wiring the motor in, I use some alligator clips on the +5v/-5v and the motor was working. I had the Stop/Start and Run/Brake connected to the Arduino. Then, after I connected the VRM/VRL the Arduino fried.

The problem is, I don't know what to do about this. Should I just connect the VRM/VRL to +5v and -5V GND rather than trying to use the Arduino? If I did this, I would have no way of controlling the speed of the motor

Thanks for the diagram.
There are problems with it, and we already wrote about them.

You connect the mains-ground to the pin 3 GND of low voltage signal side. Please don't do that. Only the Arduino GND should go to the orange wire to pin 3. At the moment the signals from the Arduino to the controller have no meaning, since the Arduino GND is not connected.
You can not connect -5V to VRL. As far as I know, it is not ment to be like that.
You probably can not connect a PWM output to VRM.

And the power - 24V is connected to the Arduino GND (via the power supply), and the Arduino is connected to the computer. That is a disaster waiting to happen. Use the computer USB to power the Arduino, or buy a seperate power supply.

Can you make a new drawing with good connections ? So we can have a look before you try it for real ?

Peter_n:
Thanks for the diagram.
There are problems with it, and we already wrote about them.

You connect the mains-ground to the pin 3 GND of low voltage signal side. Please don't do that. Only the Arduino GND should go to the orange wire to pin 3. At the moment the signals from the Arduino to the controller have no meaning, since the Arduino GND is not connected.
You can not connect -5V to VRL. As far as I know, it is not ment to be like that.
You probably can not connect a PWM output to VRM.

And the power - 24V is connected to the Arduino GND (via the power supply), and the Arduino is connected to the computer. That is a disaster waiting to happen. Use the computer USB to power the Arduino, or buy a seperate power supply.

Can you make a new drawing with good connections ? So we can have a look before you try it for real ?

THANK YOU VERY MUCH for all the help. Here is an updated drawing:
https://dl.dropboxusercontent.com/u/71339999/RoboNail%20Electric%20Diagram%20v2.pdf

There are two changes:

  1. Pin 3 GND is now connected to the Arduino GND
  2. Pin 4-VRL and 5-VRM are connected to the 5V step down power converter. The problem with this is there is no way for me to use PWM from the arduino to control the motors speed. Is there any way to control the speed of this motor with the Arduino? This is a major bummer

You also mentioned "- 24V is connected to the Arduino GND (via the power supply), and the Arduino is connected to the computer." but I don't think this is a problem. I only have the computer USB hooked up when I'm programming the Arduino. Then, I unplug the USB whenever I run the power supply. I'm using this transformer to step down the 24V into the arduino's barrel jack: http://www.amazon.com/SUPERNIGHT-TM-Converter-surveillance-instruments/dp/B00FXNN8RQ/ref=sr_1_37?s=electronics&ie=UTF8&qid=1407687691&sr=1-37&keywords=24v+to+12v+converter

I've had the same power supply and USB working for some time on this project. For months I've been using both the USB and Barrel jack as I've tested out multiple relays and sensors. The recent problems with me frying the arduino is related to the motor controller. That being said, do you still think the power supply to the arduino is a problem?

One last question, I still need to hook up pin 2 Speed Output. I have not done this yet because the manufacturer spec says "+26.4 VDC max. 10 mA max" here http://www.orientalmotor.com/products/pdfs/connection/BLH_connection_operation.pdf

I have not hooked up the Speed output yet because I'm afraid the 26.4V will fry the arduino. Is there any way for me to hook this up?

Thanks again for all the help

The speed output is an open collector output. The 26.4V is the maximum voltage you can apply (from the outside) to that pin before the controller is fried. You can connect the output pin directly to an Arduino digital input pin. Use 10k or 4k7 pullup resistor to 5V.

There is a lot confusion with the -5V and the -24V.

The CN1 pin 2 is the GND for the power supply, it's the 0V, it's the negative side of the power supply.
But it is not -24V. Can you remove the text -24V from the drawing ? It is very confusing. Call it GND or 0V.

Also the VRM being +5V and the VRL being -5V is not true. VRM should be 0...5V higher than VRL. That's all. There is no negative voltage. I think you can connect VRL to GND and convert a PWM signal to an analog signal with a filter and apply that to VRM.

About the ground current:
You can use the same power supply, and it will work. But when the black wire between the power supply and the CN1 pin 2 is loose, the Arduino could be fried instantly. During testing, it is safer to use a seperate power supply, and in the final project, you can use a resistor in the GND wire (for example 10 ohm or 47 ohm from Arduino GND to controller GND).

I'm left here scratching my head over a diagram that shows "step down transformers" on the DC output of a power supply?

One is labeled "Step Down Transformer 24v to 12v" (and feeds to the Arduino barrel connector); the other is labeled "Step Down Transformer 12v to 5v" and is cascaded from the first (and feeds the motor driver).

Transformers are for AC voltages - not DC. Unless you are using something else and calling it a "transformer" (and using a transformer symbol) - trying to do so is incorrect, and you are simply feeding 24 volts (well, probably a bit less) into the Arduino.

If you are using some other component - then you need to re-draw your schematic and label the components with their proper names. Otherwise, your schematic is mostly useless to us to help us diagnose your issue.

Peter_n:
The speed output is an open collector output. The 26.4V is the maximum voltage you can apply (from the outside) to that pin before the controller is fried. You can connect the output pin directly to an Arduino digital input pin. Use 10k or 4k7 pullup resistor to 5V.

There is a lot confusion with the -5V and the -24V.

The CN1 pin 2 is the GND for the power supply, it's the 0V, it's the negative side of the power supply.
But it is not -24V. Can you remove the text -24V from the drawing ? It is very confusing. Call it GND or 0V.

Also the VRM being +5V and the VRL being -5V is not true. VRM should be 0...5V higher than VRL. That's all. There is no negative voltage. I think you can connect VRL to GND and convert a PWM signal to an analog signal with a filter and apply that to VRM.

About the ground current:
You can use the same power supply, and it will work. But when the black wire between the power supply and the CN1 pin 2 is loose, the Arduino could be fried instantly. During testing, it is safer to use a seperate power supply, and in the final project, you can use a resistor in the GND wire (for example 10 ohm or 47 ohm from Arduino GND to controller GND).

Hopefully the final version:
https://dl.dropboxusercontent.com/u/71339999/RoboNail%20Electric%20Diagram%20v3.pdf

Few changes:

  1. Connected pin 2 Speed Output to the Arduino interrupt pin 2 with a 10k Ohm resistor
  2. Changed confusing -5V and -24V verbiage to be GND
  3. Changed PIN's 4 VRL/GND to the Arduino GND. Changed PIN's 5 VRM/+5V to Arduino's PWM pin. I think this is what fries the Arduino but am willing to give it another try. The difference between this and and original circuit that fried the arduino is that the Pin 4 GND is connected to the Arduino's GND rather than the SUPERNIGHT DC 12v to 5v Regulators GND pin.

Before I wire in bullet 3 from above, I'm going to first connect them to the SUPERNIGHT DC step down regulator. Doing this will allow me to verify everything works before connecting VRM/VRL to the Arduino. I am guessing when I connect them to the arduino it is gonna fry.... but I'm keeping my fingers crossed it doesn't

Do you think everything looks good now?

If this works, I'll send you $30 via paypal. It's less than the cost of another $40 Mega i would have to buy... so it's really win/win.

cr0sh:
I'm left here scratching my head over a diagram that shows "step down transformers" on the DC output of a power supply?

One is labeled "Step Down Transformer 24v to 12v" (and feeds to the Arduino barrel connector); the other is labeled "Step Down Transformer 12v to 5v" and is cascaded from the first (and feeds the motor driver).

Transformers are for AC voltages - not DC. Unless you are using something else and calling it a "transformer" (and using a transformer symbol) - trying to do so is incorrect, and you are simply feeding 24 volts (well, probably a bit less) into the Arduino.

If you are using some other component - then you need to re-draw your schematic and label the components with their proper names. Otherwise, your schematic is mostly useless to us to help us diagnose your issue.

This is what I'm using: http://www.amazon.com/SUPERNIGHT-Converter-Regulator-Voltage-Transformer/dp/B00HNOKGO6

Should I call it something else to avoid confusion?

huggybaird:

cr0sh:
I'm left here scratching my head over a diagram that shows "step down transformers" on the DC output of a power supply?

One is labeled "Step Down Transformer 24v to 12v" (and feeds to the Arduino barrel connector); the other is labeled "Step Down Transformer 12v to 5v" and is cascaded from the first (and feeds the motor driver).

Transformers are for AC voltages - not DC. Unless you are using something else and calling it a "transformer" (and using a transformer symbol) - trying to do so is incorrect, and you are simply feeding 24 volts (well, probably a bit less) into the Arduino.

If you are using some other component - then you need to re-draw your schematic and label the components with their proper names. Otherwise, your schematic is mostly useless to us to help us diagnose your issue.

This is what I'm using: http://www.amazon.com/SUPERNIGHT-Converter-Regulator-Voltage-Transformer/dp/B00HNOKGO6

Should I call it something else to avoid confusion?

I'd call it a "DC-DC converter".

To get an analogue voltage suitable for the VRM input, I think you can use a simple low-pass filter on the Arduino output. This technique is described here Arduino’s AnalogWrite – Converting PWM to a Voltage
I would use a large cap (e.g. 1uF) to smooth out ripple, I assume with a 100W motor you won't need instant speed changes (i.e <10ms)

You can connect Speed output directly to Arduino pin PWM2, and also from that pin to a resistor of 10k or 4k7 to the Arduino 5V.
A pullup resistor pulls the signal high, in case no one is pulling it low.
The Speed output is an open collector output, it can only pull the signal low.

The low pass filter can be like bobcousins wrote. Just a resistor and a capacitor. I think 4k7 and 1uF is okay. You have to test that if the speed is working smooth.

Perhaps the case of motor itself is also connected to mains-ground or earth-ground. That is okay, since you don't connect that ground to your circuit anymore :slight_smile:

I still think you should be using opto-isolators for the logic signals to motor driver.
There is no need for a direct electrical connection between the uC and the motor controller.
They should be two separate circuits isolated by the opto-couplers. The +24V power supply should only be on the motor controller side and there should only be +5V on the Mega side of the isolation barrier. If you had wired it this way to begin with there is no way you could have damaged the Mega . Needless to say, if you are going to proceed without the opto couplers make sure you measure the voltage on the wires from the motor controller BEFORE connecting them to the Mega.