Author Topic: Relay modual where GND turn on relays how to hook up to transistor?  (Read 5092 times)

0 Members and 1 Guest are viewing this topic.

Offline BeaminTopic starter

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
I got these Chinese relay modual that have 4 inputs GND CH1 CH2 and VCC.

When you power it up the relays stay open when you hook the ground of the power supply to CH 1 or 2 it activates the relays.

So if I want to use these with an Arduino do I need to build some sort of voltage divider circuit to use them? Whats strange is that when GND in not connected to CH1 nothing happens but when GND is connected the relay turns on. Shouldn't this configuration turn on when there is No connection as well? It appears to have two of those opto isolators on the board.

If I have an Arduino connected the out put has high or low. How does this board know the difference between low and no connection?

What if I wanted to control it with transistors would I need jfets?
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 

Offline KMoffett

  • Regular Contributor
  • *
  • Posts: 96
  • Country: us
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #1 on: October 20, 2017, 08:08:18 pm »
Please post a link to the module for spec's. NPN transistor or logic level Mosfet. Collector (drain) to CH1 or CH2 and emitter (source) to ground. Resistor from transistor base to Arduino I/O. No gate resistor needed for Mosfet.  I/O high turns on module relay.

Ken
« Last Edit: October 20, 2017, 08:12:30 pm by KMoffett »
 

Offline BeaminTopic starter

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #2 on: October 20, 2017, 09:39:11 pm »
Please post a link to the module for spec's. NPN transistor or logic level Mosfet. Collector (drain) to CH1 or CH2 and emitter (source) to ground. Resistor from transistor base to Arduino I/O. No gate resistor needed for Mosfet.  I/O high turns on module relay.

Ken

Yeah I don't have any info about it. I bought it online with some broken English about "100% happy technetium good product to use our product"

The relays work off 5 volts; has dual optos and two resistors on the circuit board which is black so it's no help. I tried reversing the polarity and my psu just cuts off with a over current limit fault.
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 

Offline frog

  • Contributor
  • Posts: 42
  • Country: nz
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #3 on: October 20, 2017, 10:02:31 pm »
Essentially from what you are saying, one end of the relay coil is connected to 5v all the time, and when you connect the GND terminal to GND it completes the circuit and operates the relay - have I got that right?
So if you want to switch this with an Arduino you may be able to do so directly (if it's opto isolated then the Arduino IO pin may be able to supply enough current to operate it).  Otherwise you'll need a transistor - either NPN bipolar or N-channel FET will do.  In the case of a FET you'd connect the gate to the Arduino IO, the drain to the relay GND terminal and the source to your power supply GND.  If you're using a bipolar then you'll need a resistor (about 10k) between the Arduino UI and the base, the collector goes to the relay and emitter to PSU GND.
I'm not sure what voltage is applied to the 'high' side of the opto, if this is higher than 5v then *don't* try connecting directly to your Arduino, you'll definitely need a transistor.  Hope that helps.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #4 on: October 20, 2017, 10:27:15 pm »
The best, sharpest colour closeup  photos  you can manage (subject to the forum's 400K attachment size limit) of both sides of the board would help.  Try bright oblique lighting so there is some chance of seeing the track edges under the black solder resist.  We may need some measurements taken to confirm the connections, but even with black solder resist we should be able to come up with a schematic.
 

Offline BeaminTopic starter

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #5 on: October 20, 2017, 11:32:12 pm »
Reversing that jumper causes it to short. Reversing the + and- and the jumper causes the modual not to work.

EDit: getting better pics
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 

Offline BeaminTopic starter

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #6 on: October 20, 2017, 11:36:54 pm »
mwoar.
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 

Offline frog

  • Contributor
  • Posts: 42
  • Country: nz
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #7 on: October 20, 2017, 11:41:28 pm »
That looks very much like you should be able to drive it directly from your Arduino, the optos appear to have the appropriate resistors on-board and there's what looks like an additional transistor to drive the relay coil and a freewheel diode.
 

Offline frog

  • Contributor
  • Posts: 42
  • Country: nz
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #8 on: October 20, 2017, 11:43:35 pm »
So you'd connect your 5V supply to VCC, GND to GND and then use the arduino to drive CH1 and CH2 low when you want to activate either relay.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #9 on: October 20, 2017, 11:56:37 pm »
I think the header with the jumper on allows you to separate the Vdd to the optocoupler inputs from Vdd to the relays (JD-Vdd).  That would let you run the optos from an Arduino and use an external supply for the relay coils.   

That looks very much like you should be able to drive it directly from your Arduino, the optos appear to have the appropriate resistors on-board and there's what looks like an additional transistor to drive the relay coil and a freewheel diode.
So you'd connect your 5V supply to VCC, GND to GND and then use the arduino to drive CH1 and CH2 low when you want to activate either relay.
Maybe, maybe not.  I would suggest checking the connections with a DMM on continuity.   Start from IN2 and see which pin of which opto it connects to.  From the same side of the same opto trace where the other pin goes to, and so on till you've figured out how R4 and LED 'IN2' are connected. Check the opto input side and the LED with the DMM on diode test (hopefully it goes up to 2V on that range) to get the polarity.  I suspect they are all in series and Frog is correct, but lets prove it.

Also, what's marked on the relays, what model are the optos and what are the resistor values?

Caution: clearances don't look adequate for mains use - I wouldn't care to use the relays for switching more than 50V AC, or their max DC V rating.
« Last Edit: October 21, 2017, 12:17:25 am by Ian.M »
 

Offline BeaminTopic starter

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #10 on: October 21, 2017, 12:04:35 am »
So when the Arduino goes low its connecting the Arduino IO pin to ground? This has me confused as to why they don't activate with no connection AND ground state. Rather they only activate with ground but not with NC. Why would you make a device like this? Seems stupid and overly complicated for a general purpose unit. But then again I don't really understand Asian culture even though I have lived and worked with Asian people for years and my family married into Asian people. They are superstious so maybe it has something to do with bad luck.

I am rereading the above post to figure out what you mean.
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #11 on: October 21, 2017, 12:22:50 am »
My suspicion is that there is the opto input LED, a resistor, and the visible indicator LED all in series, with the anode of the indicator LED to Vdd and the cathode of the opto LED to the input pin.  In that case connecting an Arduino and outputting '0' would turn the relay on, and outputting '1' would turn it off.  NC or Arduino pin set as input doesn't piut any current through the opto's LED so is also off.   However till you do some testing, I'm just guessing.
 

Offline frog

  • Contributor
  • Posts: 42
  • Country: nz
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #12 on: October 21, 2017, 03:31:19 am »
So when the Arduino goes low its connecting the Arduino IO pin to ground? This has me confused as to why they don't activate with no connection AND ground state. Rather they only activate with ground but not with NC. Why would you make a device like this? Seems stupid and overly complicated for a general purpose unit. But then again I don't really understand Asian culture even though I have lived and worked with Asian people for years and my family married into Asian people. They are superstious so maybe it has something to do with bad luck.

I am rereading the above post to figure out what you mean.

The key thing to understand is that a disconnected input is not the same as a grounded input.  In this case it seems likely that the other end of the opto is connected via a resistor to 5v.  If the other end is disconnected then no current will flow, if it's grounded then current will flow and the relay will be activated.
 
The following users thanked this post: tooki, Beamin

Offline BeaminTopic starter

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #13 on: October 21, 2017, 12:56:42 pm »
So if I want to hook an Arduino to it (Arduino runs off of computer power; module runs off power supply) do I have to tie the grounds together: connect the ground pin of the Arduino to the power supply - lead  then hook pin 13 (or what ever my io pin is) to the ch1 relay pin? Then alternate the pin 13 between high and low? What would happen if the ground weren't tied together would it do nothing? I'm always apprehensive about this stuff( rather just plug it in and see what happens) because I don't want to blow up my Arduino or USB port on the computer.
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #14 on: October 21, 2017, 01:41:49 pm »
Its a rather daggy design.  The whole point of optocouplers is to avoid the need to join power rails and/or grounds, but that board takes both 5V and ground from the input side to the output side, making the optocouplers pretty much useless if you wire it the obvious way and leave the jumper in place.   It would have been much better with a 2 pin connector for power and a 4 pin input connector with a Anode and Cathode pin for each opto allowing you to configure them as active high or active low.

It does let you disconnect  the 5V and the Ground isn't actually needed by the input side, so you can get isolation from it, *IF* you wire it right:
  • Remove the jumper and connect 5V and Gnd from a PSU to the 3 pin connector outer pins, JD-VCC and GND. *DO* *NOT* connect the middle pin (VCC).
    .
  • The Arduino 5V will connect to VCC on the 4 pin connector and I/O pins to IN1 and IN2. *DO* *NOT* connect GND.
 

Offline BeaminTopic starter

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #15 on: October 21, 2017, 02:41:11 pm »
Its a rather daggy design.  The whole point of optocouplers is to avoid the need to join power rails and/or grounds, but that board takes both 5V and ground from the input side to the output side, making the optocouplers pretty much useless if you wire it the obvious way and leave the jumper in place.   It would have been much better with a 2 pin connector for power and a 4 pin input connector with a Anode and Cathode pin for each opto allowing you to configure them as active high or active low.

It does let you disconnect  the 5V and the Ground isn't actually needed by the input side, so you can get isolation from it, *IF* you wire it right:
  • Remove the jumper and connect 5V and Gnd from a PSU to the 3 pin connector outer pins, JD-VCC and GND. *DO* *NOT* connect the middle pin (VCC).
    .
  • The Arduino 5V will connect to VCC on the 4 pin connector and I/O pins to IN1 and IN2. *DO* *NOT* connect GND.

Connect like this?
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #16 on: October 21, 2017, 03:28:28 pm »
No.  You are linking the PSU and the arduino if you wire it as your post above.

Start by removing the yellow jumper.  Its worth checking on your DMM that there is near infinite resistance between all of the PSU pins and the pins going to the Arduino, to be certain I've interpreted the PCB layout correctly.  Once that's confirmed, use the diagram below.

N.B if you are using a high-end 3.3V logic Arduino, check that IN1 and IN2 are NOT over 3.3V on a DMM, black lead to Arduino Gnd, with 5V from the Arduino connected to VCC, *BEFORE* connecting IN1 and IN2 to the Arduino outputs.  If they are, feed Vcc with 3.3V instead of 5V and confirm the relays switch properly at that input voltage when you ground IN1 and IN2.
« Last Edit: October 21, 2017, 03:33:18 pm by Ian.M »
 

Offline BeaminTopic starter

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #17 on: October 21, 2017, 07:28:35 pm »
No.  You are linking the PSU and the arduino if you wire it as your post above.

Start by removing the yellow jumper.  Its worth checking on your DMM that there is near infinite resistance between all of the PSU pins and the pins going to the Arduino, to be certain I've interpreted the PCB layout correctly.  Once that's confirmed, use the diagram below.

N.B if you are using a high-end 3.3V logic Arduino, check that IN1 and IN2 are NOT over 3.3V on a DMM, black lead to Arduino Gnd, with 5V from the Arduino connected to VCC, *BEFORE* connecting IN1 and IN2 to the Arduino outputs.  If they are, feed Vcc with 3.3V instead of 5V and confirm the relays switch properly at that input voltage when you ground IN1 and IN2.


So that is checking to see that the relay board is not feeding 5V back into the Arduino instead of 3.3? If its feeding in 5V that will blow up the Arduino? This whole GND to turn things on is a stupid design if you ask me, but its a good way to learn how to do things(or how not to do things). So when they were creating this relay board why would they chose to have GND turn this on instead of +5V? Bad design or is there some application where this is a good idea?
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #18 on: October 21, 2017, 08:13:07 pm »



... Its worth checking on your DMM that there is near infinite resistance between all of the PSU pins and the pins going to the Arduino, to be certain I've interpreted the PCB layout correctly. ...

N.B if you are using a high-end 3.3V logic Arduino, check that IN1 and IN2 are NOT over 3.3V on a DMM, black lead to Arduino Gnd, with 5V from the Arduino connected to VCC, *BEFORE* connecting IN1 and IN2 to the Arduino outputs.  If they are, feed Vcc with 3.3V instead of 5V and confirm the relays switch properly at that input voltage when you ground IN1 and IN2.

So that is checking to see that the relay board is not feeding 5V back into the Arduino instead of 3.3? If its feeding in 5V that will blow up the Arduino?

The first check is to see if the optocouplers are doing their job and isolating the relay coil drivers from the Arduino.  If not, and the extra 5V PSU is grounded and the Arduino is PC powered, then yes, there is a (small) risk of damage to the Arduino and even to the PC.  Its fairly minimal if the PSU ground is strapped to the PC chassis ground, but that may be impractical for compact form factor PCs, tablets and laptops.

The note in italics is *ONLY* applicable if you are using a 3.3V logic Arduino. Most Atmega based Arduinos run at 5V.   If in doubt, set an I/O pin to output high and measure it!  I did forget that some low power 8MHz boards also run at 3.3V, so its not just the high end ones.

This whole GND to turn things on is a stupid design if you ask me, but its a good way to learn how to do things(or how not to do things). So when they were creating this relay board why would they chose to have GND turn this on instead of +5V? Bad design or is there some application where this is a good idea?

They did it that way because the higher charge carrier mobility of electrons in N type silicon (v.s. holes in P type silicon) means NPN transistors and N channel MOSFETs have better specs (for the same physical dimensions and similar doping profiles) than PNP transistors and P channel MOSFETs.   This means that many logic chips and MCUs can sink more current with less voltage drop when an output is driving low than they can source when its driving high.  In practice, chip designers do a lot of fiddling to try and balance the performance mismatch, e.g. larger area and different geometries for the high side devices.

Bipolar TTL is a special case - its particularly difficult to get a decent PNP transistor in the silicon process technologies it used, so most gates used a Totem Pole output stage  which has very limited capability to drive high and never reaches the Vcc rail.

Therefore  LEDs or similar loads are usually (but not always)  driven by active low logic.  Sometimes other considerations dominate - e.g. logic families with little performance difference between the output levels, or for demo boards for novice student use, it may be worth trading off brightness against the need to explain inversion due to the issues above.
 

Offline BeaminTopic starter

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #19 on: October 21, 2017, 10:13:21 pm »



... Its worth checking on your DMM that there is near infinite resistance between all of the PSU pins and the pins going to the Arduino, to be certain I've interpreted the PCB layout correctly. ...

N.B if you are using a high-end 3.3V logic Arduino, check that IN1 and IN2 are NOT over 3.3V on a DMM, black lead to Arduino Gnd, with 5V from the Arduino connected to VCC, *BEFORE* connecting IN1 and IN2 to the Arduino outputs.  If they are, feed Vcc with 3.3V instead of 5V and confirm the relays switch properly at that input voltage when you ground IN1 and IN2.

So that is checking to see that the relay board is not feeding 5V back into the Arduino instead of 3.3? If its feeding in 5V that will blow up the Arduino?

The first check is to see if the optocouplers are doing their job and isolating the relay coil drivers from the Arduino.  If not, and the extra 5V PSU is grounded and the Arduino is PC powered, then yes, there is a (small) risk of damage to the Arduino and even to the PC.  Its fairly minimal if the PSU ground is strapped to the PC chassis ground, but that may be impractical for compact form factor PCs, tablets and laptops.

The note in italics is *ONLY* applicable if you are using a 3.3V logic Arduino. Most Atmega based Arduinos run at 5V.   If in doubt, set an I/O pin to output high and measure it!  I did forget that some low power 8MHz boards also run at 3.3V, so its not just the high end ones.

This whole GND to turn things on is a stupid design if you ask me, but its a good way to learn how to do things(or how not to do things). So when they were creating this relay board why would they chose to have GND turn this on instead of +5V? Bad design or is there some application where this is a good idea?

They did it that way because the higher charge carrier mobility of electrons in N type silicon (v.s. holes in P type silicon) means NPN transistors and N channel MOSFETs have better specs (for the same physical dimensions and similar doping profiles) than PNP transistors and P channel MOSFETs.   This means that many logic chips and MCUs can sink more current with less voltage drop when an output is driving low than they can source when its driving high.  In practice, chip designers do a lot of fiddling to try and balance the performance mismatch, e.g. larger area and different geometries for the high side devices.

Bipolar TTL is a special case - its particularly difficult to get a decent PNP transistor in the silicon process technologies it used, so most gates used a Totem Pole output stage  which has very limited capability to drive high and never reaches the Vcc rail.

Therefore  LEDs or similar loads are usually (but not always)  driven by active low logic.  Sometimes other considerations dominate - e.g. logic families with little performance difference between the output levels, or for demo boards for novice student use, it may be worth trading off brightness against the need to explain inversion due to the issues above.

So the purpose of the opto couplers is that they are running the relay coils off the five volts that powers the relay board and not your device you have plugged into it. What I never understood is if the relay board and the Arduino don't have a common ground how you run the board with just the io pins hooked up? I would think the current would have no place to go since the opto couplers are isolating the two sections.
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 

Offline frog

  • Contributor
  • Posts: 42
  • Country: nz
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #20 on: October 21, 2017, 10:28:43 pm »
Looking at the last photo I'd say that JD_VDD and its corresponding ground provide the power to drive the relay coils.  This is all on the output of the optocouplers.  The connector on the right has VCC, GND and two signals which all correspond to the inputs to the optocouplers.  So unless you connect the GNDs together, the two supplies can be completely isolated.

I had assumed that you were using a 5V Arduino, in which case you might as well share a supply, but if you have a 3.3v device then you'll want 3.3 on the VCC of the right-hand connector.

The current paths are:
VCC to opto input to GND on the right-hand connector, switched by the two control pins.
JD_VDD to GND on the left-hand connector, switched by the opto outputs.

I hope that helps a little.
 
The following users thanked this post: Beamin

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Relay module where GND turn on relays how to hook up to transistor?
« Reply #21 on: October 21, 2017, 11:21:45 pm »
Errr..... not quite.
The current paths are:
VCC to opto input to GND on the right-hand connector, switched by the two control pins.
JD_VDD to GND on the left-hand connector, switched by the opto outputs.
I think the relay board has one of three possible circuits - see below (only one relay and optocoupler shown). All have similar function.

The input current flows from the Arduino 5V supply (or 3.3V for a low voltage Arduino) to VCC then through the opto input LED circuit (and maybe the indicator LED), then from INx back to the Arduino output pin and via the MCU to Arduino Gnd.

The relay coil current flows from J1-VCC via the relay coil and transistor to GND.  The transistor base current flows via the optocoupler phototransistor (output side), and comes from either VCC via a resistor and possibly the indicator LED or (#2) from the transistor collector circuit, though that would have higher voltage drop.

#1 is less likely because of the two LEDs in series - it would make it less likely to work well on 3.3V logic levels.  #2 may have problems pulling in the relay if JD-VDD is a bit low and the control logic needs to be able to sink more current, so I believe #3 is the most probable.

In *ALL* of them there is no connection required between the Arduino supply (and Gnd) and the relay coil supply and ground.
« Last Edit: October 22, 2017, 12:11:39 am by Ian.M »
 

Offline frog

  • Contributor
  • Posts: 42
  • Country: nz
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #22 on: October 21, 2017, 11:59:46 pm »
I'd assumed that the transistors are driving the optos rather than the other way round; many of the optos I've used need several mA to switch, and an IO pin might struggle.  But yes the LED and opto are most likely in series for the reasons you've stated.
 

Offline BeaminTopic starter

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #23 on: October 22, 2017, 04:05:58 pm »
better pics (posting this for 6 time because the forum is being dumb)
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 

Offline BeaminTopic starter

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Relay modual where GND turn on relays how to hook up to transistor?
« Reply #24 on: October 22, 2017, 04:08:28 pm »
another (forum makes me post each one: size too big)
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf