Are capacitors needed with optocouplers?

I am building a large hydroponics controller and I expect to use most of the Megas pins. Another forum member PMed me and expressed his concern for my lack of capacitors among other things which has me second guessing most of my project. For starters, I have one of the Sainsmart 8 channel relays, and each relay/channel is outfitted with an optocoupler to isolate the arduinos digital pin. Well this other member suggested that the optocouplers don't protect the 5V and GND feeds from the MC. Most of the relays will switch small loads of roughly 1A @ 120VAC, however, 2 of the relays will be assigned to 5A loads @ 120VAC. So does that relay circuit need a capacitor to keep noise from feeding back up the 5V lines, or for decoupling purposes? If yes, generally what size caps would you suggest?

Also, I built an 8 head peristaltic dosing pump unit that uses 12V motors. This unit is a combination of 2 other units that I bought off the web that each has 4 pumps, well I just combined those two units into a single, and used one of the enclosures as my project box, but I also didn't use any of their circuitry as I want to use the pumps with my arduino and not their setup. Anyways, their circuit has a few caps, plus some other smaller SMD caps. The circuit I was planning to build to control those pumps, will likely be the same circuit I build to control my solenoid valves. That circuit is what is shown in THIS tutorial here on Arduino.cc. It is a simple TIP120(NPN) circuit that uses an N4001 diode across the motors (+/-), multiplied by 8 for each motor. I actually already built said circuits on a solderable perf board, but my solder joints were awful, so I ordered and received new materials to rebuild it. However, I hope to iron out these issues before applying any solder. FWIW, I also ordered a better magnifying glass that has a built in light on a swing arm so the next time I solder, I will be able to get clean joints and make solid connections.

If it's not already obvious, I am a newbie that has been trying to learn Arduino stuff as it relates to my project for nearly 2 years. I was more confident working with mains voltages prior to getting into Arduino stuff, but now I feel a lot more comfortable playing around with DC stuff. That said though, a lot is still new to me, so it takes me time to process the things I read to build my understanding. Capacitors are new to me, and transistors I am just wrapping my brain around too. Still though, if I need the caps, I will get them. It is important to me that this project safely functions, and with all the money I have into it so far, I absolutely do not want to smoke anything.

Can someone help me out here? TYIA

I think there is a misunderstanding at some poi t somewhere. Driving an optocouple is exactly like driving an LED (because on the input side it IS an LED). I have no idea what a cap would do there. As with LEDs, you will want to limit the current with a resistor, but I am almost sure a relay module board with OCs already has those.

On the linked page about the relay board, click the circuit diagram and hover over it to enlarge it.

The un-named block top left in the diagram, represents the pins at bottom right of the photos, ie the pins marked GND / VCC / JD-VCC. If you take the jumper off, VCC the voltage for the LED and JD-VCC the voltage for the relay coil, are totally separated. VCC for the LED (which as can be seen by the way, does indeed have a resistor, R1) comes from the 5V pin on the Arduino, and the LED's cathode is to an Arduino digital pin. The relay power JD-VCC and GND then come from whatever 5V you provide for the relay, which with the jumper removed is not the Arduino, and the Arduino and the relay are isoltaed.

Do not be tempted, if you remove the jumper, to "park" it across the GND and VCC pins, which is pretty much what it seems you should do :wink:

Well this other member suggested that the optocouplers don't protect the 5V and GND feeds from the MC.

Wrong ... they do provide complete optic isolation providing you use separate power supplies and do not use a ground connection from the relay board to the MCU board.

Regarding "lack of capacitors"...

On DC circuits, sometimes a small cap is sometimes used across a DC motor to reduce noise. For a DC pump motor that is never reversed, a diode should be used to dissipate the inductive energy when the motor is switched off.

On AC circuits, capacitors are not directly connected across the load (unless specifically designed for this purpose). If a capacitor is used to reduce relay contact arcing and interference, it would be in series with a resistor and refered to as a snubber. For your switched AC loads, I recommend using an MOV rated for 150VAC (like this one) connected across each relay's COM and NO terminals.

Check out this thread for more ideas on contact arc suppression

Your relay board's connections for opto isolation...

I did not use a separate power supply for the relay module as I was given the impression that all the MCU would need to source is the current needed to power the LEDs in the opto. Unfortunately, there are not 2 separate VCC circuits on the module as they are connected via a trace. I suppose the only reason for the headers is to have the option to jump it to JD-VCC or GND. I would need to disassemble my project box to verify the exact position, but I have my other module jumped to JD-VCC, so I assume the actual one is also in the same position.

I do have a 5V/1A wall wart that I can use in light of this current knowledge. Perhaps this would be the better route as I also plan on working in that second module of 8 bringing my total up to 16 digital pins. Question, should I use resistors or any other components between the separate DC power supply and the relay modules?

I did not use a separate power supply for the relay module as I was given the impression that all the MCU would need to source is the current needed to power the LEDs in the opto.

No, with the VCC/JD-VCC jumper in place, the MCU powers the relay coils too.

I suppose the only reason for the headers is to have the option to jump it to JD-VCC or GND.

Jump what to JD-VCC or GND? If you take the jumper off the VCC/JD-VCC position, don't reposition it, throw it in a drawer.

Question, should I use resistors or any other components between the separate DC power supply and the relay modules?

Just directly connect as shown. If rated for 2A or higher, you could use it to power two 8-relay modules.

I did not use a separate power supply for the relay module as I was given the impression that all the MCU would need to source is the current needed to power the LEDs in the opto.

True, but with one power supply you need a GND connection from the relay board to the MCU board. With a GND connection between the boards, you loose opto isolation. With loss of opto isolation, the negative effects of switching AC inductive loads, and contact arcing can get introduced on the MCU board through the GND line.

In any case, I recommend configuring all unused inputs with INPUT_PULLUP to help prevent high impedance pins acting as antennae.

Keep all AC circuitry and wiring away from the DC wiring and components. Also, increasing the distance (if possible) from the MCU board to the relay board is helpful to reduce effects of interference.

If you are switching inductive loads with any of the relays you'll need a snubber (for AC) or a free-wheel diode
(for DC) to prevent the relay contacts burning up rapidly.

dlloyd:
Keep all AC circuitry and wiring away from the DC wiring and components. Also, increasing the distance (if possible) from the MCU board to the relay board is helpful to reduce effects of interference.

That's what the other member told me via PM. You'll probably laugh when ya see it, but I'll show it anyways. I have a piece of clear plastic sheet like lexan, and put aluminum foil tape over it to hopefully suppress some of the EMI produced by AC, but that's just where my understanding was at when I built the project over a year ago.

Anyways, I have the Ethermega on standoffs on one side, and the relay module on standoffs mounted to the inside face of the project box with all the AC circuitry. The lexan piece with the DC circuits is flipped towards the bottom of the project box (12"x12"x6"d) I only tested the project with small loads like household light bulbs. The largest load I intend to use are two 600 watt light ballasts, each to their own 10A relay. All other devices draw less than an amp @ 120VAC. Each ballast will be powered on for 12 hours in opposite times of the day. I also need to find out the the Arduino is going to behave around those ballasts as research suggests that digital ballasts produce the most EMI. I also plan to use roughly 7 sensors, perhaps 2 Arduinos will be needed? I have another Mega, and also an Udoo if that counts?

I opened the project box and shot some video.
Project video - Youtube

I also have a few one channel relay circuits that I can use to completely separate the ballasts from the Arduinos area if that is advisable.

I just want to bump this thread back up in the queue as I hope to get some answers to questions asked, thanks.