PIR to Optocoupler circuit 201230

Thread Starter

allenpitts

Joined Feb 26, 2011
163
Hello AAC forum,

Working to operate an Arduino using a PIR with some fairly long wire runs
so an opto-coupler is used to isolate the Uno.
PIR_To_optocouple_1_v _Source_2020-12-30.jpg.jpg
This is the first attempt at a circuit. Perhaps, because the signal to the microcontroller,
represented by D2, has the same voltage source as the PIR the optocoupler does not
isolate the the UNO input from EMI.

To isolate the output from the PIR from the input to D2 there must be
separate power supplies, right? Voltage and ground or just ground?
PIR_To_optocouple_2_v _Source_2020-12-30.jpg.jpg
The problem with the second schematic is the PIR, HC-SR505 has a signal output
of 2.5 volts. (The data sheet says 3.3 volts but the signal has been measured
several times and is never above 2.7 and has been measured a couple of times
at 2.49 volts.) The optocoupler, PC 817, requires at least 5 volts to
complete the connection between the collector and the emitter, so a transistor is used to boost
the signal to the optocouple anode.
PIR_To_optocouple_2_v _Source_w_Q_2020-12-30.jpg.jpg
It is believed this will work but post at this forum for some feedback might
improve chances of success.

Thanks.

Allen in Dallas
 

sghioto

Joined Dec 31, 2017
5,380
The problem with the SR505 is an internal 1K resistor in series with the output. It doesn't have enough drive current for circuits 1 and 2 as you have figured out.
Circuit 3 will work but needs mods as suggested below.
Increase values R1,R3 to reduce LED current to safer level.
Add R2, there was no current limit in your original circuit.
Drive D1 with transistor Q1.
EEE SR505 isolated.png
 
Last edited:

sghioto

Joined Dec 31, 2017
5,380
Remove the led in series with the optocoupler
That would have been my first suggestion but the internal resistor will limit the current through the opto to 2.1 ma. This may not be enough to switch VO1 and you will eliminate the visual indicator on the PIR, if that's important.
 

Thread Starter

allenpitts

Joined Feb 26, 2011
163
Hello DodgDave, sghioto and the AAC forum,

DodgyDave, Your solution simplified the circuit but the PIR indicator, D1, is
helpful in seeing what's going on in the circuit.

sghioto, Thanks for the mark up PIR to Optocoupler 2V Sources w Transistor
The schematic was breadboarded.
Opto_breadboard_photo_201231_600_x_450.JPG

The PIR side of the circuit works as expected. Waving a hand at the PIR causes D1
to come on. But D2 comes on rather faintly and stays on when D1 has gone off.
I figured maybe the optocoupler was blown or defective. I replaced the optocoupler
with a new one and got the same operation .

Have checked the schematic to breadboard accuracy and there don't seem to be any defects.
But I am a bit new to the optocoupler so not sure how to troubleshoot it.

Thanks.

Allen in Dallas
 

Thread Starter

allenpitts

Joined Feb 26, 2011
163
Hello DodgDave, sghioto and the AAC forum,

It may be noted that if power is applied at B1 without power to B2, then D2 at the emitter/collector side
of the optocouple does not light up. But when power is supplied to B2 then D2 come on and stays on even when
D1 is not on.

I think that means the optocoupler is turning D2 on but not turning D2 off.

Is there a way to check that? Again not sure how analyze the optocoupler.

Thanks.

Allen in Dallas
 

LesJones

Joined Jan 8, 2017
4,174
The external power to the HC-SR505 is reduced to 3.3 volts by an onboard regulator (HT7133-1). This means the maximum output signal will be a bit less then 3.3 volts. The forward voltage across a red LED is about 1.8 volts. The LED in the opto coupler will probably be an IR LED which will have a forward volts drop of about 1.5 volts. So when these two LEDs are in series the voltage required is 3.3 volts. This will mean that there will be very little current flowing through the LEDs so the IR light from the IR LED may not be enough to turn on the phototransistor in the opto coupler. I think a slightly modified version of your circuit with the transistor should work. It will need the sensor negative connected to the negative of the 12 volt supply and also a current limiting resistor in series with the LED in the opto coupler. (I would suggest about 2K to give a current of about 5mA )

Les.
 

Dodgydave

Joined Jun 22, 2012
11,285
Hello DodgDave, sghioto and the AAC forum,

It may be noted that if power is applied at B1 without power to B2, then D2 at the emitter/collector side
of the optocouple does not light up. But when power is supplied to B2 then D2 come on and stays on even when
D1 is not on.

I think that means the optocoupler is turning D2 on but not turning D2 off.

Is there a way to check that? Again not sure how analyze the optocoupler.

Thanks.

Allen in Dallas
There is a 1K resistor on the output from the chip , so you don't need a series resistor to the optocoupler, just wire it directly as it will give out 10mA.


__SR505_pir_module_circuit.png
 

LesJones

Joined Jan 8, 2017
4,174
I think the phototransistor in the opto coupler may be heating up as it is trying to pass a current of about 45 mA as a result of using a 220 ohm current limiting resistor. As we don't know the part number of the opto coupler we can't check the current rating of the phototransistor . If it is heating up it will increase it's leakage current causing the LED to glow. Try changing the 220 ohm resistor to about 1K.

Les.
 

Thread Starter

allenpitts

Joined Feb 26, 2011
163
Hello sghioti, DodgyDave, LesJones and the AAC forum,

DodgyDave
There is a 1K resistor on the output from the chip , so you don't need a series resistor to the optocoupler,
just wire it directly as it will give out 10mA.
Pretty sure by 'the chip' it is meant the chip on the HC-SR505, right?

If the series resister to the optocoupler is eliminated then the circuit looks like

1609447233854.png


right?

LeJones: (Oh yeah, sorry, thought the optocoupler part number was on the
schematic, it is PC817.) There maybe something to your point because
I believe the circuit worked as intended for a couple of PIR cycles. But then the D2 load LED would not go off.
But then when the PC817 was replaced and there was no initial working then not working.
Will try the resistor change with a new PC817. Might as well, right now I am stuck.

Thanks.

Allen in Dallas
 

eetech00

Joined Jun 8, 2013
3,859
hello

The maximum output from the SR505 is 3.2v, so even with the output short circuited, the maximum current will be 3.2 millamps.
That's why the LED will be dimm, unless a low current LED is used. However, the PC817 is spec'd at 5ma minimum for a transfer ratio of 50%. A little confusing though because the graph shows approx 110% at 3ma.

1609448748219.png

I've tested an LED (20ma, 2v, the only one i had) connected in series with the SR505 output and the base (no base resistor) of a current loop driver transistor. The LED lights noticably well in ambient light.
 
Last edited:

sghioto

Joined Dec 31, 2017
5,380
Might as well, right now I am stuck.
Do not connect as shown in post #10.
I can't tell from the photo if the board is wired correctly or not. I need to see a much larger image.
Going back to post #10, you can't eliminate the series resistor to the opto if using the transistor driver. You have to use a series resistor or you will blow out the IR LED inside the opto.
If you connect the opto directly to the output of the PIR the most current you can push through it is only about 2.1ma because of the internal 1K resistor.
(3.3 volts) minus (the typical voltage drop of 1.2 volts across the IR LED) is 2.1 volts divided by 1K is 2.1ma.
The circuit needs to be wired as in post #2.
What transistor are you using?
 
Last edited:

LesJones

Joined Jan 8, 2017
4,174
I agree with sghioto's comments in post #12. That is exactly why I suggested adding the 2K resistor in post #7.
I did not recognise PC817 as an opto isolator part number. I have found and attached the datasheet so you have the information required to calculate the required resistor values.

Les.
 

Attachments

Last edited:

eetech00

Joined Jun 8, 2013
3,859
Try it this way. This mod requires a PNP driver transistor but will allow you to set the LED drive current separate from the opto drive current.

1609525536535.png
 

ericgibbs

Joined Jan 29, 2010
18,766
Working to operate an Arduino using a PIR with some fairly long wire runs
so an opto-coupler is used to isolate the Uno.
hi allen,
How long is the cable from the PIR to the Arduino.?

I use a HC SR501 PIR module voltage output 0V to +3V [active] to drive into a 15mtr screened multi core cable, connected to an analog input of a PIC, simple R/C filter for noise elimination.

The PIC program senses the 'activated' voltage level of the PIR signal, above or below +1.5Volts.

I have a HC SR505 in stock, I can check how well that drives a long cable run.

E
 

Thread Starter

allenpitts

Joined Feb 26, 2011
163
Hello eetech00, sghioto, LesJones, DodgyDave and the AAC forum,

It was hoped that success was near with the schematic from sghioto
marked 'Revised 201230; copied here.
The PIR side is working but the opto side is not.
EEE SR505 isolated.png
In post #12 it was noted that the bread board could not be
seen because the photo did not show detail. Perhaps a fritz of
the bread board makes the test clearer.
PIR_to_Optocoupler_2_V_Sources_w Transistor_210102.gif
In post #9 it was suggested that a 220 ohm resistor be replaced with
a 1000 ohn resistor. This must refer to an older schematic because
on the latest schematic marked 'Revised 201230' there is no 220 ohm
resistor.

In post #14 eetech offers a completely different plan. Am in the process
of breadboarding the schematic maked 'Sensor Mod.asc'. Working to get
a better understanding as the breadboard is implemented.

At Sensor Mod.asc the output of the HC-SR505 saturates the base of Q1 which
sends current to the base of Q2. Q2, a 2n3906, is normally on and
current to the base of Q2 would would open the connection between
the Q2 emitter and collector. So D1, which normally draws current from
VCC, when Q1 is stimulated turns Q2 off which would turn D1 off.
But it would seem the function of D1 is to indicate a plus voltage
from the PIR and Q1 so why the current to D1 is turned off is not
understood.

Thanks.

Allen in Dallas
 

Attachments

eetech00

Joined Jun 8, 2013
3,859
In post #14 eetech offers a completely different plan. Am in the process
of breadboarding the schematic maked 'Sensor Mod.asc'. Working to get
a better understanding as the breadboard is implemented.

At Sensor Mod.asc the output of the HC-SR505 saturates the base of Q1 which
sends current to the base of Q2. Q2, a 2n3906, is normally on and
current to the base of Q2 would would open the connection between
the Q2 emitter and collector. So D1, which normally draws current from
VCC, when Q1 is stimulated turns Q2 off which would turn D1 off.
But it would seem the function of D1 is to indicate a plus voltage
from the PIR and Q1 so why the current to D1 is turned off is not
understood.

Thanks.

Allen in Dallas
You have mis-interpreted how my circuit works.

When no motion is detected, Q1 is normally OFF and Q2 is normally OFF.
When motion is detected, Q1 turns on and does two things. 1) It permits current flow thru the optocoupler input diode. 2) It provides continuity to ground at the base resistor of Q2. This turns Q2 on and lights LED D1 to indicate motion is detected. The current thru D1 can be set separately from the current through the optocoupler diode. So if you want to operate D1 at 20mA, you can by adjusting R2. Likewise, the current thru the optocoupler diode can be changed by adjusting the current loop resistors. So both current adjustments can be made with little effect on each other. You can operate D1 at the brightness level you prefer.
 
Last edited:

LesJones

Joined Jan 8, 2017
4,174
I agree with sghioto post #14. The way you have it connected LED2 will be on permanently. This is assuming that I have guessed the track layout in the breadboard. (Which I have never used.)

Les.
 

tindel

Joined Sep 16, 2012
936
I'm not seeing the justification for using an opto due to 'fairly long wire runs'. And submit that the opto is likely hurting you in this application.

If you're powering the PIR with these same wire runs, be aware that the PIR is common-drain, and is very sensitive to power supply noise. The power rail needs to be well filtered. I designed one of these once, professionally, to run over a 3 meter wire. I used a circuit similar to @Dodgydave's, with an added PIC that would then send a I2C communication back to the 'master' microcontroller. I2C wasn't a great option either, but it worked, and was extremely low noise. We had more than one sensor, so a simple 'trip' signal was not feasible.

By far, the most important factor in the success of your sensor is the lens you pair with the sensor.
1609686949247.png
 
Last edited:
Top