Go Down

Topic: I/O between arduinos with opto coupling. Sample schematic  (Read 5492 times) previous topic - next topic

jeffez

Hi guys,
I'm looking at having some inputs and outputs between multiple arduinos. It will be across potentially lengthy distances and i'd be looking at using cat5 for cost and minimising interference.

I put together a schematic and wanted to see if it looks correct and if opto isolating is the best way to go. Basically when the pin outputs HIGH on one arduino, the other ones input pin goes to LOW.

This is part of an earlier project i did when i was starting out.
https://forum.arduino.cc/index.php?topic=362113.0


Grumpy_Mike

That circuit is fine as it goes. I would use 1K on the receiving end and 220R on the sending end.
However it might not solve any distance related problem, for that you need a differential driver and receiver. But that depends on the exact circumstances of your setup.

jeffez

That circuit is fine as it goes. I would use 1K on the receiving end and 220R on the sending end.
However it might not solve any distance related problem, for that you need a differential driver and receiver. But that depends on the exact circumstances of your setup.
Thanks, so i would want more current running from the arduino on the left given the long distance to ground?

Would a capacitor be worth using the help smooth out potential noise from the long distance?

ricky101

You really need to define your meaning of  " long distance "

For distances of up to 20 mtrs + then look at using a pair of MAX232 chips

raschemmel

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Paul__B

Thanks, so I would want more current running from the Arduino on the left given the long distance to ground?
No, the gain of the optocoupler is (usually) less than one, likely about 50%, so you need to feed more current into it than it can switch with the output transistor, thus the lesser resistance.  It has no relationship to the distance.

Your diagram is however wrong - the optocoupler should be on the receiving side with the cable feeding the LED.  The cable resistance will merely be part of, but almost certainly much less than the current limiting resistor for the LED.

Would a capacitor be worth using the help smooth out potential noise from the long distance?
Almost certainly not.  Unless your signal is very slow, perhaps 10 baud.

raschemmel

Quote
Your diagram is however wrong - the optocoupler should be on the receiving side with the cable feeding the LED.  The cable resistance will merely be part of, but almost certainly much less than the current limiting resistor for the LED.
 
I was wondering why that didn't look right.... ;D
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

jeffez

You really need to define your meaning of  " long distance "

For distances of up to 20 mtrs + then look at using a pair of MAX232 chips
In this case it might be upto 20 meters.
I currently have an opto relay board running 50 meters away over cat5 straight from the arduino drawing around 5ma per output pin.
Not sure how this works but using the same cable over a shorter distance with opto coupling between two arduinos is going to need more current and possibly even extra chips?

jeffez

No, the gain of the optocoupler is (usually) less than one, likely about 50%, so you need to feed more current into it than it can switch with the output transistor, thus the lesser resistance.  It has no relationship to the distance.

Your diagram is however wrong - the optocoupler should be on the receiving side with the cable feeding the LED.  The cable resistance will merely be part of, but almost certainly much less than the current limiting resistor for the LED.
Almost certainly not.  Unless your signal is very slow, perhaps 10 baud.

Ah i didn't know which side to put the optocoupler! :D
I put it on that side because i was told in another thread that its better to not apply voltage over a long distance wire.

jeffez

Ive revised the diagram, does this look correct? I set resistor values from Grumpy_Mikes suggestion.


adult photo sharing

Paul__B

That's fine.  All the resistors and wires are in the right places.

Note just by the way, that putting a HIGH to feed the LED will then switch on the transistor and pull the Arduino input LOW.

This is precisely as it should be, the safest way in case of short circuits.  But your sketch logic will of course, have to expect this.

MarkT

That circuit is fine as it goes. I would use 1K on the receiving end and 220R on the sending end.
However it might not solve any distance related problem, for that you need a differential driver and receiver. But that depends on the exact circumstances of your setup.
An LED at the end of a long cable is differential, surely?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

jeffez

I have two opto relay boards connected to the same arduino, one about 50 meters away and the other about 10 meters. Both work well using cat5 and draw only around 5ma per channel. Infact i have two relay channels sharing the same output pin, which i plan to change but hey it still works! :D. My thinking is it should be possible to replicate this reliability using the same/similar circuit as what the relay board uses.

I haven't been able to find a schematic but by the look of the board there isn't any special driver on there?

http://www.ebay.com.au/itm/DC-12V-4-Channel-Relay-Module-Optocoupler-For-Arduino-PIC-ARM-AVR-DSP-HD23L-/131524714841?hash=item1e9f7be159:g:c-oAAOSwhwdVUbW-

raschemmel

Does the relay turn on with a LOW ?
It might be similar to this:

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

jeffez

Does the relay turn on with a LOW ?
It might be similar to this:


Thanks yeah it has Active LOW, i would say that must be an 8 channel version of my one. I'll have to find out what value R5 is plus the opto led resistance.
I'm starting to wonder if i have been wrong about the actual current draw from the arduino for each relay channel. I was told in another thread upto 4mA would be used but i may have misunderstood.

Post #29
https://forum.arduino.cc/index.php?topic=362113.15

Go Up