Electronic Design

Measure Nanoseconds With A PIC Microcontroller

Nanosecond interval timers are a critical component in products as diverse as time-domain reflectometers (TDRs), collision-avoidance systems, radar altimeters, and nuclear instrumentation. This simple circuit, which runs off a single 5-V supply, allows a PIC 16F877 to measure pulse lengths from 2 to 950 ns with a 1-ns resolution. Linearity over the full dynamic range is ±1 count.

Referring to Figures 1 and 2, the input pulse (VIN) and the trigger are applied to the circuit at the same time. In this application, the PIC reads its ADC 240 µs after receiving the interrupt on the trigger input. A 2-V input pulse causes 11.5 mA to flow through Q1, Q2, and R7. Q1 and Q2 form a temperature-compensated pair of emitter followers. The current flowing through Q2 and R7 is identical due to the current mirror formed by Q3, Q4, and Q5. The biasing provided by R2 and R3 eliminates voltage droop on C1 by ensuring that Q2 remains off until the input voltage exceeds 0.7 V. C1 integrates the current for the duration of the input pulse, producing a voltage at B proportional to its width.

Figure 3 shows the input pulse and the response at B on a faster time scale and at higher resolution than shown in Figure 2. U1 amplifies and buffers the signal at B and drives the ADC (node C). Note that the ramp on trace C in Figure 2 is due to the op amp's step response, not because of integration on C1. After the ADC is read, the PIC resets the circuit via Q6. Resistors R4, R5, R6, R7, and R8 damp transients that would degrade linearity.

For prototyping purposes, the matched pairs Q1-Q2 and Q3-Q4 can be made by selecting transistors with a closely matched VBE and gluing them together with five-minute epoxy. Refer to Pease Porridge "What's All This Logarithmic Stuff, Anyhow?" (Electronic Design June 14, 1999, p. 111) for the procedure. In production, matched arrays such as the T320 and T340 (www.thatcorp.com) would be appropriate.

Board layout is critical for maximum performance. Leads should be very short, and node B in particular should have as little inductance as possible. Star ground and power distribution is recommended for all components between VIN and the op amp. On the prototype, the noise at C is less than 1 mV p-p, corresponding to a time resolution of under 200 ps. The 10-bit ADC limits the resolution to 1 ns. Adding a higher-resolution external ADC would improve performance accordingly.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.