Maker Pro
Maker Pro

Phototransistor latch circuit?

BlinkingLeds

Feb 23, 2013
180
Joined
Feb 23, 2013
Messages
180
Hi.
I'm trying to figure out a way to make a latching circuit from a phototransistor (when signal is applied it should stay on until receiving a signal again). The problem is it should be really fast ,micro-second fast. I thought of using a 4017 but i wasn't sure about it's speed. Is there any other better and/or simpler way to do it?
Thanks.
 

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
Did you read the data sheet? It's all spec'd out in there. They're about twice as fast @ 10V than @ 5V Vdd. That said there are faster alternatives.

Chris
 

Laplace

Apr 4, 2010
1,252
Joined
Apr 4, 2010
Messages
1,252
Have a look at the CD74HC109 J-K flip-flop with Schmitt trigger clock input. The Schmitt clock input would be a suitable interface for a phototransistor, and a J-K flip-flop can be configured into any kind of latch you might want.
 

BlinkingLeds

Feb 23, 2013
180
Joined
Feb 23, 2013
Messages
180
Did you read the data sheet? It's all spec'd out in there. They're about twice as fast @ 10V than @ 5V Vdd. That said there are faster alternatives.

Chris

Ok then i think i will use the 4017. How about those alternatives?
 

BlinkingLeds

Feb 23, 2013
180
Joined
Feb 23, 2013
Messages
180
Have a look at the CD74HC109 J-K flip-flop with Schmitt trigger clock input. The Schmitt clock input would be a suitable interface for a phototransistor, and a J-K flip-flop can be configured into any kind of latch you might want.

I do have a 555 Schmitt that CDRIVE showed me. I don't now how to use a J-K flip flop and from what i understood from the datasheet it needs 2 signals one to tell it to go high and another signal on a different pin to go low. I need something that will have only one input pin like the 4017. Oh and of course i don't have anything like flip-flops lying around and it will take some time to get them. i only have 555 , 4017 , fets , transistors , AND , OR gates , inverting and non inverting buffers. What can i do with those?
 
Last edited:

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Use the 555 as a Schmitt trigger to clean up the signal from your phototransistor, and feed it into a 4017 with its reset input tied to its Q2 output. On every pulse the 4017 will alternate between Q0 high and Q1 high. Use a 12V power supply for maximum speed in the 4017.
 

BlinkingLeds

Feb 23, 2013
180
Joined
Feb 23, 2013
Messages
180
Use the 555 as a Schmitt trigger to clean up the signal from your phototransistor, and feed it into a 4017 with its reset input tied to its Q2 output. On every pulse the 4017 will alternate between Q0 high and Q1 high. Use a 12V power supply for maximum speed in the 4017.

So something like this then?

How much time will it take for the 4017 to reset after Q2 goes high?
 

Attachments

  • 123.jpg
    123.jpg
    53.4 KB · Views: 222

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Something exactly like that, yes.

According to the Texas Instruments and Fairchild data sheets, less than 0.4 us at 10V or higher supply voltage.

If you have a problem with a noisy or modulated light source causing multiple clocking, you can add a capacitor across the phototransistor.
 

BlinkingLeds

Feb 23, 2013
180
Joined
Feb 23, 2013
Messages
180
Something exactly like that, yes.

According to the Texas Instruments and Fairchild data sheets, less than 0.4 us at 10V or higher supply voltage.

If you have a problem with a noisy or modulated light source causing multiple clocking, you can add a capacitor across the phototransistor.

Wouldn't that generate a delay?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Yes. I suggested adding the capacitor only if you get unreliable clocking because the light source isn't steady, for example.
 

BlinkingLeds

Feb 23, 2013
180
Joined
Feb 23, 2013
Messages
180
ok but if i decide to add a capacitor anyway what would be the safe value that won't affect the timing much?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
That's kind of like asking "how long is a piece of string".

If your light source is a fluorescent light that flickers 100 or 120 times per second, you'll need to add significant capacitance (e.g. 0.1 uF or more) to prevent multiple clocking. That capacitance works by delaying the change in the phototransistor's collector voltage. Therefore it will delay the initial detection of the light significantly as well.

It also depends on the resistance of the pot in the phototransistor's collector circuit.

Perhaps I can explain how the circuit works, and how the capacitor will affect it.

The phototransistor is a variable current sink. It conducts a certain amount of current from its collector to its emitter. That amount of current is roughly proportional to the instantaneous amount of light it receives.

The potentiometer between the collector and VCC converts this current into a voltage. If the phototransistor is dark, and is sinking no current, there is no current through the pot, and therefore no voltage across it. Therefore the collector, and the 555's input, is at the VCC voltage (or nearly).

As the amount of light falling on the phototransistor increases, the phototransistor starts to sink current. This current flows through the pot, and causes the voltage across the pot to increase. This is another way of saying that the collector voltage decreases.

At a certain point, the voltage drops below the 1/3 VCC threshold of the 555's input, and the 555's output goes high. The 555 has a Schmitt trigger action that means that its output will stay high until its input rises above the higher threshold voltage, which is 2/3 VCC.

Now if you add a capacitor across the optocoupler, the capacitor will slow down the voltage change. Its behaviour is: the rate of change of the voltage across it is proportional to the current flowing into it.

It's a bit like a rechargeable battery - the more current you force into it, the quicker it charges, and the more current you draw out of it, the quicker it discharges. Except with a capacitor, everything is linear and smooth, unlike rechargeable batteries which only have a limited usable voltage range.

The formula for charge/discharge in a capacitor is:

dV / dT = I / C where
dV is the change in voltage, in volts;
dT is the time period, in seconds;
I is the current, in amps;
C is the capacitance, in farads. (Be careful here - 1 uF is only 1x10^-6 farads.)

This formula shows that applying or drawing more current to/from the capacitor will cause the voltage across the capacitor to increase or decrease at a faster rate.

It also shows that for a given current, a smaller capacitance will allow the voltage across it to change more quickly than a larger capacitance. This is why when you put a capacitor across part of a circuit to slow things down, a high capacitance has more effect than a low capacitance.

So let's connect a capacitor across the phototransistor, and assume there's no light on the phototransistor, so its collector voltage is roughly VCC. Now shine a light on the phototransistor.

The phototransistor will sink current. Some of this will come from the potentiometer, but some will also come from the capacitor. If we ignore the potentiometer, the collector voltage will drop at a rate that is determined by two factors:
(a) how much current the phototransistor is drawing (more current makes the voltage fall faster), and
(b) the amount of capacitance you've added (more capacitance makes the voltage fall more slowly).

At a certain point, the phototransistor's current and the current through the pot will be equal and the collector voltage will stabilise. But before they do, you will see a delay, due to the capacitor's presence.

It's convenient that a higher current (corresponding to a brighter light) will cause the capacitor to discharge more quickly. This means that the delay in responding to a bright light will be shorter than the delay in responding to only a small increase in light level.

If the illumination on the phototransistor decreases, the phototransistor will sink less current. There will now be a positive current flowing into the capacitor, because the potentiometer is trying to pull the collector voltage up towards VCC. Again this increasing voltage will be slowed down by the capacitor, and this will delay the detection of "dark". But it seems that in your case you are mainly concerned about the delay in detecting a change from dark to light, right?

So I'll plug some approximate numbers in, to make it a bit more concrete.

1. Let's say the circuit's supply voltage is 12V. This means the 555's input thresholds are at 8V and 4V.
2. Let's assume that the "brightness threshold set" potentiometer, from the phototransistor's collector to VCC, has been set to 20 kilohms. We have tested with our light source and found that to get the 555 to report "light present" (output high) at the illumination level that we want to initially detect as being "light" requires the trimpot to be set to 20 kilohms.
3. Initially, there is no capacitor.

We can calculate the phototransistor current that corresponds to "light". The threshold voltage for detection in this direction is 4V, so at that time, the pot has 8V across it. Use Ohm's Law, I = V / R, with V = 8 and R = 20k. The current is 400 uA (microamps).

Now let's add a 10 nF capacitor across the phototransistor and shine the same amount of light onto it. In this calculation I'm going to neglect the effect of the current drawn by the potentiometer, to simplify the calculations.

So initially the collector voltage is 12V (darkness). We shine a light on the phototransistor and it starts sinking 400 uA.

Ignoring the potentiometer, and just considering the capacitor, the collector voltage will fall at a certain rate, which can be calculated from dV / dT = I / C.
I = 400e-6
C = 10e-9
so dV / dT = 40,000V/s.

So to calculate the delay, we need to work out how long it will take for the collector voltage to drop from +12V to +4V, i.e. to drop by 8V.

40,000 = dV / dT rearranges to dT = dV / 40,000 which is 8 / 40,000 which is 200 us.

So adding a 10 nF capacitor delays detection of light by about 1/5000th of a second.

Those calculations are simplified because I ignored the effect of the current supplied by the potentiometer. I did that because the dV/dT=I/C equation can only be used in that simple form if the current is constant. This is roughly true of the phototransistor, but not true of the pot - the pot's current depends on the voltage across it, which varies significantly as the collector voltage falls during the time period I'm trying to calculate.

I hope this is interesting to you - or somebody :)
 
Last edited:

BlinkingLeds

Feb 23, 2013
180
Joined
Feb 23, 2013
Messages
180
Thanks for that huge explanation i read it all except for the equations (i'm not good with equations :) ) That gave me an idea: what if i set the pot to near zero ohms like 500ohms or 1k wouldn't that make the photo less sensitive and therefore prevent it from activating from unwanted light sources? That way i can get the same result as with the capacitor but without the time delay right?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
If you set the pot resistance to a low value, you will need more light on the phototransistor to activate the 555's output. That's the purpose of the pot. It sets the light sensitivity.

You decide how much light you want to be the minimum brightness that's guaranteed to activate the output, shine that amount of light on the phototransistor, and increase the pot's resistance until the 555 output activates.

The lower the pot's resistance, the more light is required to activate the 555.

That will make it less likely to activate from unwanted light sources, yes. But that wasn't the reason for the capacitor.
Yes. I suggested adding the capacitor only if you get unreliable clocking because the light source isn't steady, for example.
 

BlinkingLeds

Feb 23, 2013
180
Joined
Feb 23, 2013
Messages
180
Ooops sorry i misread that. My light source is steady in fact it's always on, i use the IR led - phototransistor pair as an photointerupter
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
OK, in that case the signal from the phototransistor will be very clean and you won't need a capacitor.
 

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
BL could you please explain the end function of your project? I ask because I have an idea to eliminate the 4017 but I need to know what the end product is going to be. Reading back over your Schmitt Trigger topic didn't clarify anything for me.

Chris
 

BlinkingLeds

Feb 23, 2013
180
Joined
Feb 23, 2013
Messages
180
sorry for the delay
I want to use it as an rpm counter and / or an on / off time counter
 

CDRIVE

Hauling 10' pipe on a Trek Shift3
May 8, 2012
4,960
Joined
May 8, 2012
Messages
4,960
sorry for the delay
I want to use it as an rpm counter and / or an on / off time counter

Oops, I missed this >>>

Ooops sorry i misread that. My light source is steady in fact it's always on, i use the IR led - phototransistor pair as an photointerupter

I have to regroup now because my feeble brain was working under the ass_umption that the light source was being keyed by remote button presses. Yes, nothing you said intimated that at all!

Chris
 
Top