Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIR to PC817 210112

Status
Not open for further replies.
Hello ETO forum,

Working on a circuit to send a signal from a PIR, HC-SR505, to an Arduino input.

After some trial and error have had some success getting this circuit to work.
EEE_SR505_isolated_left_to_right_210110.jpg

This is a fritz of the same circuit.
PIR_to_Optocoupler_2_V_Sources_w Transistor_210104.gif

The circuit works as designed:
Before a hand is waved at the PIR when the twelve volt power sources are applied D1 and D2 are not lit.
When a hand is waved at the PIR D1 and D2 come on.
After about eight seconds D1 and D2 go off.


While troubleshooting the black probe of the DMM was placed near the PC817 at the point marked
'e' on the schematic and the red probe put at the PC817 at the point marked 'c' and these measurements
were gathered:
1. When D1 and D2 lit (the PIR is sending signal out), voltage = 10.83
2. When D1 and D2 are not lit (the PIR is not sending signal out), voltage = .53

This seems counterintuitive. It is conjectured that before
the PIR is activated no signal would be sent to the PC817, the transistor
in the PC817 would be open and
the voltage going through the PC817 would be low, say closer to
the half volt measured.

And, conversely, when the PC817 receives voltage from the transistor,
Q1 saturated by the signal from the PIR, would close the
circuit to the 12 volt source on the PC817 side and the voltage measured would be
closer to 11 volts measured.

Why is the signal from the PC817 high when D1 is off and low when
D1 is on?

Thanks.

Allen in Dallas
 
Why is Q1 connected with it's base and emitter swapped over compared with the normal way they would be connected ?
Think of the photo transistor as a switch. When the switch is closed the voltage across the switch will be zero.
Try thinking of the photo coupler as a relay with a normally open contact. When there no current through the coil the contacts are open so no current can pass through them so if you measure the voltage across them it will be the full voltage driving the circuit. (12 volts in your case.) When there is enough current through the coil the contacts close so the voltage across them will be zero. This is not a perfect analogy but it may help you to understand what is happening .
Note. The transistor with emitter and collector swapped over will work to some extent.

Les.
 
Hello Les Jones and the ETO forum,

Thanks for your excellent reply.

It is realized that the PC817 is a switch, like a NPN transistor, or a relay. And like those components the PC817 allows
a small amount of current and voltage to control a larger amount of current and voltage. And, in the case of the PC817, to do with
electronic isolation because light not voltage is controlling the photo transistor and current flow.

And so it is thought that when the PC817 is not receiving voltage, when the LED D1 is off, there would be no
connection between the PC817's emitter and collector. And conversely, when LED D1 is on the current
flowing between the PC817 anode and cathode would cause infrared light to shine on the PC817's
internal photo transistor and allow for a connection between the PC817's emitter and collector.

Question 1.
If that is true, then when LED D1 is on voltage flows from the PC817 anode to cathode, and allow current
to flow from the PC817 collector to the emitter. And yet when LED is on the DMM reads .19 volts.

And when LED D1 is off the PC817 photo transistor off. But the DMM read 10.83 volts.

So it is low when expected to be high and high when expected to be low.

Question 2.
Why is Q1 connected with it's base and emitter swapped over compared with the normal way they would be connected ?

So the transistor is seated backwards?
Tried reseating the transistor with 3904 placed with emitter is where the collector is in the schematic and collector where the emitter is in the schematic.
This blows my mind, it still works and the meter reads 3.24 volts when D1 lit and 10.24 when D2 is off.

This undermines how I thought transistors should be deployed. That is, on an NPN like a 2N3904 the emitter should
be connected to ground. Is that not true?

Thanks.

Allen in Dallas
 
Hello ETO forum,

Working on a circuit to send a signal from a PIR, HC-SR505, to an Arduino input.

After some trial and error have had some success getting this circuit to work.View attachment 129000
This is a fritz of the same circuit.
View attachment 129002
The circuit works as designed:
Before a hand is waved at the PIR when the twelve volt power sources are applied D1 and D2 are not lit.
When a hand is waved at the PIR D1 and D2 come on.
After about eight seconds D1 and D2 go off.


While troubleshooting the black probe of the DMM was placed near the PC817 at the point marked
'e' on the schematic and the red probe put at the PC817 at the point marked 'c' and these measurements
were gathered:
1. When D1 and D2 lit (the PIR is sending signal out), voltage = 10.83
2. When D1 and D2 are not lit (the PIR is not sending signal out), voltage = .53

This seems counterintuitive. It is conjectured that before
the PIR is activated no signal would be sent to the PC817, the transistor
in the PC817 would be open and
the voltage going through the PC817 would be low, say closer to
the half volt measured.

And, conversely, when the PC817 receives voltage from the transistor,
Q1 saturated by the signal from the PIR, would close the
circuit to the 12 volt source on the PC817 side and the voltage measured would be
closer to 11 volts measured.

Why is the signal from the PC817 high when D1 is off and low when
D1 is on?

Thanks.

Allen in Dallas

:rolleyes:It amazes me how such a simple circuit has become so complicated to resolve. Why does this keep changing?

Rather than try to explain why it works like it does, perhaps you should clearly explain how you want it to work.(?)
And what do you want to accomplish with the two LED's?

And....As I explained before....you cannot connect 12v to the arduino input. And Q1's emitter and collector is swapped in your schematic.
 
Question 1.
If that is true, then when LED D1 is on voltage flows from the PC817 anode to cathode, and allow current
to flow from the PC817 collector to the emitter. And yet when LED is on the DMM reads .19 volts.

And when LED D1 is off the PC817 photo transistor off. But the DMM read 10.83 volts.

Think of the PC817 as a "remote controlled switch" - it connects both terminals together when ON (so collector = 0V, same as the emitter or nearly so) and it is open circuit when OFF; so no current flow through the LED and resistor and no voltage drop across them.

If the "switch" were between the positive supply and the resistor & led, with the LED to ground, the on/off action would be exactly the same but the output (now emitter) of the PC817 would pull the resistor high when it was on.

You are overcomplicating things and reading too much in to them, as others have said.
 
Why are you making it so complicated?, the sensor can connect directly to the Arduino.

 
Re question 1. You seem to have got the idea that when a switch is closed that there should be a voltage across it's connections. This idea is wrong. This would mean that you would expect a significant voltage between the ends of a piece of wire carrying current. I Added the word "significant" because every piece of wire has some small amount of resistance. (The exception is superconductors But you need to understand the simple things first.) For your reading of 0.19 volts between collector and emitter for now just think of that simply caused by resistance. (Again the physics is more complicated but you don't need. I don't know all the physics of transistors. )

Re question 2 You don't say where the 3.24 volt reading is being taken but I suspect it is due the reverse breakdown effect of the base emitter junction as the way it is wired you are using its as a base collector junction. Your statement that the emitter should be connected to ground is not correct. (But in many cases it is.) It should be connected to a point that is more negative than the collector.

Les.
 
The transistor output of the PC817 is not an ON/OFF switch like a relay is. It is a controlled current. As such, the voltage dropped across the Emitter-Collector pins of the opto when "ON" will vary with the circuitry it's connected to and the LED current.

Current Transfer Ratio is the parameter of interest, and is seldom a tightly specified value. Typical specs that I have seen vary from 50% to 600%. Many optocouplers can be ordered that have been sorted into narrower CTR ranges.

The E-C transistor current is roughly limited to the LED current * the CTR. That means that, unless I-LED * CTR is greater than the current that is resistor limited in the output circuit, you will see a non-zero voltage across the E-C junction.


Personally, I don't see the need for optocouplers in this particular application. True, they can protect against carped static damage, but only if the sensitive circuitry is exposed to near contact from the person on the stairs. As this system uses a motion detector to control some LED lights, no direct contact is necessary or likely. Just put the circuitry in a suitable enclosure.
 
it was to help protect against transients like carpet static.
An opto will happily transmit a transient. Keep the circuit low impedance and handle transients in software would be the simpler solution. Handling transients in software is no different to debouncing a switch.

Mike.
 
Pommie, eTech, ChrisP58, Les Jones, Nigel Goodwin, rjenkinsb, and the ETO forum,

Please accept my apology for making the question in post #3 too complicated. Guess I didn't
have enough coffee that day.

From the feedback it looks like could simplify the system by eliminating the optocouplers
and feeding the 3 volt output from the PIR to the Arduino input.

Will refactor schematic and post in new thread.

Thanks.

Allen In Dallas
 
An opto will happily transmit a transient. Keep the circuit low impedance and handle transients in software would be the simpler solution. Handling transients in software is no different to debouncing a switch.

Mike.

Twisted wire runs will help suppress the transients. I don’t see how arduino software is going to prevent static damage to the input HW. Software debounce will probably be too complicated for the op.
 
what do you mean “imagine”,

The sensor is designed to connect directly to an Arduino - the chances of imaginary 'carpet static' are EXTREMELY unlikely, and not not worthy of consideration.

As the sensor is connected to the Arduino, static damage isn't an issue anyway.
 
The sensor is designed to connect directly to an Arduino - the chances of imaginary 'carpet static' are EXTREMELY unlikely, and not not worthy of consideration.

As the sensor is connected to the Arduino, static damage isn't an issue anyway.

mayb, maybe not...depends.
unless you are able to control the forces of nature.:D
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top