0
\$\begingroup\$

I have a robot with several servos controlled by an arduino. Also attached is an electric airsoft gun, which draws considerable current. The gun is on an independent circuit with a separate battery pack. The arduino is connected to a relay which controls the gun.

The gun is on a physically separate circuit from the arduino and servos.

The problem is that when the gun is fired, all of the servos move toward their 0 position. This doesn't make sense to me, because the gun circuit is not connected to the servo-arduino circuit.

Why is this happening, and how can I fix it?

\$\endgroup\$
  • 1
    \$\begingroup\$ Try to disconnect the gun's battery and test if the problem persists (servos return to zero spuriously). If yes, the problem is software or on the command side of the relay. If no, the problem is some feedback from the contact side of the relay to the other; could be mechanical (vibration of the soft gun creates temporary open circuit), inductive.. \$\endgroup\$ – fgrieu Mar 28 '15 at 15:32
  • \$\begingroup\$ It's called electromagnetic interference (EMI). Mitigating it is a very broad topic, but start by adding shielding (metal enclosures and shielded cables) and shortening/rerouting wiring. \$\endgroup\$ – Dave Tweed Mar 28 '15 at 15:33
  • 1
    \$\begingroup\$ @fgrieu I've done that and the problem does persist. \$\endgroup\$ – ItsTimmy Mar 28 '15 at 15:33
  • 1
    \$\begingroup\$ If the problem persists with the gun's battery disconnected, then the problem lies between the relay and the Arduino. Show us exactly how that's wired. It sounds like inductive kickback might be resetting the CPU. \$\endgroup\$ – Dave Tweed Mar 28 '15 at 15:35
2
\$\begingroup\$

If the airsoft gun thing is on a seperate circuit and galvanically isolated from the Arduino then it's possible that the arduino is getting reset/corrupted by magnetic induction. This is quite common when the wiring between the two circuits are in close proximity and the current taken by one circuit is high and pulse like.

It's the same principal for an AC transformer; the primary winding generates a voltage on the secondary due to the magnetization current in the primary. With loosely connected windings the voltage is less of course but with a bigger primary magnetization current the voltage induced gets bigger.

Here's a picture showing a bad cable method and a good cabling method: -

enter image description here

And another showing how fields cancel on twisted wires: -

enter image description here

Twisting wires that carry heavy pulses of currents (or AC) reduces the emission to other wires. Twisting wires that might be susceptible to EMI improves their ability to withstand interference. Best practise is do both.

\$\endgroup\$
  • \$\begingroup\$ I don't think there's much point in elaborating further on this answer, since the OP has already said that the problem occurs even if the motor power is removed altogether. \$\endgroup\$ – Dave Tweed Mar 28 '15 at 16:17

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.