Page 1 of 1

RPI reboots when powering motor with relay

Posted: Sat Dec 28, 2013 2:58 pm
by TimmR
Hi all,

I have an old PC power adapter from which I get 12v and 5v.
The 5v powers the RPI and the 12v powers a motor.

The motor is turned on and off by a relay. And the grounds
are connected.
But when I turn on the relay (and the motor) the RPI reboots.

The motor does work directly without relay when the RPI is off.

What am I doing wrong?

Re: RPI reboots when powering motor with relay

Posted: Sat Dec 28, 2013 3:00 pm
by Richard-TX
It is likely that the regulation of the power supply isn't 100%. Try powering your pi from another source. I'll bet your issue goes away.

Re: RPI reboots when powering motor with relay

Posted: Sat Dec 28, 2013 3:01 pm
by joan
You don't mention if the Pi is switching the relay. A circuit diagram would be useful.

Re: RPI reboots when powering motor with relay

Posted: Sat Dec 28, 2013 3:15 pm
by TimmR
Yeah! my first circuit diagram!
The relay is actually a relay shield (YwRobot)
The shield works fine.

And the power comes from one pc power.
Untitled.jpg
Untitled.jpg (40.43 KiB) Viewed 2971 times
The thing is that I really just want one power source.
The RPI is controlling a nerf Vulcan toy gun.

Re: RPI reboots when powering motor with relay

Posted: Sat Dec 28, 2013 5:00 pm
by TimmR
I see that the RPI stays on when I power the
motor directly, before the RPI boots and keep
the motor running.

Now, I don't have any electrical knowledge.
But could there be some spike of something
on the moment the RPI runs AND I turn on the
relay, which turns on the motor?

Re: RPI reboots when powering motor with relay

Posted: Sat Dec 28, 2013 6:15 pm
by pksato
Hi,
You diagram can be have a copy error, or really have a design error.
Theses arduino relay shield is not good to use with Raspberry Pi.
You shield is one with three pins (vcc, in and gnd) on logic side?
Like this http://www.emartee.com/product/42055
This Shield use a PNP transistor to drive relay.
If is, this shield not work proper with raspberry pi.
Shield VCC is 5V, Raspberry PI is 3v3.
If connect Shield VCC on 5V, and IN to some GPIO, relay is activated all times.
If connect Shield VCC to 3v3, and IN to GPIO, relay can apparently appears to work, but is not ideal. And, can reset raspberry pi due noise, spike, and drop on 3v3 line.
To make it work proper, need a extra circuit, a NPN (2N2222) transistor and a resistor (2k2). Connect emitter to GND, collector to IN, base to resistor, and resistor to GPIO. Shield VCC to 5V direct from PSU.

Re: RPI reboots when powering motor with relay

Posted: Sat Dec 28, 2013 7:36 pm
by TimmR
Thanks! It sure is a step forward! Now I can use the shield properly.
I've just happen to have two of each in my starterskid :P

But... the system still reboots after I switch the relay and so turn on the motor...
My uneducated guess would be a spike? Can I protect the circuit to such spikes?

Re: RPI reboots when powering motor with relay

Posted: Sun Dec 29, 2013 11:02 am
by DougieLawson
TimmR wrote: My uneducated guess would be a spike? Can I protect the circuit to such spikes?
Use opto-isolators between the RPi and the relay board.

Re: RPI reboots when powering motor with relay

Posted: Sun Dec 29, 2013 11:29 am
by johndough
TimmR wrote:Thanks! It sure is a step forward! Now I can use the shield properly.
I've just happen to have two of each in my starterskid :P

But... the system still reboots after I switch the relay and so turn on the motor...
My uneducated guess would be a spike? Can I protect the circuit to such spikes?
Hi

When a motor starts it can draw 5 to 8 times its running current. This is for a time of about 80 - 180 milliseconds.

IF the PSU is detecting this overcurrent it may be shutting down.

You can support the Pi thru this period by putting a diode in its supply, check what voltage drop you get, and adding a small reservoir of energy by adding a small capacitor.

The capacitor runs the Pi for 1 second, and the diode prevents the power going back towards the PSU.

You could have seperate power supplies as mentioned of course.

Spikes can be suppressed, the capacitor will help with smoothing out a spike but is not a suppressor.

Re: RPI reboots when powering motor with relay

Posted: Sun Dec 29, 2013 3:26 pm
by TimmR
johndough wrote:
You can support the Pi thru this period by putting a diode in its supply, check what voltage drop you get, and adding a small reservoir of energy by adding a small capacitor.

The capacitor runs the Pi for 1 second, and the diode prevents the power going back towards the PSU.
I'm trying to wrap my head around it all. Since the most impressive thing I did before this is turn on/off a led :P
I've made a circuit schematic as shown below. Is this correct?

Also, can't I just take out the relays? If the NPN transistor does about the same, right?
This would also take out two spikes caused by the relay coils, right?
And as a big plus I can imagine I could start using PWM for the DC motor.

(the power to the RPI in the diagram are connected trough the GPIO but In reallife it is connected
trough a modded usb to breadboard cable (can't find the option in Fritzing, same for P5 headers)
motor-setup-01.jpg
motor-setup-01.jpg (38.93 KiB) Viewed 2847 times
Thank you all so much for your help guys! I'm learning so much here!

Re: RPI reboots when powering motor with relay

Posted: Tue Dec 31, 2013 1:56 pm
by boyoh
What is the specifications of the relay
I/E Voltage / Current