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
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.
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.
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.
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.
... 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?
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?
... 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.
The current paths are:
VCC to opto inputto GNDon the right-hand connector, switched by the two control pins.
JD_VDD to GND on the left-hand connector, switched by the opto outputs.