satish.gunjal
Posts: 42
Joined: Sat May 23, 2015 11:50 am

Relay board and back emf issue

Wed Nov 07, 2018 10:49 am

I am using 5V 10A, 8 channel relay board (https://www.amazon.in/JBTek-Channel-Con ... B00KTELP3I) to exhaust fans(50W). Each relay will need 15 to 20mA current. Relay board is externally powered.

Using python script on my raspberry pi zero W. No problem starting the the exhaust fan...but the moment i stop the fan raspberry pi power-off!! May be because off back emf. As per advertised features this board is optically isolated, safe, reliable, anti-interference.

is there any way i can handle back emf issue while using such relay board?

RichG
Posts: 13
Joined: Tue Jan 27, 2015 8:17 pm

Re: Relay board and back emf issue

Wed Nov 07, 2018 12:38 pm

Has the jumper on the relay board been removed, as you are running external power?

satish.gunjal
Posts: 42
Joined: Sat May 23, 2015 11:50 am

Re: Relay board and back emf issue

Wed Nov 07, 2018 5:35 pm

RichG wrote:
Wed Nov 07, 2018 12:38 pm
Has the jumper on the relay board been removed, as you are running external power?
Yes(JD-VCC & VCC are not connected by jumper). Connections are as below.

Connected +ve wire of external power supply to JD-VCC pin of 8 Channel relay
Connected -ve wire of external power supply to Ground pin of 8 channel relay
Connected jumper cable to VCC of 8 channel relay and 3.3V of RPI.

Pedro_Lopes
Posts: 30
Joined: Thu Nov 03, 2016 10:04 am
Contact: Website Twitter

Re: Relay board and back emf issue

Wed Nov 07, 2018 5:42 pm

Without the fan's connected to the relay, do you have the same problem?
https://www.hackster.io/pedromflopes

User avatar
Imperf3kt
Posts: 2120
Joined: Tue Jun 20, 2017 12:16 am
Location: Australia

Re: Relay board and back emf issue

Wed Nov 07, 2018 8:38 pm

Are you overloading the GPIO? The maximum limit per GPIO is 16mA, with a maximum limit across all GPIO together being no more than 50mA
Google is ubiquitous - Try it today, it's free!
https://opensource.com/life/16/10/how-ask-technical-questions

satish.gunjal
Posts: 42
Joined: Sat May 23, 2015 11:50 am

Re: Relay board and back emf issue

Thu Nov 08, 2018 1:43 am

Pedro_Lopes wrote:
Wed Nov 07, 2018 5:42 pm
Without the fan's connected to the relay, do you have the same problem?
No. Without fan relay board works fine.

satish.gunjal
Posts: 42
Joined: Sat May 23, 2015 11:50 am

Re: Relay board and back emf issue

Thu Nov 08, 2018 1:57 am

Imperf3kt wrote:
Wed Nov 07, 2018 8:38 pm
Are you overloading the GPIO? The maximum limit per GPIO is 16mA, with a maximum limit across all GPIO together being no more than 50mA
I don't think so. Relay board works fine without fan connected. I have switched on all the 8 channels on 5V 10A relay board and 1 channel on 5V 30A relay board for 1 minute without any issue. Both relay board connected to raspberry pi zero and externally powered.

klricks
Posts: 6304
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Relay board and back emf issue

Thu Nov 08, 2018 2:19 am

satish.gunjal wrote:
Thu Nov 08, 2018 1:43 am
Pedro_Lopes wrote:
Wed Nov 07, 2018 5:42 pm
Without the fan's connected to the relay, do you have the same problem?
No. Without fan relay board works fine.
OK you only did half of the test.
Now with the RPi and relay running, power on and off the fan without using the relay board and see if that works OK.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

satish.gunjal
Posts: 42
Joined: Sat May 23, 2015 11:50 am

Re: Relay board and back emf issue

Thu Nov 08, 2018 8:23 am

@klricks

test setup:
# 50W fan connected to 'NC' and 'COM' pins of relay board
# Relay board and RPi started
# python script is stopped. Not controlling the relay from RPi

Now if I stop the fan EVERY TIME RPi stops!!

one more thing i observed...

I am also using Adafruit powerboost 1000C with below circuit and python script to start and stop the RPi.
Whenever i change the fan speed using regulator sometimes it used to trigger the shutdown!!

Code: Select all

# Setup the GPIO pin to use with the use shutdown button

user_shutdown_pin = 26
user_shutdown_setup(user_shutdown_pin)

def user_shutdown_setup(shutdown_pin):
    # setup the pin to check the shutdown switch - use the internal pull down resistor
    GPIO.setup(shutdown_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

    # create a trigger for the shutdown switch
    GPIO.add_event_detect(shutdown_pin, GPIO.RISING, callback=user_shutdown, bouncetime=1000)

# User has pressed shutdown button - initiate a clean shutdown
def user_shutdown(channel):
    global safe_mode
        
    shutdown_delay = 10 # seconds
    logger.info("user_shutdown()>shutdown request received")

    # in Safe Mode, wait 2 mins before actually shutting down
    if(safe_mode):
        logger.info("user_shutdown()>System shutting down(user request) in 2 minutes - SAFE MODE")
        cmd = "sudo wall 'System shutting down(user request) in 2 minutes - SAFE MODE'"
        os.system(cmd)
        time.sleep(120)

    logger.info("user_shutdown()>System shutting down(user request) in %d seconds" % shutdown_delay)
    cmd = "sudo wall 'System shutting down(user request) in %d seconds'" % shutdown_delay
    os.system(cmd)
    time.sleep(shutdown_delay)

    # Log message is added to /var/log/messages
    os.system("sudo logger -t 'pi_power' '** User initiated shut down **'")
    GPIO.cleanup()
    os.system("sudo shutdown now")
Image
Last edited by satish.gunjal on Fri Nov 09, 2018 8:16 am, edited 1 time in total.

Pedro_Lopes
Posts: 30
Joined: Thu Nov 03, 2016 10:04 am
Contact: Website Twitter

Re: Relay board and back emf issue

Thu Nov 08, 2018 10:11 am

satish.gunjal wrote:
Thu Nov 08, 2018 1:43 am
Pedro_Lopes wrote:
Wed Nov 07, 2018 5:42 pm
Without the fan's connected to the relay, do you have the same problem?
No. Without fan relay board works fine.
If without FAN's connected works fine, it's not EMF issue. Are you using the same power supply for FAN's and Raspberry Pi? If yes, try with separated power supply.
https://www.hackster.io/pedromflopes

satish.gunjal
Posts: 42
Joined: Sat May 23, 2015 11:50 am

Re: Relay board and back emf issue

Thu Nov 08, 2018 1:50 pm

@Pedro_Lopes

My setup is as below:
5V 2A wall adapter powering Adadfruit powerboost 1000C. Output from powerboost connected to USB hub. And from USB hub i am powering RPi and two relay boards.

Max current consumption is less than 700mA. And powerboost can supply 1A.

Please correct me if i am wrong... Relay board is only handling the back EMF from relay switching but the back EMF from the FAN is not handled, which is affecting the RPi.

Pedro_Lopes
Posts: 30
Joined: Thu Nov 03, 2016 10:04 am
Contact: Website Twitter

Re: Relay board and back emf issue

Thu Nov 08, 2018 5:08 pm

Yes, i think you are correct, but your relay board should provide isolation.

Try connecting a optocoupler to the GPIO, and drive the relay through the optocoupler. This way you will be 100% sure that the GPIO is isolated from the relay coil.
https://www.hackster.io/pedromflopes

satish.gunjal
Posts: 42
Joined: Sat May 23, 2015 11:50 am

Re: Relay board and back emf issue

Fri Nov 09, 2018 7:54 am

I am beginner and i haven't used optocoupler as of now ...
attached the sketch of my setup with PC817. Since i am using USB hub, will it still qualify as separate power supply for relay board?

Image

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

Re: Relay board and back emf issue

Fri Nov 09, 2018 10:14 am

satish.gunjal wrote:
Fri Nov 09, 2018 7:54 am
I am beginner and i haven't used optocoupler as of now ...
attached the sketch of my setup with PC817. Since i am using USB hub, will it still qualify as separate power supply for relay board?

Image

You have the Pi 5v from the Power bank, Use a 5v power adapter
To feed the Pi ,don't common the grounds, The opto isolator will keep
Both power supply's isolated. Then run the system to see if you get
The problem when you stop the fans, This might help,to find the problem.

Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

satish.gunjal
Posts: 42
Joined: Sat May 23, 2015 11:50 am

Re: Relay board and back emf issue

Fri Nov 09, 2018 12:40 pm

boyoh wrote:
Fri Nov 09, 2018 10:14 am
satish.gunjal wrote:
Fri Nov 09, 2018 7:54 am
I am beginner and i haven't used optocoupler as of now ...
attached the sketch of my setup with PC817. Since i am using USB hub, will it still qualify as separate power supply for relay board?

Image

You have the Pi 5v from the Power bank, Use a 5v power adapter
To feed the Pi ,don't common the grounds, The opto isolator will keep
Both power supply's isolated. Then run the system to see if you get
The problem when you stop the fans, This might help,to find the problem.

Regards BoyOh
Is my optocoupler connections correct?
What do you mean by "don't common the grounds"
If i understand you correctly i shouldn't use USB hub and power the relay from powerbank and RPi from powerboost

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

Re: Relay board and back emf issue

Sat Nov 10, 2018 4:17 pm

Yes your Opto Circuit is correct. What I am trying to do is take you through the process of elimination

First what I mean by not common the Ground 0-v is as follows Pi ground 0-v--------X-------ground 0v--Battery Power

When using opto isolators you don't need any return connection back to the Pi

Do you have any other connections from the Pi to your project, How do you stop the fans

Try using a separate power supply as temporary measure for the Pi.

My advice do some reading on electronics and some bread Board work


Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

drgeoff
Posts: 9203
Joined: Wed Jan 25, 2012 6:39 pm

Re: Relay board and back emf issue

Sat Nov 10, 2018 4:31 pm

boyoh wrote:
Sat Nov 10, 2018 4:17 pm
When using opto isolators you don't need any return connection back to the Pi
That's badly worded and may not convey what boyoh meant.

Any circuit requires two connections. The opto is no exception. It's input side requires a "go" and "return" from the RPi. However the output side of the opto and everything else it is electrically connected to does not require any electrical connection to the opto's input side ie the RPi. That is the whole point of an optocoupler.

satish.gunjal
Posts: 42
Joined: Sat May 23, 2015 11:50 am

Re: Relay board and back emf issue

Mon Nov 12, 2018 8:08 am

boyoh wrote:
Sat Nov 10, 2018 4:17 pm
Yes your Opto Circuit is correct. What I am trying to do is take you through the process of elimination

First what I mean by not common the Ground 0-v is as follows Pi ground 0-v--------X-------ground 0v--Battery Power

When using opto isolators you don't need any return connection back to the Pi

Do you have any other connections from the Pi to your project, How do you stop the fans

Try using a separate power supply as temporary measure for the Pi.

My advice do some reading on electronics and some bread Board work


Regards BoyOh
I am using relay board to stop the fan. From pi relay board signal pins and 'BAT' and 'EN' pins of Adafruit powerboost are connected.
I have tried this circuit on breadboard issues are random mostly because of the back EMF from fan.

satish.gunjal
Posts: 42
Joined: Sat May 23, 2015 11:50 am

Re: Relay board and back emf issue

Mon Nov 12, 2018 8:26 am

few more observations

For my RPi shutdown setup i am using GPIO 26. I have trigger setup to shutdown the RPi if user press button for more than 3 seconds.


Observation#1. if fan is started and stopped withing 2 minutes. Most of the time i receive the trigger on GPIO 26. I am only monitoring GPIO 26 not sure if other GPIO's are also receiving such trigger.

Observation#2. if fan is started and stopped after 10 minutes. Every-time RPi power off!! Since input power is received through powerboost, I suspect the Powerboost is experiencing some kind of voltage spike.

I will try to separate the RPi and relay board power supply and test it. also planning to add a large (at least 1000uF) capacitor between the PowerBoost's Vs pin and GND.

Return to “Beginners”