Apologies if this question seems vague or ridiculous - i've been doing a lot of research on this one, without a lot of success. I should also say that i'm pretty familiar with developing code, but on the electronics side of things I am a true beginner (none since school a long time ago :))
I'm trying to trigger one of the digital pins on the arduino by the activation of the siren on my domestic alarm system (9v).
What i'm attempting to do is use a 4N35 opto-coupler to do this and keep the circuits seperate. So rather than having the siren connected, i'd route the siren output into the opto and upon the alarm being tripped, the digital IO pin would go high.
However, I am struggling with the circuit schematic.
I've seen plenty of circuits which describe how to drive external sources using the arduino and an opto, but none showing the reverse - i.e. to trigger 5v on the digital IO pin in order to execute logic within the arduino.
Any help would be greatly appreciated as i'm really struggling with this one.
Most optical isolators use a two terminal open collector transistor (the light inside is activating the internal base for the transistor) for the output signal.
You wire the emitter lead (the one with the arrow symbol) to the Arduino ground and the collector lead to a say 10k resistor and the other end of the resistor to the Arduino +5vdc. Now run a wire from the opto collector terminal to the desired Arduino digital input pin.
The logic will be active low, so a low on the Arduino input pin means the optoisolator is being turned on.
Hope that helps;
Lefty
PS: You might be able to eliminate the external pull up resistor mentioned above by activating the Arduino internal pull-up for the digital input pin being used, It's worth a shot.
retrolefty: PS: You might be able to eliminate the external pull up resistor mentioned above by activating the Arduino internal pull-up for the digital input pin being used, It's worth a shot.
If you did that, wouldn't the transistor be shorting +5V to ground when it turned on?
Apologies if this question seems vague or ridiculous - i've been doing a lot of research on this one, without a lot of success. I should also say that i'm pretty familiar with developing code, but on the electronics side of things I am a true beginner (none since school a long time ago )
I'm trying to trigger one of the digital pins on the arduino by the activation of the siren on my domestic alarm system (9v).
What i'm attempting to do is use a 4N35 opto-coupler to do this and keep the circuits seperate. So rather than having the siren connected, i'd route the siren output into the opto and upon the alarm being tripped, the digital IO pin would go high.
However, I am struggling with the circuit schematic.
I've seen plenty of circuits which describe how to drive external sources using the arduino and an opto, but none showing the reverse - i.e. to trigger 5v on the digital IO pin in order to execute logic within the arduino.
Any help would be greatly appreciated as i'm really struggling with this one.
The problem, as I see it, is that you may be trying to sense the 9V siren turning on by putting the LED of the optocoupler in series with the siren. This would be a problem because the LED of the opto is not going to require as much current as the siren, which would no doubt damage the LED.
Even if you put the LED in parallel with the siren, with a resistor, you're robbing a little current from the siren to drive the LED, and you're subjecting the opto to any inductive noise kicked back from the siren.
I think a decent solution would be to use an op-amp, in voltage follower mode. The op-amp negative input connected to the op-amp output, and the op-amp positive input connected to the lead powering the siren, with maybe a resistor in series. The op-amp output also connected to the Arduino digital input of choice If you use a +5VDC supply for the op-amp, the output will only go to +5V max when the siren is activated, so it will be safe for the digital input of the Arduino. You just have to be sure that the op-amp's ground is connected to the siren's ground. You may want to apply some filter caps if required, for your desired response or noise filtration. Siren's can probably send out some nasty noise on a digital signal line. Below is a rough schematic of what I'm talking about.
If you did that, wouldn't the transistor be shorting +5V to ground when it turned on?
No, in that case there would be no direct connection to the +5vdc pin. Just emitter to ground and collector to the Arduino digital input pin. The path to +5vdc would be made through the software enabled internal pull-up.
Jshwaa: I'm actually envisaging taking the siren out of the circuit completely. I would like to convert the alar into a silent system which will message me over the internet when it's triggered.
Would this making the straight opto solution make any more sense?
Jshwaa: I'm actually envisaging taking the siren out of the circuit completely. I would like to convert the alar into a silent system which will message me over the internet when it's triggered.
Would this making the straight opto solution make any more sense?
Both ways make sense, because all you're really trying to achieve is isolation between your sensed circuit(alarm) and your arduino. An op-amp with it's near infinite input resistance, or an opto-isolator can do the trick. You won't have to worry about noise as much, now that you're taking the siren out. You may not need complete isolation as much as just a level change(from 9V of alarm output, to 5V of digital input of arduino) You could probably get away with using a couple resistors and a 5V zener diode.
Whatever you decide, test it with a meter. Check the output of your level shift circuit, to be sure that when the alarm(9V) activates, that you only have 5V at your output to your arduino. Put the meter in series with ground, in ammeter mode, and check for max current conditions. If you have an Atmega1280 based arduino(Arduino Mega) then you can't exceed 40mA of current at any input pin.
You could do the silent route and still have the siren available. Let the arudino sense the optocouple on an input and allow the arduino to inform you of the trip.
Then you can command the arduino to turn on an output connected to a transistor which powers the siren.
I've used the output of an Arduino to control a solid state relay that easily activated a fire bell I have.
If you run out of inputs or outputs there are several ways to expand those.
An op-amp with it's near infinite input resistance, or an opto-isolator can do the trick.
Too complex for what is required.
You don't need to go to that much trouble. A simple voltage divider with two resistors will do here. There is no need for an op-amp. If you want to be a bit more isolated then a simple transistor on the input like lefty describes will be well.