Generating precise nanoseconds pulses with a microcontroller

Introduction

Microcontrollers are often required to generate timed output nanoseconds pulses. The pulse width of the pulses that can be generated from a microcontroller is limited by its clock speed. In an optical LiDAR system, it may desirable to generate nanoseconds pulses to drive a laser driver for instance with a microcontroller. This post describes how to generate precise nanoseconds pulses with a microcontroller irrespective of its clock speed.

For an Arduino, functions like digitalWrite and digitalRead is performed using a number of clock cycles. At 8MHz that’s 125ns per instruction, so from the point of toggling a pin on to the point of turning off would give you 4 instructions to play with..This is not adequate for generating narrow pulses. To overcome this limitation, an external circuit which uses a monostable multivibrator can be used and this post provides the schematic and test of such circuit.

Monostable Multivibrator

A multivibrator is an electronic circuit used to implement systems such as oscillators, timers and flip-flops. A monostable multivibrator is also known as a one-shot multivibrator. For a monostable multivibrator, one of the states is stable and the other state is unstable. A trigger pulse causes the circuit to enter the unstable state and the circuit will return to the stable state after time usually set by an external capacitor and an external resistor. Such a circuit is useful for creating a timing period of fixed duration in response to some external trigger with variable pulse duration. For more information about multivibrator, visit this page: Multivibrator

Nanoseconds Pulses

There are a range of monostable multivibrator on the market, with some faster than others. They can provide varying pulse width. For this post, the CD74HC221M96 from Texas Instruments was selected. The CD74HCT221 are dual monostable multivibrators with reset. An external resistor (RX) and an external capacitor (CX) control the timing and the accuracy for the circuit. Adjustment of RX and CX provides a wide range of output pulse widths from the Q and Q\ terminals.

The pulse width of the output pulse Q and Q\ is set according to: tw = 0.7*RX*CX. The minimum value for RX is 500 ohms. To get a pulse width of 40 ns for instance and with RX=500 ohms, CX needs to be 115 pF.

Schematic

The schematic for the multivibrator is shown below, with Vcc=5V:
monostable multivibrator

Test results

The circuit was assembled and tested with a signal generator connected to the input and an oscilloscope to the output. A consistent output of ~52 ns is observed irrespective of input signal pulse width as shown in the following figures. The pulse repetition frequency was set to 1kHz.
Input with a pulse width of 1us
Input with a pulse width of 25 ns
Input with a pulse width of 200 ns

Using a microcontroller to trigger the circuit

The input pulses for the circuit can be generated with ease using any Arduino. The simplest method is to create pulses using the so-called “Bit-banging Pulse Width Modulation”. For more information, visit Secrets of Arduino PWM

If you have any comments or suggestions, please email us at contact@behindthesciences.com or leave a comment below.

Add a Comment

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons