TimmR
Posts: 34
Joined: Thu Apr 11, 2013 11:12 am

RPI reboots when powering motor with relay

Sat Dec 28, 2013 2:58 pm

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?

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: RPI reboots when powering motor with relay

Sat Dec 28, 2013 3:00 pm

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.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
joan
Posts: 15038
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: RPI reboots when powering motor with relay

Sat Dec 28, 2013 3:01 pm

You don't mention if the Pi is switching the relay. A circuit diagram would be useful.

TimmR
Posts: 34
Joined: Thu Apr 11, 2013 11:12 am

Re: RPI reboots when powering motor with relay

Sat Dec 28, 2013 3:15 pm

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 2963 times
The thing is that I really just want one power source.
The RPI is controlling a nerf Vulcan toy gun.

TimmR
Posts: 34
Joined: Thu Apr 11, 2013 11:12 am

Re: RPI reboots when powering motor with relay

Sat Dec 28, 2013 5:00 pm

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?

pksato
Posts: 295
Joined: Fri Aug 03, 2012 5:25 pm
Location: Brazil

Re: RPI reboots when powering motor with relay

Sat Dec 28, 2013 6:15 pm

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.

TimmR
Posts: 34
Joined: Thu Apr 11, 2013 11:12 am

Re: RPI reboots when powering motor with relay

Sat Dec 28, 2013 7:36 pm

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?

User avatar
DougieLawson
Posts: 39788
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: RPI reboots when powering motor with relay

Sun Dec 29, 2013 11:02 am

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.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

johndough
Posts: 254
Joined: Sun Jan 13, 2013 2:00 pm

Re: RPI reboots when powering motor with relay

Sun Dec 29, 2013 11:29 am

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.

TimmR
Posts: 34
Joined: Thu Apr 11, 2013 11:12 am

Re: RPI reboots when powering motor with relay

Sun Dec 29, 2013 3:26 pm

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 2839 times
Thank you all so much for your help guys! I'm learning so much here!
Attachments
motor-setup-01.fzz.zip
just in case
(11.43 KiB) Downloaded 62 times

boyoh
Posts: 1505
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: RPI reboots when powering motor with relay

Tue Dec 31, 2013 1:56 pm

What is the specifications of the relay
I/E Voltage / Current
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

Return to “Beginners”