1
\$\begingroup\$

This question is kinda similar to highly-asymmetrical-rise-and-fall-times, but I think that the data sheet is already suggesting that I'm at the optimum design. Resistor changes were the answer to that particular question.

I have this:-

my circuit

which produces this output that's fed into an Arduino digital input:-

trace

with 1 V and 200 nS /div settings. It's clear that the LM311P comparator is being thrashed beyond it's slew rate which is okay. You can see the relatively slow rise time in comparison to the fall time. The data sheet suggests a 500 Ohm pull up resistor. That's about 10 mA of current which seems a lot for a logic circuit. I'm assuming that as they've used the 500 value for their timing diagrams, this is the optimum value and maximises speed. I realise that the rise /fall times are different on the datasheet, but is this the only reason for my asymmetry? And if so, is there no solution to equalising them any better? Even if a solution eludes me, I'd be happy with an explanation.

The reason for the output pulses not reaching the full 5V level as been asked. The inputs to the comparator are white noise from the Zeners, which looks like:-

zener input

I don't think that it's oscillations, it's just too fast for the 120 ns switch time. The Rigol's FFT display is naff so I can't accurately measure the spectrum /frequency.

\$\endgroup\$
  • \$\begingroup\$ What causes those 10% height and 50% height pulses? Are those oscillation of the LM311? \$\endgroup\$ – analogsystemsrf Apr 25 '17 at 6:14
  • 1
    \$\begingroup\$ Find a comparator with a push-pull output stage. \$\endgroup\$ – Brian Drummond Apr 25 '17 at 8:28
  • \$\begingroup\$ @analogsystemsrf No. Look at the inputs to the comparator. It's pure white noise from 2 sources that are then compared. I think those diodes are emitting at >10 MHz but I don't know how to measure it exactly as it's random. It's faster than the comparators slew rate so it can't reach the 5V level all the time. There's an edit... \$\endgroup\$ – Paul Uszak Apr 25 '17 at 9:50
  • \$\begingroup\$ Schmitt trigger is another option. Though your digital input may already have one. \$\endgroup\$ – Phil Frost Apr 25 '17 at 13:26
4
\$\begingroup\$

Your rise and falls times aren't all that asymmetrical. Sure, the rising edge has that long tail as it approaches +5, but that really doesn't matter, since you are driving a digital input. What counts is the time from either 0 or +5 to (approximately) the mid=point, and from the looks of the scope traces that is a few tens of nanoseconds. If you need better symmetry you're probably better off with a higher-speed comparator.

So let's start by dropping back to basic questions. How much symmetry do you need, and why?

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I hadn't considered the midpoint. You're right! Digital on is about 0.6Vcc and off about 0.3Vcc for an Arduino according to the datasheet. It's a digital entropy source for a true random number generator, so I'd like to eliminate as much bias as possible at the hardware stage. I get about 15% bias which I can live with. I just wanted to know if it can get better, but I think you've shown me that it's fairly good as it is... \$\endgroup\$ – Paul Uszak Apr 25 '17 at 10:36
3
\$\begingroup\$

That's an open collector or emitter comparator, as such it is only active on one edge.

enter image description here

Find a comparator that is push-pull or logic level outputs.

BTW: The 500R resister can be dropped a bit since it can sink sink 50mA but that is not really the right approach.

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

Here is the circuit you are asking about:

The complaint is asymmetrical rise and fall times, but there are other issues too.

First, the slow rise time and fast fall times are exactly what should be expected from this circuit. This is because the LM311 has a open collector output. That means it actively drives the output low, but it is up to the external circuit to drive it high. That can be convenient for level shifting, but results in asymmetric rise and fall times.

There is a lower impedance driving the signal low than driving it high. With the same capacitance on the line, the time constant is longer going high than low.

The fix is to use a comparator or opamp with symmetric output drive. These will drive to the power rails of the device, so now you have to change the opamp power strategy.

Since you want a 0-5 V digital signal out, I'd start with a opamp that can run from 5 V and has rail to rail output. There are many to chose from. One example is the MCP6021. It has complementary CMOS output, 500 µV offset, and goes to 10 MHz.

Now you have to figure out how to keep the input signals within the opamp's valid range, which is 0-5 V for the MCP6021 running from 5 V. With the -15 V supply and 24 V Zeners, the nominal signal levels are at 9 V. You want those to be about 2.5 V intead. One possibility is to use a -21.5 V supply instead of the -15 V supply. This is no longer powering the opamp, just the bottom of the Zeners, so doesn't need much current capability at all. A charge pump can do this.

For extra credit, you could even control the charge pump closed loop to try to keep the average of the two signals close to 2.5 V.

A possibly better alternative is to flip the input around with the bottom ends of R1 and R2 tied to ground and the top ends to the anodes of the Zeners. Now you only need to make a positive 26.5 V or so. Again the current is so low that a filtered charge pump from the +15 V supply can do this easily.

Added

AC coupling the two inputs alleviates the need for any new supplies. You already have +15, +5, and -15 volts available. With AC coupling, that's all you need:

R1 and R2 form a voltage divider to make half of the opamp supply. C2 reduces noise on that node. I know this is a noise generator, but the kind of noise on the 5 V supply is not likely to be random. R5 and R6 DC couple this midpoint voltage to both opamp inputs. This coupling is deliberately high impedance to minimally interfere with the AC component on the opamp inputs.

R3, R4, D1, and D2 are your avalanche breakdown noise sources as before. C3 and C4 couple the AC components of that noise to the opamp inputs.

With the values shown, the high pass filter rolloff is about 160 mHz. That means the result isn't truly random in that very long term continuously high or low sequences will get truncated. However, at such low frequencies there are other sources of error anyway.

Random bit stream generation

You don't say what your application is, but most likely trying to get every last bit of true randomness from the circuit is missing the point. Usually the electronic random noise generator is followed by a digital hash function.

A CRC generator is a good example. A 32 bit CRC is a good pseudo-random generator. Unless you look at very long sequences where the limited 232 states becomes relevant, sequence snippets are pretty much indistinguishable from truly random signals. All you need is to give the CRC a occasional random kick, and the result becomes basically truly random.

In this case, every time you want a new random bit, feed the threshold-detected result of this circuit into the CRC and use the bit shifted off the end. Even if this circuit were to have correlation or other patterns over a few bits, the CRC will hash those in the short term. The randomness of the circuit will cover up the non-randomness of the CRC in the long term.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

One must be careful of feedback, especially where input impedances are high.
It is also possible that the 10 mA ground current from pin 1 influences the +15V or -15V supply via C1 and C2. Ground routing and bypass capacitor positions on the three supplies (+15, -15, +5v) might influence rise/fall times. However, 'scope photo shows little "ringing", which suggests this isn't likely.
Over-driving inputs helps to make rise/fall times more equal.

Your results are not too far from what the data sheet suggests....but there is one more thing that is a little odd:
It appears that the comparator's "high" output is +4.3 V and fails to rise to +5.0 V as the schematic suggests it should. There are a number of possibilities here:

  • Your 'scope calibration is poor.
  • Your +5V supply is on the low side.
  • Another load resistor is pulling it down

The load is a microcontroller input pin, which should be a high-impedance load, adding only a little capacitance. Could the microcontroller have a +3.6V power supply? If so, your microcontroller is at risk of failure. If the microcontroller is powered from +5V then you should discover why your comparator output doesn't reach the supply voltage when its output switch is off. (Leakage current is only 50 nA max).

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ It's an Arduino Uno running from the USB connector. When it's powered like this, Vcc is actually 4.72V not 5V. My USB power is about 5.05V, but I think that there's a FDN340P MOSFET switch on the Uno that drops the 0.3 volts. It's T1 along the USBVCC line in the schematic arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf. And there's also polyfuse that I think has a 0.15 Ohm resistance that drops another .05V. \$\endgroup\$ – Paul Uszak Apr 25 '17 at 10:15
0
\$\begingroup\$

If the pulldown is fast enough, and the pullup is NOT fast enough, use a lower impedance pullup. A resistor divider (pullup 220 ohms to +5 and pulldown 330 ohms to GND) will give you 132 ohms drive

schematic

simulate this circuit – Schematic created using CircuitLab

impedance and is a common solution for fast-rise TTL drive into circa 110 ohm transmission lines. The logic input should have no trouble with the less-than-5V input levels.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.