Pages: [1]   Go Down
Author Topic: General interfacing advice using optocouplers  (Read 793 times)
0 Members and 1 Guest are viewing this topic.
South UK
Offline Offline
God Member
*****
Karma: 2
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all. I am interfacing my alarm system with an Arduino.

Here is the write up from the alarm manual.

Quote
OUTPUTS (J3): These outputs are programmed as active low output. They are held at 13V and fall to 0V
when active, it can source or sink 10mA.
These outputs would normally be connected directly to the input channels of wire in type communicators.
Alternatively each output can be used to drive a relay (coil resistance > 1200 Ohms) connected between the
output terminal and the 13V supply terminal. The relay will energise when the output port operates. It is
recommended that a back EMF protection diode is used in parallel with the relay coil.

I have some MOCD207M optocouplers handy, so I was going to connect the diodes to the 13V and the outputs so when the outputs went low, current would flow through the diodes and activate them.  

Looking at the optocouplers datasheet http://www.fairchildsemi.com/ds/MO/MOCD207M.pdf a forward voltage of around 1.4v @ 30mA is suggested. Should I use a 390R resistor to drop from 13v? The alarm manual says the outputs can source or sink 10mA so would 30mA flowing into them overload them? Or should I try and limit the current to 10mA and hope it is enough for the optocouplers - I can't see the minimum current in the MOCD207M datasheet?

Thanks!
Logged

Denmark
Offline Offline
God Member
*****
Karma: 8
Posts: 527
Please don't send questions as PM!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset



So that's 13V -1,25V = 11,75 / 0,03 = 391

So yes, 390 Ohms are perfect ;-)

// Per.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Looking at the optocouplers datasheet http://www.fairchildsemi.com/ds/MO/MOCD207M.pdf a forward voltage of around 1.4v @ 30mA is suggested. Should I use a 390R resistor to drop from 13v? The alarm manual says the outputs can source or sink 10mA so would 30mA flowing into them overload them? Or should I try and limit the current to 10mA and hope it is enough for the optocouplers - I can't see the minimum current in the MOCD207M datasheet?

Thanks!

Yes you need to limit the current to the 10ma limit capacity of the alarm output pin. So wire the output pin to a cathode of one of the opto's input led, wire the anode to a 1200 ohm resistor and the other end of the resistor to the +13vdc voltage source on the alarm module.

The 'CTR' spec in the datasheet tells you the response ratio for a given input current. Assuming you will just be driving arduino digital input pins you don't require a lot of current in the opto's output circuit, 10ma input led current will be more then enough. Just ground the emitter, enable the internal pull-up resistor for the digital input pin and wire it to the opto's collector terminal. you should be able to detect the state of the alarm output. The arduino will read a LOW when the alarm module activates the signal and a HIGH when it deactivates the signal.

Lefty
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



So that's 13V -1,25V = 11,75 / 0,03 = 391

So yes, 390 Ohms are perfect ;-)

// Per.

No it's not, it will burn up the output pin of the alarm module that has a 10ma maximum rating.

Lefty
Logged

The Netherlands
Offline Offline
Edison Member
*
Karma: 35
Posts: 1294
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You would need a 1200 (AKA 1K2) Ohm resistor for this.

You have 10 mA, 13 volts and 1.4 volts as a reference.

13 volts minus 1.4 volts == 11.6 volts to drop.
U=I*R; R=U/I; 11.6 / 0.01 == 1160, makes a standerd value of 1200 Ohm.

10 mA is not a lot, is there a need to use those optocouplers ?
You could connect directly to your Arduino.
Or use some transistors to boost the signal from your alarm system.
Logged

Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

South UK
Offline Offline
God Member
*****
Karma: 2
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, thanks for the reply's.

Thanks for the detailed advice Lefty! I will try that smiley Should I use resistors on the arduino digital pins also? If it is written HIGH via the internal pull ups and I ground the pins, how much current would flow? I know the pins supply about 30mA but how much would it sink?

Apparently the 13V output from the alarm can supply up to 200mA so I plan to run the arduino & ethernet shield from that. Would you simply run 13V into the Vin or step it down first?

Thanks!
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, thanks for the reply's.

Thanks for the detailed advice Lefty! I will try that smiley Should I use resistors on the arduino digital pins also? If it is written HIGH via the internal pull ups and I ground the pins, how much current would flow? I know the pins supply about 30mA but how much would it sink?

No need for any external resistors for the digital input pins. The internal pullups are like 40K to 50K ohms, so very little current flows when the output transistor of the opto conducts to ground.

Output pins can sink current to an external circuit when they are commanded to a LOW state and can source current to an external circuit when commanded to a HIGH state. But an input pin is just a very high (many megohm) input sensing pin that draws no current to speak of from what ever is supplying voltage to the pin.

So lesson here is that output pins and input pins are two totally different animals on a arduino board. Most of the rules and limits for output pins are different then the rules for input pins, but both do have rules and limits of course.


Apparently the 13V output from the alarm can supply up to 200mA so I plan to run the arduino & ethernet shield from that. Would you simply run 13V into the Vin or step it down first?

I suspect not as ethernet boards are somewhat current hungry as I recall, but don't know directly. The basic Uno type arduino board draws about 50ma, so add that to whatever the ethernet shield requires plus anything else you are wiring to the arduino board like leds, etc and see what the total works out to.

Thanks!
Logged

Denmark
Offline Offline
God Member
*****
Karma: 8
Posts: 527
Please don't send questions as PM!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset



So that's 13V -1,25V = 11,75 / 0,03 = 391

So yes, 390 Ohms are perfect ;-)

// Per.

No it's not, it will burn up the output pin of the alarm module that has a 10ma maximum rating.

Sorry, my bad ;-(
Logged

Offline Offline
Edison Member
*
Karma: 56
Posts: 2145
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have to visualize, getting to old.
I would definitely lower the voltage from 13 Volts so as to keep the Arduino regulator cool.
Note: lowest Vin is 7 Volts for the Arduino regulator to work.


* Alarm.jpg (80.32 KB, 949x487 - viewed 35 times.)
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16499
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That R? 4.7k ohm resistor is really not required, just enable the internal pull-up resistor for the input pin being wired to.

pinMode(Pin#, INPUT_PULLUP);
Logged

South UK
Offline Offline
God Member
*****
Karma: 2
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Again, thanks all for the input! And thanks to larryD for drawing it out.

Got it built on a protoshield and all seems to be working smiley I used 1300R resistors in the end to be on the safe side and through them I am measuring 9mA and picking it up on the digital pins so it should be fine.

You are right about the Arduino regulator. Its mildy warm with the arduino only, but gets too hot with the ethernet shied on, I measure 230mA with the shield attached smiley-sad . Is there a way to reduce this? This circuit will be running 247 so would be nice to get it down a little.

Obviously I won't be able to power the arduino from the alarm now, for heat and over current reasons. Guess I will just get a 9v wall adapter or similar.

Thanks

Edit: Obvious things I can think of is to disable all the LED's, I notice the shield takes 5V from the arduino then drops it to 3.3V, I don't suppose the 3.3V on the arduino is enough to power the shield is it?

« Last Edit: January 06, 2013, 09:48:38 pm by dtokez » Logged

Pages: [1]   Go Up
Jump to: