Arduino 5V relay problem

Forum for posting topics and questions about anything.
Post Reply
Alantronics
Posts: 3
Joined: Mon Apr 12, 2021 8:53 pm

Arduino 5V relay problem

Post by Alantronics » Mon Apr 12, 2021 9:21 pm

I have a positioner system with 3 stepper motors controlled by an Arduino Mega, and I just added a relay (Arduino 5V relay module HCARDU0001), to switch on a 12 V DC supply to an electromagnet.
This causes a problem with a stepper motor, as soon as I put the power to the relay the stepper motor sound changes, and after a while the sketch program crashes.
The system works fine if the 12 V DC supply to the magnet from the relay is not attached, so there seem to be no power overload issues from the supply and signal to the relay.
This seems very odd to me, as the supply to the electromagnet should be isolated from the arduino as it is going through the relay, so surely the earths etc are separate?
Any ideas welcomed! thanks, Alan

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Arduino 5V relay problem

Post by andrew » Tue Apr 13, 2021 7:55 am

The system works fine if the 12 V DC supply to the magnet from the relay is not attached, so there seem to be no power overload issues from the supply and signal to the relay.
I just need to check a few things to understand the setup a bit better...

I assume from the above comment that power is still connected to the magnet, just not via the relay?

Is the 12V supply that powers the magnet also used to power other things, i.e. the Arduino and stepper motors?

Does the stepper motor sound change right from the moment that the magnet is turned on?

If you were to replicate what the relay is doing by manually applying power to the magnet when the relay would have does the same thing happen?
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Alantronics
Posts: 3
Joined: Mon Apr 12, 2021 8:53 pm

Re: Arduino 5V relay problem

Post by Alantronics » Tue Apr 13, 2021 10:40 am

Hi, thanks for your suggestions, I have followed these, with results as below:

I assume from the above comment that power is still connected to the magnet, just not via the relay?
A: the magnet is only powered through the relay, 12 V about 0.4 A.

Is the 12V supply that powers the magnet also used to power other things, i.e. the Arduino and stepper motors?
A: No the steppers are from another 12 mains to dc transformer; I put them onto a different 13 A socket in the house to see if that made any difference, it didnt.

Does the stepper motor sound change right from the moment that the magnet is turned on?
A: Yes

If you were to replicate what the relay is doing by manually applying power to the magnet when the relay would have does the same thing happen?
A: Interesting! yes it happens even when powered directly. The motors are attached to metal runners, so there is a lot of metalwork to pick up EM spikes I guess, and when the magnet is powered on/off two of the motors pick up signal and try and step a few steps. I tried adding an earth from the mains, but on second thoughts should I take the arduino Gnd and connect that to the metalwork? With the main earth it also interferes with the motors when i splash the earth on/off.

What do you think? should I use the arduino ground? (by the way I don't think that it is the magnetic field directly, there is pickup even if the magnet is over 30 cm from the metalwork and it is only a small magnet (12 V 0.4 A) - it is fed by two non-twisted wires, perhaps I should twist these as well? )
Many thanks! Alan

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Arduino 5V relay problem

Post by andrew » Tue Apr 13, 2021 4:08 pm

I must admit at the moment I’m a bit of a loss as to what the issue could be. From what you have said it’s clearly being caused by powering the magnet which is somehow affecting the Arduino and/or the stepper motors. This would be via one of 2 ways, by transients on the power supply from the magnet being powered, or via RF interference.

For the former as you said, the magnets power supply is completely separate from the motor and the Arduino supplies and also it will be isolated via the relay so I doubt very much it’s that. Which then leaves RF interference but as you say you’ve tested the magnet a distance from the Arduino and it didn’t fix the issue. But it does sound like something is definatly upsetting the Arduino.

It is definitely worth twisting the supply wires to the magnet together as it could certainly be a source so I’d give that a try first.

If there’s nothing electrical connected to the metalwork then it shouldn’t hurt to connect a GND from the Arduino to it although I’d be surprised if that’s the problem. If you have a mains earth connected though I wouldn’t suggest doing this.

I take it the stepper motors have their own controller boards?
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Alantronics
Posts: 3
Joined: Mon Apr 12, 2021 8:53 pm

Re: Arduino 5V relay problem

Post by Alantronics » Sat Apr 17, 2021 6:39 am

Yes the steppers have their own controllers. I did try a smoothing capacitor on the magnet supply but that made it worse...then I realised later that I had put the power connector and capacitor on top of the arduino so not a good position for cross-talk! thanks for your reply, I had to give up and remove the magnet, but I may get a chance to investigate more later next week.

Post Reply

Return to “General Discussion”