0
\$\begingroup\$

I'm building an Arduino controlled crane machine out of old crane machine parts.

The motors in a crane machine are 48V DC and I am controlling them with an H-bridge configuration using an 8 channel relay module I got off eBay which is controlled by an Arduino Nano. I'm using an ATX power supply to power the system but I'm using a high power boost converter to get up to 48V for the motors.

The issue I'm having is when the motors are moving, 50% of the time the Arduino will either reset, or will skip a few lines of code, or sometimes the Arduino freezes and will keep going in one direction indefinitely.

It's only programmed to move to the centre of the cabinet, drop the claw until the down switch activates then raise the claw until it hits the top after that, it goes back to the corner, but it only rarely finishes it, usually it resets or keeps going in 1 direction.

I've tried 2 different power supplies, I tried powering the Arduino and relay module over USB, I tried 2 different Arduino Megas. When I try lowering the voltage on the boost converter, it doesn't stuff up as often and when I power it to 12V it hardly does it at all but 12V is way too slow for the motors. When there is no power at all for the motors, it doesn't reset at all, but obviously that isn't useful when you're trying to make a crane machine.

Photo of setup

Crane setup

Closer photo of arduino

\$\endgroup\$
2
  • \$\begingroup\$ H-Bridges are prone to produce a hell of a high frequency noise. The kind of noise that can lead microcontrollers to either reset or malfunction. Most of the time, mitigating the noise is just a matter of adding well placed capacitors. Do you have a schematic for the H-Bridge? Nice project, by the way. \$\endgroup\$ – jmgonet Jan 14 at 6:51
  • \$\begingroup\$ The H-bridge in this case only switches when a motor starts, stops, or changes direction. It uses relays so the typical "hell of a high frequency noise" won't be present - you can't use high frequency PWM with relays. \$\endgroup\$ – JRE Jan 14 at 7:00
1
\$\begingroup\$

There's a few things that could be causing your problems.

The most likely is that you're getting a lot of electrical noise on the digital input from the crane machine. That noise is coming into the Nano over the limit switch wires.

You have the motor power wires and the limit switch wires in one bundle from the Nano to the crane machine. The motors will cause a lot of electrical noise on the power wires. With the power wires parallel to the signal wires, some of that noise will make it to the signal wires.

You need to first reduce the amount of noise produced by the motors. There would normally be a capacitor across the motor terminals right at the motor. If there's not one there already, install like a 100 nanofarad capacitor rated for 250V (I think that's the next higher up from 50V) across the motor right at the motor.

At the Arduino end, you need to clamp anything that makes it that far. Put a small (few hundred ohms to 1 kiloohm) resistor in series with the limit switch inputs, and a small capacitor (1 nanofarad or so) from the digit input of the Nano to ground. While you are at it, put a Schottky diode from the digital pin to the Arduino 5V.

Another thing you could do is to use a shielded cable to run the limit switch wires through. A shielded cable has a braided conductor around the signal carrying wires. The braid is connected to ground. It prevents electrical noise from getting into your signal wires.

Try to neaten up your wiring - keep high current conductors away from low current signals.

Keep in mind that breadboards have very limited current carrying ability - don't use the breadboard as a junction for all of your ground wires.

Breadboards are also prone to bad contacts - vibration may cause sporadic loss of power or other connections to the Nano, resulting in erratic behaviour.

\$\endgroup\$
3
  • \$\begingroup\$ I'll try disconnecting all the switches from the Arduino and just program it to move left and right continuously and see if it resets. I'll post the result tomorrow. \$\endgroup\$ – Ramsom Jan 14 at 7:49
  • \$\begingroup\$ Yep, i just went out to test your theory and yes in fact, when all the switches are disconnected, it doesn't stuff up at all! I wrote a really simple program that just moves the crane up, down, left, right, and it didn't mess up once when the switches were unplugged, but if i plug in just one of them even though it isn't reading from them, it resets randomly again, so what's the next thing i should do to stop this nasty interference? \$\endgroup\$ – Ramsom Jan 14 at 8:35
  • \$\begingroup\$ I've already described what you need to do above. What you do first depends on what you have at hand. Capacitors on the motors, shielded cable, filter and clamp at the Arduino input. You probably need all of them. \$\endgroup\$ – JRE Jan 14 at 8:40
1
\$\begingroup\$

OK, I just want to explain what I did to fix the problem so that future people that may be reading this know what to do,

I added a 100 nanofared capacitor at the motors, this alone reduced the odds of it resetting a lot, i then added 10k ohm resistors in series with all of the inputs and now it's perfect!

\$\endgroup\$

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.