Optoisolator with Darlington Driver - 1 Channel Help

Hello,

I am trying to simulate a mechanical button using the Optoisolator with Darlington Driver - 1 Channel. The mechanical button just completes a circuit to activate. Here is a schematic of the component.

http://www.sparkfun.com/datasheets/Comp … xample.jpg

In the schematic above: I have the wires of the mechanical button connected to 3 (VCC) and 4 (Vout).

I have a digital output from the Arduino digital pin 7.

I also have a 220Ohm resistor between 2 and ground.

I do not have RL.

const int ButtonPin = 7;
void setup() {
  pinMode(ButtonPin, OUTPUT);      
}

void loop(){
    digitalWrite(ButtonPin, HIGH);
    delay(100);
    digitalWrite(ButtonPin, LOW);
    delay(1000);
}

I am not able to see the mechanical switch being activated. I have it plugged into a doorbell chime.

Any help would be great. Thanks.

Do you have a scope, or a DMM, or a small power supply?

You could make a few DC measurements, assuming you could step through your code.

With a power supply (Could be a couple 1.5 volt batterys) you could drive the pulse input

pins 1 and 2 with the resistor in there with that.

Is your doorbell chime AC or DC powered (Relative to to the mehanical switch)?

I need to see the circuit your opto pins 3 and 4 are driving.

Could be there is not sufficient current on output darlington to drive it.

What opto is that?

njr27:
I am not able to see the mechanical switch being activated. I have it plugged into a doorbell chime.

Any help would be great. Thanks.

I’m not sure by “see” what you mean. If you mean the doorbell chime doesn’t chime, you might want to think about using a longer pulsewidth. 100 usec might be too short and it’s easy enough to lengthen it to perhaps 1 msec or so.

Also how sure are you that the old switch connected 5V to the chime ? Perhaps (more likely IMO) it connected ground to the input pin of your chime. You could do this with your Darlington output stage as well.

Hardwareguy:
Do you have a scope, or a DMM, or a small power supply?

I have a handheld DMM.

Hardwareguy:
Is your doorbell chime AC or DC powered (Relative to to the mehanical switch)?

The doorbell chime has a 9V battery connected to it. So I assume DC.

Mee_n_Mac:
I’m not sure by “see” what you mean. If you mean the doorbell chime doesn’t chime, you might want to think about using a longer pulsewidth. 100 usec might be too short and it’s easy enough to lengthen it to perhaps 1 msec or so.

Yes, the doorbell does not chime. :( . Where do I change the pulsewidth? I have a delay of 100msec between HIGH and LOW digital writes.

Mee_n_Mac:
Also how sure are you that the old switch connected 5V to the chime ? Perhaps (more likely IMO) it connected ground to the input pin of your chime. You could do this with your Darlington output stage as well.

I connected the doorbell chime to a 3.5mm jack and the doorbell chimes when I touch 2 of the wires (left and right); the wire connected to the ring does nothing so I connected that to right). I measure the wires and I get a voltage that is used to activate the chime. So by touching the 2 wires, it completes the circuit.

Hope this helps.

Thank you again with the responses.

njr27:
Yes, the doorbell does not chime. :frowning: . Where do I change the pulsewidth? I have a delay of 100msec between HIGH and LOW digital writes.

Ooops, my bad. I was looking at the diagram and not your code. You do indeed have a PW of 100 msec. That should be long enough.

njr27:
I connected the doorbell chime to a 3.5mm jack and the doorbell chimes when I touch 2 of the wires (left and right); the wire connected to the ring does nothing so I connected that to right). I measure the wires and I get a voltage that is used to activate the chime. So by touching the 2 wires, it completes the circuit.

Hope this helps.

Thank you again with the responses.

Here's my guess at what your seeing. One wire is connected to ground. The other wire is connected to some logic input which is pulled up to +V via a resistor. Connecting the 2 wires provides a logic 0 to the circuit. You measure +V due to the pullup resistor.

Now can we verify my guess above ? Take your DMM and put one lead on the - terminal of the battery. That will be ground for the circuit. Measure the voltages on both wires above. I believe you’ve done this already and 1 of the wires should have measured 0 V. Then switch the DMM to ohms and measure the resistance between this wire and ground. It should be small (< 2 ohms). If so then half my guess is correct. Connect pin 3 of your optoisolator on this wire. Connect pin 4 to the other. You might have done this but I’m being a bit pedantic just in case you reversed the connections.

The above should work (if my guess is correct) so let’s now make sure your optoisolator is being driven properly by the Arduino. What I’d recommend lengthening the the PW and period you’ve programmed above to be long enough to be measurable using the DMM you have. Make the PW equal to 2 seconds and period 5 seconds (or longer if you want, it’s just for this test). Then run your code and using the voltmeter measure the voltage from pin 4 to pin 3 and see what you see. If is doesn’t go to < 0.4 V for some seconds then something is wrong. You might then want to measure the voltage from pin 2 to ground on your Arduino to see if it goes high for some seconds.

What Arduino are you using (3.3 or 5 V) ? What’s the part number for the optoisolator ? How did you arrive at the 220 ohms ? Lastly when you measured the voltages on the 2 wires from the doorbell, what were they ?

const int ButtonPin = 7;
void setup() {
  pinMode(ButtonPin, OUTPUT);      
}

void loop(){
    digitalWrite(ButtonPin, HIGH);
    delay(2000);
    digitalWrite(ButtonPin, LOW);
    delay(3000);
}

Procedure and Results…

When I measure across the 9V battery: 8.12 Volts. Result expected due to life of battery.

I will now use the negative terminal of the 9V battery as Ground.

When I measure the 3 wires from the 3.5mm jack out of the door chime, Right is 0V, Left is 6.45V, Center is 6.45V. On a 3 ring 3.5mm cable: The tip and sleeve are both 0V while the ring is 6.45V. On a 2 ring 3.5mm cable: the sleeve is 6.54V while the tip is 0V. This leads me to think that I may not be able to use both of the cables with the same input. The circuit will have to be designed to only work with 1 of them.

Resistance Testing:

When I measure the resistance between ground and the tip of the 3 ring 3.5mm cable, I get a low resistance. The sleeve and ring of the cable returns 0 Ohms.

When I measure the resistance between ground and the tip of the 2 ring 3.5mm cable, I get a low resistance. The sleeve of the cable returns 0 Ohms.

Before running tests with the optoisolator, I would like to verify which wires I should connect to pins 3 and 4.

Thanks.

I attached my circuit with part of the code I am using.

I’m a little surprised to hear there’s 2 cables coming off your doorbell and that one has 3 wires. Also that the OC voltage on the pins is 6.45 V. I’ll guess this is an old doorbell unit ? In any case I think your schematic above is correct to connect to the 2 wire cable. Your opto-isolator output should handle the reverse bias of 6+ V easily and should provide the “short” that you’ve seen work. So the tip (input to doorbell) of the 2 ring goes to pin 4 of the opto-isolator and the sleeve (ground) to pin 3. Did you measure the drive to input of the opto-isolator with the voltmeter ? This is just to verify that the code in your Arduino is really doing what we think it should be.

The doorbell chime that I am using has a 3.5mm jack. There are 2 different cables that I have that work with them. (Stereo has 3 rings. Mono has 2 rings)

http://www.computercableinc.com/ccinc/i … 201401.jpghttp://store.jvc.com/images/product/QAM0113-001.JPG

Sorry about the confusion.

When I ran the code:

void setup() {                
  pinMode(7, OUTPUT);  // sets pin 7 to output mode
}

void loop() {
  digitalWrite(7, HIGH);   // set the Doorchime on
  delay(2000);              // wait for 2 seconds
  digitalWrite(7, LOW);   // set the Doorchime off
  delay(3000);              // wait for 3 seconds
}

Measuring voltage at Optoisolator:

The voltage at pin 1 to ground is 4.88V for around 2 seconds. (This makes sense, the arduino & microcontroller are working)

The voltage at pin 2 to ground is 0.63V for around 2 seconds. (This makes sense, the voltage is dropping over the resistor)

The voltage at pin 3 to ground is 0V. (This makes sense, the ground is in reference to the board, not the battery)

The voltage at pin 4 to ground is 0V. (This makes sense, the ground is in reference to the board, not the battery)

The voltage at pin 3 to pin 4 is 6.45V.

njr27:
Measuring voltage at Optoisolator:

The voltage at pin 1 to ground is 4.88V for around 2 seconds. (This makes sense, the arduino & microcontroller are working)

OK, looks like Arduino code is doing the right thing !

njr27:
The voltage at pin 2 to ground is 0.63V for around 2 seconds. (This makes sense, the voltage is dropping over the resistor)

Hmmm, this puzzles me a bit. From the datasheet, the forward drop of the input to the opto-isolator should be about 1.3V. With a 4.88V output and minus the 1.3V should leave ~ 3.58V for the 2 secs the Arduino output is high. That you see only 0.63V indicates to me that the current is lower that expected. I thought an Arduino output could source or sink 40 mA. Perhaps I'm wrong re: this. I'd have expected about 16 mA given the aforementioned 1.3V drop and a 220 ohm resistor. IF the resistor is 220 ohms then you're seeing only ~3 mA. The opto-isolator should work with less forward/input current that 20 mA though. Perhaps the 2 seconds isn't long enough to allow the meter to settle ? :? Or perhaps the resistor isn't really 220 ohms ? :?

njr27:
The voltage at pin 3 to ground is 0V. (This makes sense, the ground is in reference to the board, not the battery)

Agreed.

njr27:
The voltage at pin 4 to ground is 0V. (This makes sense, the ground is in reference to the board, not the battery)

Agreed.

njr27:
The voltage at pin 3 to pin 4 is 6.45V.

Just to be picky but I hope you mean "voltage **from** pin **4** to pin **3** is 6.45V". [pin 3 to pin 4 should be -6.45V]

I’ve been under the assumption that you hacked the above cables onto/into the doorbell. If this isn’t the case, were there mechanical switches previously attached to these cables (or their equivalents) ? I’m trying to revisit my assumptions to see if they hold up. I’m trying to make sure what I’ve assumed are inputs to the doorbell are/were indeed inputs.

BTW did the doorbell chime with the above timing and connections ?

If you wanted to verify your opto-isolator was working (perhaps a good idea given my puzzle above) then you could connect it’s pin 3 to the Arduino ground and another 220 ohm resistor (500 - 1000 ohms would be better if you have one) between it’s pin 4 and the Arduino 5V. Then you should be able to measure between pin 4 and Arduino ground and see the opto switch between about 0.5 V and 5 V.

njr27:
Or perhaps the resistor isn’t really 220 ohms?

The resistor is 240 Ohms. My mistake.

njr27:
Just to be picky but I hope you mean “voltage from pin 4 to pin 3 is 6.45V”. [pin 3 to pin 4 should be -6.45V]

Agreed.

njr27:
If you wanted to verify your opto-isolator was working (perhaps a good idea given my puzzle above) then you could connect it’s pin 3 to the Arduino ground and another 220 ohm resistor (500 - 1000 ohms would be better if you have one) between it’s pin 4 and the Arduino 5V. Then you should be able to measure between pin 4 and Arduino ground and see the opto switch between about 0.5 V and 5 V.

I will test this. I have a 560 Ohm resistor. I will put it in series with the 240 Ohms. =800 Ohms!

What do I connect to pin 1?

njr27:
I will test this. I have a 560 Ohm resistor. I will put it in series with the 240 Ohms. =800 Ohms!

What do I connect to pin 1?

See the attached below. Leave the present connections to the Arduino as they are. 240 vs 220 ohms is a don’t care, won’t make any practical difference. What you should see is the voltage across pin 4 to ground switches from ~5 V when the opto is “off” to ~ 0.5 V (or less) when the opto is “on”*. Perhaps you could measure the voltage across pin 1 and ground again, with the opto connected as below and the code running. There should be a fairly steady 4.88 V (when the pulse is “on”) going by your prior post. And obviously 0 V when the pulse is “off”. Then measuring from pin 1 to pin 2, you should see 0 V (when off) switching to ~ 1.3 V when the pulse is on. And if the voltage across the 220/240 resistor is still 0 V (off)/ 0.63 V (on) then I have to wonder where the missing voltage is. That is the 1.3 V + the voltage across the resistor (? 0.63 v ?) should = 4.88 V when the pulse is on. Obviously 1.3 + 0.63 != 4.88. So I’m not understanding something here or something is borked up … hence my desire to measure the above (again). :oops:

If the opto seems to be working as measured above*, then be sure to plug the cable you’re using into it and check for the same voltages as the opposite end of the cable. Let’s make sure the problem isn’t something silly like a bad cable. Alternately use the ohm meter to verify the cable is good, tip to tip, sleeve to sleeve.

BTW what model Radio Shack doorbell is that ? The part in your picture looks like the RF transmitter portion of a wireless set. If that’s the case then “we” need to be sure the RF part is working in the location where, and under the same conditions as when, you tried to use the Arduino & opto-isolator. If the opto tests (above) look good then I have some other ideas as to what to look for next.

Sorry for the delay. I was unable to log in due to SparkFun’s login issue. Now that it is fixed, I can answer your questions.

Mee_n_Mac:
What you should see is the voltage across pin 4 to ground switches from ~5 V when the opto is “off” to ~ 0.5 V (or less) when the opto is “on”*.

The voltage across pin 4 to ground is constantly 4.97V.

Mee_n_Mac:
Perhaps you could measure the voltage across pin 1 and ground again, with the opto connected as below and the code running.

The voltage across pin 1 to ground switches from 0 to 4.49V.

Mee_n_Mac:
Then measuring from pin 1 to pin 2, you should see 0 V (when off) switching to ~ 1.3 V when the pulse is on.

The voltage across pin 1 to pin 2 before the resistor is 4.30V. The voltage from pin 1 to after the pin 2 resistor is 4.82V.

The voltage across the resistors (2x 120 Ohm in Series) is 0.60V.

Mee_n_Mac:
BTW what model Radio Shack doorbell is that ?

Wireless Remote Door Chime

(630-0871) Specifications Faxback Doc. # 18649

Frequency…310 MHz +/- 1 MHz

The door chime still works if I plug in a mechanical button to press down.

njr27:
The door chime still works if I plug in a mechanical button to press down.

Ok, that's a good start. The RF link is working.

njr27:
The voltage across pin 1 to ground switches from 0 to 4.49V.

Also good, your code is pulsing the output pin. Odd that it's 4.49V to gnd while it's 4.82V to what should be gnd on the other side of the 240 ohm resistors.

njr27:
The voltage across pin 4 to ground is constantly 4.97V.

This is bad and it's why the doorbell is not chiming. So the opto-isolator is not doing it's thing. It's either broken or it's not being driven hard enough or I'm not understanding something (? wiring is not as I think it is ?)

njr27:
The voltage across pin 1 to pin 2 before the resistor is 4.30V. The voltage from pin 1 to after the pin 2 resistor is 4.82V. The voltage across the resistors (2x 120 Ohm in Series) is 0.60V.

I guess 2.5 mA is not enough to drive the output into saturation. I'm not sure why this is, given the datasheet. In any case it's obvious that the internal LED is not being driven hard enough. It should be, given the 4.49 or 4.82 V output on the pin 1. Given this I might suggest using just one of the 120 ohm resistors (btw pin 2 to gnd) and seeing what happens.

Also, with power removed, can you measure the resistance between pin 2 and the ground points you used above ? I’ve got a sneaking suspicion that the connection from the “bottom” 120 ohm resistor to ground is not as good as short as it should be. That is, when you think it’s 120 ohms to ground, it’s really not 120 ohms … at least to the point where you measured 4.82 V above. It’s got to be more resistance and that would mean much less current which in turn explains why the voltage btw pins 1 and 2 (when the pulse is 4.49V) is 4.3V instead of ~1.3V. It’s because there’s even less current that the 2.5 mA I calculated using 240 ohms. It’s either that or the opto-isolator is broken.

Mee_n_Mac:
Also, with power removed, can you measure the resistance between pin 2 and the ground points you used above ?

Using the 120Ohm resistor instead of 240: I measured 122 Ohms from pin 2 to ground so the resistor is relatively true.

Here is what my circuit looks like:

I also measured the voltage across the resistor. Both are 4.97V… :shock:

OK then it looks like your opto-isolator is blown. With ~5V output from the Arduino on Pin 1 and a 120 or 240 ohms from pin 2 to ground, you should see 1.3V from pin 1 to 2 and therefore ~3.7V across the resistor(s). That should make for a low voltage drop between pins 3 and 4. Since this isn’t happening, no current is flowing from pins 3 to 4 and thus there’s no voltage drop across the 470 ohm resistor (~5V on either side of it).

You might want to verify the connection from pin 4 to the resistor and from pin 3 to ground but even if there was an open circuit there, that wouldn’t account for the lack of current in the pin 1 to 2 path.

Time to try a new opto in the circuit above.

Okay. I was afraid of that. What can I do to not have this happen again?

Thank you for your help.

njr27:
What can I do to not have this happen again?

Got me. It would seem the input of the opto is borked. I’m not sure how this might have happened. Even if you had shorted the Arduino output to pin 1 and had pin 2 tied directly to ground (no resistor) the Arduino could only source ~40 mA and I doubt that would be enough to fry the opto input. None of the voltages you’d be using are enough to cause damage and I really doubt ESD could do it either. But try another opto in the “test circuit” above and make sure it works and then install it into the real circuit. Your original thinking was fine.

Ok. Good. I just wanted to make sure that my circuitry was not the cause of the fried opto.

Thank you very much for your troubleshooting steps and advice. :mrgreen:

I purchased a few more of these and tested them just like you showed me. They work!

Thank you for all of your help and patience.

How do you make this forum topic “Solved”?