Using a quad op amp can help compensate for a lack of rail-to-rail performance in an op amp one-shot design.
To sense animals moving I wanted to create a simple IR sensor that would trigger a monostable to generate a rather long pulse when an animal passed by. Further, while the animal remained in front of the sensor I wanted the pulse to stay set. I originally intended to use a 555 timer configured as monostable but I didn’t have any lying around and I needed this design as fast as possible. All I had to work with was a single supply (a 9V battery) and some op amps, but I did not want to use them as comparators. I started to think about how to create a rail-to-rail one-shot using cheap op amps and came up with this idea.
Figure 1 shows an idealized version of the circuit.
Figure 1 This circuit using ideal op amps will create a one-shot pulse that runs rail-to-rail.
The working principle is simple. Pressing the push button PB1, which corresponds to the IR sensor detecting an animal, charges capacitor C up to VCC through R1 with a short time constant. Releasing the push button allows the capacitor to discharge through R. Op-amp U1 buffers this exponential discharge and U1’s output voltage goes into a non-inverting Schmitt trigger with a voltage reference of VCC/2. While the capacitor voltage is over ¾ VCC (which it will quickly reach once the button is pushed because the time constant of R1*C is chosen to be very short), the output of U2 goes to VCC. Due to U2’s hysteresis, the output voltage will go to ground only when the capacitor voltage discharges to ¼ VCC. The output pulse duration is:
T = ln(4) RC ≈ 1.38 RC seconds (1)
Note that the time is independent of the supply voltage.
Simulation of the ideal circuit
Time to try the design via simulation. Let’s say we want a pulse-width of around 10 seconds. Using Equation 1, if we choose C = 50μF then R should be 144kΩ, and so if we are using 5% resistors the actual R = 150kΩ. With these values, T = 10.40 sec., as shown in Figure 2. We use ideal op amps and mimic the pushbutton’s activation with a time-varying value for R1, getting the results shown in Figure 3.
Figure 2 We can simulate the circuit using real component values and ideal op amps.
Figure 3 The simulation of the design in Figure 2, assuming ideal op amps, shows the behavior we expected.
The simulation shows that the circuit behaves as expected using ideal op amps, so the next step is to simulate it with a real op amp, such as the LM358, which does not have rail-to-rail capability, as shown in Figure 4. Given that the other components remain the same we would expect the same result, but that’s not what the simulation result says.
Figure 4 The design of Figure 2 using real op amps should also show the behavior we expect.
Using an op amp without rail-to-rail capability, yields a pulse duration that is not T ≈ 1.38RC (Figure 5). Why is that? Well, since the output of U2 cannot reach VCC, the non-inverting input of U2 also starts at a lower voltage than VCC. But the threshold voltage needed to set the Schmitt trigger to ground is still set to VCC/2, which is now greater than half the expected output voltage. So, the circuit triggers early.
Figure 5 The simulation using LM358 op amps, instead of ideal ones, yields a different result.
How can we solve that problem? At first I thought about using a trimmer at the inverting input of U2 to set the trigger threshold properly. We can measure the maximum output voltage of U2 and then adjust the inverting input to 0.5VoU2MAX. It is a simple method and works quite well (as you will see in the testing section). However, the method is not “bulletproof” and it won’t work for different supply voltages; you would have to trim the circuit for each different supply voltage.
Wow the engineering world with your unique design: Design Ideas Submission Guide
If, however, you have available a quad op-amp IC like the LM324 (which is a quad LM358), or in the worst case another op amp of the type you are already using for U1 and U2, you can employ the configuration shown in Figure 6.
Figure 6 Reconfiguring the design to use a quad op amp, such as the LM324, can help compensate for a lack of rail-to-rail performance.
Let’s test it using R = 100 kΩ and C = 47 μF, so T = 6.51 sec. We get the results shown in Figure 7. We see a pulse width around 6.60 seconds for several different supply voltages. This is close enough to what we desire, so let’s move on to the real world.
Figure 7 Simulating the configuration of Figure 6 shows a consistent pulse width independent of the supply voltage.
Real-world testing
Building up the circuit of Figure 4 with a trimmer incorporated (Figure 8) and testing the performance gives the results shown in Figure 9. After trimming the input for the LM358 at 9V, we can see that the circuit works well. However, different trimming is necessary for every supply voltage.
Figure 8 This test version of the circuit of Figure 4 uses one LM358 and a trimmer.
Figure 9 Test results when using one LM358 and a 100 k trimmer (C = 47 μF, R = 100k, R1= 100, T = 6.51 sec.) show that the real circuit works as expected.
Implementing the circuit of Figure 6 allows us to test if the design will generate the target pulse width despite the lack of rail-to-rail performance (Figure 10). The output pulse is the intended value of 6.51 sec. (Figure 11). The real pulse measures 6.767 seconds, which is close enough given the component’s tolerances.
Figure 10 Using one LM324 in the design of Figure 6 allows the monostable circuit to output a supply-tolerant pulse.
Figure 11 A test of the circuit using one LM324 (C = 47 μF, R = 100 k, R1= 100, T = 6.51 sec.) shows the expected output pulse width.
There are several factors to consider when implementing this approach. First, it is better to choose rather big (even if leaky) capacitors for C rather than big resistors for R. If resistor R is too big, the intrinsic parallel resistance of C is in parallel with R, and the combination will be less than the smaller of the two, so the circuit will discharge with a time constant based on the parasitic resistance of C rather than on R.
Second, choose the time constant τ = R1C to be small compared to the push button’s pulse width (or whatever you use as the push button). For a mechanical push button, I would use 10 msec; for the motion sensor 10 msec is good as well. (If an animal can go past the sensor faster than 10 msec, I will be really impressed.)
Finally, beware the op-amps’ slew rates and if possible, select rail-to-rail op amps to keep the timing reliable.
If you want to know all the math behind the circuit so you can adjust different parameters, this document includes mathematical explanations so you can try new configurations.
This article was originally published on EDN.
Related articles: