Triggering problem: How do I filter out short pulses?

hgmjr

Joined Jan 28, 2005
9,027
You will probably need to aperture the photo-diode. That is to say you will need to place a short length of hollow tube directly in front of the photodiode. This helps eliminate the interference from the ambient light. You probably have your setup in a room with fluorescent lighting. That is probably the source of the 60Hz or 120Hz noise. Turn off the lights and see if the noise goes away.

hgmjr
 
Last edited:

gootee

Joined Apr 24, 2007
447
Finally, here is the scheme. The top circuit is the one I currently have. The low pass filter on the left was built following a recommendation of the photodiode manufacturer. Removing it did not make much difference in my application.

The bottom circuit is an idea I thought about last night for the rejection of short pulses. I think it should pass on pulses longer than T=R1C1. It does not conserve the lenge of the allowed pulses, since after passing through they become shorter by T seconds. This does not matter much in my application since T is rather short (<1ms) and I can sustain such a delay in triggering the camera.

Please respond if you have any comment regarding each of the two circuits.

Thanks!

N.
So what might be the source of the interfering pulses?

Could RF be getting in? It would get rectified by semiconductor junctions and could cause many sorts of weirdnesses, including output blips.

Do you have all of the power supply and reference voltage connection points bypassed to ground with small ceramic capacitors (typically 0.01 to 0.1 uF, and probably a little lossy like X7R type), right at where they connect to something in your circuit? You could even put a few tens of ohms or more of resistance in series before the caps, if your circuit can stand it.

Remember that for RF, "inputs" also include outputs, and power supply connections, as well as all conductors.

And remember also that RF isn't just from radio transmitters. An electromagnetic event that is very short in the time domain will tend to produce a very broad frequency spectrum; think light switches, HVAC relays, etc.

Can you put proper RF low-pass filters on all of the opamp and comparator inputs, or connect a couple hundred picofarads across their input pins, without losing something your applcation needs?

You should probably also put a capacitor in parallel with any opamp's negative-feedback resistor, if your application can handle it (but not in parallel with the positive-feedback R shown in your schematic).

And you should have a couple of low-ish value resistors in series with each opamp and comparator output, with a capacitor to ground from between them (calculate value for low-pass filtering somewhat above desired frequencies).

For better and more-detailed information about all of the above, see Section 7 (and others) of http://www.analog.com/library/analogdialogue/archives/39-05/op_amp_applications_handbook.html (a free download of the book "Op Amp Applications Handbook", Walt Jung, Editor Emeritus).

Cheers,

Tom Gootee
 
Last edited:

Thread Starter

Neptune24

Joined Dec 9, 2010
27
You will probably need to aperture the photo-diode. That is to say you will need to place a short length of hollow tube directly in front of the photodiode. This helps eliminate the interference from the ambient light. You probably have your setup in a room with fluorescent lighting. That is probably the source of the 60Hz or 120Hz noise. Turn off the lights and see if the noise goes away.

hgmjr

hgmjr,

You exactly described the configuration of my system. The photodiode is mounted inside an 8 inch aluminum tube. In front of the tube I have a 633nm notch filter. Regarding the fluorescent lights in the room, I have already verified that they do not contribute to the 120Hz noise - I turned off these lights and the noise amplitude remained the same.

What do you think about the circuit I proposed for rejecting short pulses?

Thanks,

N.
 

hgmjr

Joined Jan 28, 2005
9,027
hgmjr,


What do you think about the circuit I proposed for rejecting short pulses?

Thanks,

N.
What I would like to do at present is see what benefits you can derive from the current mirror that I have suggested. If spikes are still an issue using the current mirror then we can look at what can be done to suppress them.

Thanks for the compliment on my font. My generation of engineers did not learn our craft in the age of computers and hand held calculators. We got along just fine with slide rules and pencils.

hgmjr
 

Ron H

Joined Apr 14, 2005
7,063
I have attached a schematic of a current mirror that should give you a significant improvement in both response and voltage gain.

The trick to interfacing to a photodiode is to present it with a constant reverse bias. Another advantage to maintaining a near constant voltage across it will result in the maximum frequency response.

hgmjr
With the present circuit, he is getting 1V across 4.7k, which means the incident light power on the photodiode is causing it to pass about 200uA. With the current mirror, the load resistor will need to be about 20kΩ or less to prevent saturation of the transistor.
I agree that the response time and gain will improve, but response time is not an issue here. The diode's capacitance is 40pF, which, even if he had a 20k load resistor and 10pF of stray capacitance, would still result in 2.2uS risetime due to a step of illumination.
I'm not saying the current mirror is a bad thing. I just don't see much if any advantage. Also, transistor matching and thermal coupling will have to be addressed.
In either case, Neptune24 needs to get rid of the DC offset, and add some gain, by adding an AC amplifier. The offset will change with changes in illumination, and temperature due to diode leakage, so the presently used fixed threshold will probably not work unless the signal is AC coupled.
 

hgmjr

Joined Jan 28, 2005
9,027
With the photodiode conduction current at 200uA when illuminated, then the 20K should work fine. The beauty of a current mirror is that it permits the designer to choose a value of output resistance best suited to the current being generated without worrying about adversely effecting the response of the photodiode. It also maintains a constant reverse bias voltage across the photodiode which enhances the photodiode's frequency response. It also provides a convenient node to introduce low pass filtering by simply placing the appropriate value of capacitance in parallel with the output collector resistor.

I have used this approach very successfully with a phototransistor in place of the photodiode. The improved detector response was significant.

hgmjr
 

Thread Starter

Neptune24

Joined Dec 9, 2010
27
With the photodiode conduction current at 200uA when illuminated, then the 20K should work fine. The beauty of a current mirror is that it permits the designer to choose a value of output resistance best suited to the current being generated without worrying about adversely effecting the response of the photodiode. It also maintains a constant reverse bias voltage across the photodiode which enhances the photodiode's frequency response. It also provides a convenient node to introduce low pass filtering by simply placing the appropriate value of capacitance in parallel with the output collector resistor.

I have used this approach very successfully with a phototransistor in place of the photodiode. The improved detector response was significant.

hgmjr

hjmgr,

I built your current mirror using two PN2907 transistors and a low-pass filter at the outlet as you suggested. I found that the current mirror improved the stability of the photodiode circuit as follows: without the mirror the circuit exhibited very strong 'ringing' oscillations after it was triggered. These oscillations had amplitude of more than 5V and frequency of around 13.6MHz. The oscillations decayed relatively fast, within a few microseconds. I haven't noticed these oscillations until now since I did not look at such short time scales and my scope seem to smear these oscillations when looking on longer scales. The good thing is that the current mirror abolished these oscillations. However, it introduced similar oscillations (only a bit slower) when the circuit returned from its triggered state to the normal state. Other than that, as far as I noticed, the signal obtained from the photodiode was very similar to the one I got without the mirror (and with the same low-pass filter between the diode and the comparator). Therefore, preferred to keep my previous configuration, especially because the high-frequency oscillations bother me most when they arise after a triggering event ends, whereas they do not really bother me during such an event since the trigger is on anyway.

To reject short pulses I used an modified version of the circuit I drew in one of my previous posts. The idea is to have the square pulse charge a capacitor and use a comparator with hysteresis to detect when the capacitor is 50% charged. Only pulses that are longer than the 50% charging time (T~20us) will be transmitted onwards by this module. The resulting pulse is shorter by T and delayed by T, but these facts do not matter much for my application as the camera can be triggered by a very short pulse and T is a delay I can easily suffer. I am aware of the fact that is it a much better practice to manipulate an analog signal before it is being transformed into a logical one, but this is the only idea I had so far and it seems to solve most of the issues I was talking about.

Another problem that I did not mention so far, is the fact that the laser baseline power has substantial drifts, especially during the first few hours since it is turned on. When the intensity changes I either get many false triggering events or loose detection sensitivity, since my activation threshold is set manually. What I do now is just to turn the laser on a night before I run the system, which helps to overcome most of the drifts, but still requires tweaking the threshold every few minutes. However, I was wondering if there is a simple way to dynamically set the threshold. Maybe it is possible to use an integration circuit that will calculate a 'running average' of the photodiode voltage during a previous, predetermined interval. Then, the threshold could be set dynamically as either a predetermined fraction of the mean (say 99% to detect 1% drops) or as a an absolute voltage below this mean (say 25mV below the running average). Is this feasible, in your opinion?

Thanks for your help,

N.
 

hgmjr

Joined Jan 28, 2005
9,027
hjmgr,

I built your current mirror using two PN2907 transistors and a low-pass filter at the outlet as you suggested. I found that the current mirror improved the stability of the photodiode circuit as follows: without the mirror the circuit exhibited very strong 'ringing' oscillations after it was triggered. These oscillations had amplitude of more than 5V and frequency of around 13.6MHz. The oscillations decayed relatively fast, within a few microseconds. I haven't noticed these oscillations until now since I did not look at such short time scales and my scope seem to smear these oscillations when looking on longer scales. The good thing is that the current mirror abolished these oscillations. However, it introduced similar oscillations (only a bit slower) when the circuit returned from its triggered state to the normal state. Other than that, as far as I noticed, the signal obtained from the photodiode was very similar to the one I got without the mirror (and with the same low-pass filter between the diode and the comparator). Therefore, preferred to keep my previous configuration, especially because the high-frequency oscillations bother me most when they arise after a triggering event ends, whereas they do not really bother me during such an event since the trigger is on anyway.
Your description of the ringing may be originating out of the laser rather than a ringing introduced by the photodiode interface. The reason that the current mirror has a slower ringing response is that the output may be seeing some capacitance. I have never seen the current mirror misbehave as you have described but for whatever reason it appears not to meet your needs. I recommend you keep the current mirror circuit in mind the next time you need an interface circuit for a photodiode or phototransistor. It may be just the ticket next time.

hgmjr
 

Ron H

Joined Apr 14, 2005
7,063
Another problem that I did not mention so far, is the fact that the laser baseline power has substantial drifts, especially during the first few hours since it is turned on. When the intensity changes I either get many false triggering events or loose detection sensitivity, since my activation threshold is set manually. What I do now is just to turn the laser on a night before I run the system, which helps to overcome most of the drifts, but still requires tweaking the threshold every few minutes. However, I was wondering if there is a simple way to dynamically set the threshold. Maybe it is possible to use an integration circuit that will calculate a 'running average' of the photodiode voltage during a previous, predetermined interval. Then, the threshold could be set dynamically as either a predetermined fraction of the mean (say 99% to detect 1% drops) or as a an absolute voltage below this mean (say 25mV below the running average). Is this feasible, in your opinion?

Thanks for your help,

N.
I mentioned this problem in post #46. Attached is how I would deal with the drift. I don't remember exactly what your range of pulse widths is. I put in a couple of single-pole filters with ≈1mS time constant. You might have to change those. Also, you can change the ranges on gain, threshold, and hysteresis.
I did not attempt to filter out 120Hz, so if you have not solved that problem, it would still have to be dealt with.
I included the .ASC file, in case you want to simulate it on LTspice.
 

Attachments

Thread Starter

Neptune24

Joined Dec 9, 2010
27
I mentioned this problem in post #46. Attached is how I would deal with the drift. I don't remember exactly what your range of pulse widths is. I put in a couple of single-pole filters with ≈1mS time constant. You might have to change those. Also, you can change the ranges on gain, threshold, and hysteresis.
I did not attempt to filter out 120Hz, so if you have not solved that problem, it would still have to be dealt with.
I included the .ASC file, in case you want to simulate it on LTspice.
Ron H,

Thanks a lot! It will take me some time to figure out how this circuit works. On the meantime, I could not find the library files for the LM393 you have used (and maybe also LM358 - I can't tell if it is included in my LTSpice package). Could you please direct me to the place where I can find the files you have used?

Thanks again for you time,

Neptune24.
 

Ron H

Joined Apr 14, 2005
7,063
Ron H,

Thanks a lot! It will take me some time to figure out how this circuit works. On the meantime, I could not find the library files for the LM393 you have used (and maybe also LM358 - I can't tell if it is included in my LTSpice package). Could you please direct me to the place where I can find the files you have used?

Thanks again for you time,

Neptune24.
Here are the subcircuits.
Rich (BB code):
*////////////////////////////////////////////////////////////////////
* For ordering or technical information on these models, contact:
* National Semiconductor's Customer Response Center
*                 7:00 A.M.--7:00 P.M.  U.S. Central Time
*                                (800) 272-9959
* For Applications support, contact the Internet address:
*  amps-apps@galaxy.nsc.com

*//////////////////////////////////////////////////////////
*LM358 DUAL OPERATIONAL AMPLIFIER MACRO-MODEL
*//////////////////////////////////////////////////////////
*
* connections:      non-inverting input
*                   |   inverting input
*                   |   |   positive power supply
*                   |   |   |   negative power supply
*                   |   |   |   |   output
*                   |   |   |   |   |
*                   |   |   |   |   |
.SUBCKT LM358    1   2  99  50  28
*
*Features:
*Eliminates need for dual supplies
*Large DC voltage gain =             100dB
*High bandwidth =                     1MHz
*Low input offset voltage =            2mV
*Wide supply range =       +-1.5V to +-16V
*
*NOTE: Model is for single device only and simulated
*      supply current is 1/2 of total device current.
*      Output crossover distortion with dual supplies
*      is not modeled.
*
****************INPUT STAGE**************
*
IOS 2 1 5N
*^Input offset current
R1 1 3 500K
R2 3 2 500K
I1 99 4 100U
R3 5 50 517
R4 6 50 517
Q1 5 2 4 QX
Q2 6 7 4 QX
*Fp2=1.2 MHz
C4 5 6 128.27P
*
***********COMMON MODE EFFECT***********
*
I2 99 50 75U
*^Quiescent supply current
EOS 7 1 POLY(1) 16 49 2E-3 1
*Input offset voltage.^
R8 99 49 60K
R9 49 50 60K
*
*********OUTPUT VOLTAGE LIMITING********
V2 99 8 1.63
D1 9 8 DX
D2 10 9 DX
V3 10 50 .635
*
**************SECOND STAGE**************
*
EH 99 98 99 49 1
G1 98 9 POLY(1) 5 6 0 9.8772E-4 0 .3459
*Fp1=7.86 Hz
R5 98 9 101.2433MEG
C3 98 9 200P
*
***************POLE STAGE***************
*
*Fp=2 MHz
G3 98 15 9 49 1E-6
R12 98 15 1MEG
C5 98 15 7.9577E-14
*
*********COMMON-MODE ZERO STAGE*********
*
*Fpcm=10 KHz
G4 98 16 3 49 5.6234E-8               
L2 98 17 15.9M
R13 17 16 1K
*
**************OUTPUT STAGE**************
*
F6 50 99 POLY(1) V6 300U 1
E1 99 23 99 15 1
R16 24 23 17.5
D5 26 24 DX
V6 26 22 .63V
R17 23 25 17.5
D6 25 27 DX
V7 22 27 .63V
V5 22 21 0.27V
D4 21 15 DX
V4 20 22 0.27V
D3 15 20 DX
L3 22 28 500P
RL3 22 28 100K
*
***************MODELS USED**************
*
.MODEL DX D(IS=1E-15)
.MODEL QX PNP(BF=1.111E3)
*
.ENDS
*$
Rich (BB code):
* LM393 VOLTAGE COMPARATOR "MACROMODEL" SUBCIRCUIT
* CREATED USING PARTS VERSION 4.03 ON 03/07/90 AT 14:17
* REV (N/A)
* CONNECTIONS:   NON-INVERTING INPUT
*                | INVERTING INPUT
*                | | POSITIVE POWER SUPPLY
*                | | | NEGATIVE POWER SUPPLY
*                | | | | OPEN COLLECTOR OUTPUT
*                | | | | |
.SUBCKT LM393    1 2 3 4 5
*
  F1    9  3 V1 1
  IEE   3  7 DC 100.0E-6
  VI1  21  1 DC .75
  VI2  22  2 DC .75
  Q1    9 21  7 QIN
  Q2    8 22  7 QIN
  Q3    9  8  4 QMO
  Q4    8  8  4 QMI
.MODEL QIN PNP(IS=800.0E-18 BF=2.000E3)
.MODEL QMI NPN(IS=800.0E-18 BF=1002)
.MODEL QMO NPN(IS=800.0E-18 BF=1000 CJC=1E-15 TR=807.4E-9)
  E1   10  4  9  4  1
  V1   10 11 DC 0
  Q5    5 11  4 QOC
.MODEL QOC NPN(IS=800.0E-18 BF=20.29E3 CJC=1E-15 TF=942.6E-12 TR=543.8E-9)
  DP    4  3 DX
  RP 3  4 46.3E3
.MODEL DX  D(IS=800.0E-18)
*
.ENDS
Copy and paste these into two Notepad files. Save them in yourLTspice.../sub folder as LM358.sub and LM393.sub, respectively. You will then have to restart LTspice.
 
Last edited:

Thread Starter

Neptune24

Joined Dec 9, 2010
27
Here are the subcircuits.

Copy and paste these into two Notepad files. Save them in yourLTspice.../sub folder as LM358.sub and LM393.sub, respectively. You will then have to restart LTspice.

Thanks Ron H.

I put the files in the "sub" folder, but now get another error message when trying to run the simulation:

"Missing model value for Q:u1:1"

What does it mean?

I do not know if it is related, but I had to find also a potentiometer model and used the following pot.sub:

* This is the potentiometer
* _____
* 1--|_____|--2
* |
* 3
*
.SUBCKT potentiometer 1 2 3
.param w=limit(wiper,1m,.999)
R0 1 3 {Rtot*(1-w)}
R1 3 2 {Rtot*(w)}
.ENDS

Do you have any idea what I need to do in order to run your file?

Nepune24.
 

Ron H

Joined Apr 14, 2005
7,063
I realized in the middle of the night that you would need the pot files.
Put pot.sub in your .../lib/sub folder.
Put pot.asy in your .../lib/sym/misc folder.
 

Attachments

Ron H

Joined Apr 14, 2005
7,063
Did you unzip the files before putting them in their respective directories?
Did you restart LTspice after adding the files?
 

Thread Starter

Neptune24

Joined Dec 9, 2010
27
Did you unzip the files before putting them in their respective directories?
Did you restart LTspice after adding the files?
Yes and yes. By the way, I noticed that the LM358 file has no ".ENDS" command. Is it possible that it was truncated for some reason? I added the ".ENDS" at the end and it still did not work. In fact, I got the same error message even when I removed both LM358.sub and LM393.sub from the "sub" directory. Before I put them for the first time I got an error message saying that the LM393.sub is missing.
 

Ron H

Joined Apr 14, 2005
7,063
Apparently I screwed up LM358.sub. Here it is again.
Rich (BB code):
*////////////////////////////////////////////////////////////////////
* For ordering or technical information on these models, contact:
* National Semiconductor's Customer Response Center
*                 7:00 A.M.--7:00 P.M.  U.S. Central Time
*                                (800) 272-9959
* For Applications support, contact the Internet address:
*  amps-apps@galaxy.nsc.com

*//////////////////////////////////////////////////////////
*LM358 DUAL OPERATIONAL AMPLIFIER MACRO-MODEL
*//////////////////////////////////////////////////////////
*
* connections:      non-inverting input
*                   |   inverting input
*                   |   |   positive power supply
*                   |   |   |   negative power supply
*                   |   |   |   |   output
*                   |   |   |   |   |
*                   |   |   |   |   |
.SUBCKT LM358    1   2  99  50  28
*
*Features:
*Eliminates need for dual supplies
*Large DC voltage gain =             100dB
*High bandwidth =                     1MHz
*Low input offset voltage =            2mV
*Wide supply range =       +-1.5V to +-16V
*
*NOTE: Model is for single device only and simulated
*      supply current is 1/2 of total device current.
*      Output crossover distortion with dual supplies
*      is not modeled.
*
****************INPUT STAGE**************
*
IOS 2 1 5N
*^Input offset current
R1 1 3 500K
R2 3 2 500K
I1 99 4 100U
R3 5 50 517
R4 6 50 517
Q1 5 2 4 QX
Q2 6 7 4 QX
*Fp2=1.2 MHz
C4 5 6 128.27P
*
***********COMMON MODE EFFECT***********
*
I2 99 50 75U
*^Quiescent supply current
EOS 7 1 POLY(1) 16 49 2E-3 1
*Input offset voltage.^
R8 99 49 60K
R9 49 50 60K
*
*********OUTPUT VOLTAGE LIMITING********
V2 99 8 1.63
D1 9 8 DX
D2 10 9 DX
V3 10 50 .635
*
**************SECOND STAGE**************
*
EH 99 98 99 49 1
G1 98 9 POLY(1) 5 6 0 9.8772E-4 0 .3459
*Fp1=7.86 Hz
R5 98 9 101.2433MEG
C3 98 9 200P
*
***************POLE STAGE***************
*
*Fp=2 MHz
G3 98 15 9 49 1E-6
R12 98 15 1MEG
C5 98 15 7.9577E-14
*
*********COMMON-MODE ZERO STAGE*********
*
*Fpcm=10 KHz
G4 98 16 3 49 5.6234E-8               
L2 98 17 15.9M
R13 17 16 1K
*
**************OUTPUT STAGE**************
*
F6 50 99 POLY(1) V6 300U 1
E1 99 23 99 15 1
R16 24 23 17.5
D5 26 24 DX
V6 26 22 .63V
R17 23 25 17.5
D6 25 27 DX
V7 22 27 .63V
V5 22 21 0.27V
D4 21 15 DX
V4 20 22 0.27V
D3 15 20 DX
L3 22 28 500P
RL3 22 28 100K
*
***************MODELS USED**************
*
.MODEL DX D(IS=1E-15)
.MODEL QX PNP(BF=1.111E3)
*
.ENDS
*$
I also edited my original post, for the benefit of those who don't read this far.
I'm not sure what's causing the rest of your problems.
 
Top