Making an Oscillator With LogicBoard From MH-EDU-Electronics

by kevinjwalters in Circuits > Electronics

438 Views, 1 Favorites, 0 Comments

Making an Oscillator With LogicBoard From MH-EDU-Electronics

logicboard-oscillator-titlepage-65.jpg

The LogicBoard (STEM Logic Gates Experimentation Lab) from MH-EDU-Electronics is an affordable, small board for learning about logic gates which are the fundamental building blocks of digital computers. It has 13 gates, three switched inputs and three red LED outputs.

This article shows how to make an oscillator (also known as an astable multivibrator) using two extra components, a resistor and a capacitor. This generates a square wave output which is used to make one of the red output LEDs flash. The square wave can be seen on an oscilloscope if you have one - a Zoyi ZT-703S features in this article. The various factors affecting the flash rate are explored.

This board can be used with an Arduino UNO. Another product, the 8 gate LogicShield is specifically designed for use with an Arduino.

Instructables: Making a Full Adder With LogicBoard From MH-EDU-Electronics includes more information about the board.

Supplies

  • MH-EDU-Electronics LogicBoard: Tindie
  • A resistor - any value above around 10k, 100k is used in this article.
  • A capacitor - for the flashing to be visible the resistor value multiplied by the capacitor value needs to be approximately 0.1 or higher. A 47uF electrolytic capacitor is used in this article.
  • Power source with 2.1mm centre-positive DC barrel jack connector (same as Arduino UNO)
  • A 9V PP3 battery with a connecting lead or
  • a 4xAA battery pack with a connecting lead or
  • a mains power supply between 4V and 14V - ensure it is centre-positive.
  • With care the board can be powered from an Arduino UNO by connecting
  • Arduino GND to LogicBoard 0 and
  • Arduino 5V to LogicBoard 1.

Oscillation With Logic Gates

osc3-v4-onecycle-anim2.gif
logicboard-oscillator-diagram-65.jpg

Basic logic gates can be used in different ways to create larger logic circuits. If the output is only determined by the (current) inputs then it is referred to as combinatorial logic and the behaviour can be described with a simple truth table. If the output varies based on prior inputs then it's known as sequential logic - this implies the circuit has a form of memory, often known as state.

An oscillator can be constructed by connecting the output of a NOT gate to its input (see OSC 1 above). There is a paradox here because the gate's output X is the opposite of its input A but the wire connecting them makes them the same.

 NOT     WIRE
A | X A | X
===== =====
0 | 1 0 | 0
1 | 0 1 | 1

This conundrum is resolved by the behaviour of real gates. Each gate takes a tiny amount of time (typically quoted in nanoseconds) to change so this would create a very fast oscillator (tens of megahertz or faster). The rate can be decreased by using three (or any odd number of) NOT gates in series but this still offers no ability to set a precise rate, nor control it.

A capacitor can be added to the circuit to slow the rate of change on the input as it charges or discharges (see OSC 2 above). A resistor is also required to limit the current flowing in and out of the capacitor. The values of the these two passive components affect the rate at which the input voltage changes and hence affect the oscillation rate of this relaxation oscillator.

For 5V powered gates the logic levels are often written as 0V for low and 5V for high. The datasheet will specify a wider range of voltages for input values where the gate is guaranteed to work correctly - these may not be equal in size. The gate will have undefined behaviour outside of these ranges but will clearly do something and this will depend on the technology the gate is constructed with. Three different examples are listed below, CMOS is very commonly used, TTL is rare nowadays, ECL is very specialist and uses atypical voltage levels.

  • TI CD4069UB (CMOS): inputs: low 0.0-1.0V , high 4.0-5.0V.
  • TI SN74LS04 (TTL): inputs: low 0.0-0.8V, high 2.0-5.0V.
  • OnSemi MC100EL04 (ECL): inputs: low 3.05-3.52V, high 3.87-4.19V for PECL.

The LogicBoard uses CMOS gates, these are likely to start switching near the midpoint voltage. Taking into account the LogicBoard's reverse polarity protection diode, for a 9V power supply the midpoint voltage will be (9.0 - 0.6) / 2 = 4.2V. This could lead to very fast oscillation as the input voltage varies from, say, 4.19V to 4.21V.

The AND and NAND gates on the LogicBoard are created from NAND gates featuring Schmitt trigger inputs. These increase the input voltage difference required to register as a changed level. Use of these particular gates slows down the oscillation for a capacitor-smoothed input and makes it more predictable. A NAND gate can be converted to a NOT gate by simple joining its inputs for use in an oscillation circuit. An alternative approach is to use the second input as an ENABLE input for the oscillator allowing it to be turned on and off (see OSC 3 above).

The three oscillators described here are shown above as an animation using 5V logic gates in the Falstad Circuit Simulator. The switching rate is so fast on the first two that the output looks like a solid thick line between 0V and 5V. The third one using the Schmitt trigger is oscillating at 0.259Hz which would be visible as slow flashing on the LED.

Oscillators are important components for electronics and computers providing clocks. These clocks are more like a metronome than a watch in that they just mark a certain amount of time has passed. Clocks based on RC time constants have poor accuracy and stability. Crystal-based clocks, used in quartz clocks, offer excellent accuracy and stability. Atomic clocks go a step further with state of the art clocks using optical lattices.

Making and Running an Oscillator Using LogicBoard

Oscillator on the MH-EDU-Electronics LogicBoard

The two logicians have become vacillators. They construct an oscillator in the video above with the supervisor overseeing the project. They use

  • 1 orange cable for input A as an ENABLE for the oscillator;
  • 1 orange and 1 blue cable for the 100k (99.1k measured) resistor;
  • 1 black and 1 white cables for the 47uF (47.1uF measured) electrolytic capacitor (the capacitor's marked negative lead must go via black cable to the LogicBoard's 0 which acts as a ground);
  • 1 violet/purple cable for the output Y.

The leads on the capacitor and resistor are too small for the connectors and may not make perfect contact. If they are horizontal then they won't fall out!

This circuit oscillates with a period of 4.87 seconds, 0.205Hz.This does not match the simulation results at 0.259Hz. The actual Schmitt trigger high/low voltages are likely to be the major difference explaining this. Component tolerances for the passive components will also have a small effect, these are typically wider for capacitors than resistors.

This is similar to how the legendary 555 timer chip can be used to create simple oscillators, see Instructables: Dual Astable 555 Timer for one attractive example of this.

Schmitt Triggers

cd4093b-ds-st-fig2-65.png
cd4093b-ds-st-fig3-65.png

The plot on the left from the CD4093B datasheet for the LogiceBoard's NAND/AND gates shows how the output voltage of the gate varies over time with the second input with the first being held high by Vdd. The input voltage ramps up with the output going high at Vp, the output goes low as it ramps down at Vn. The difference between these two voltages is Vh, the hysteresis voltage. If the input voltages varies between Vn and Vp then the output will stay steady and not change.

The second figure on the right shows similar information with the addition of Voh and Vol showing the output voltage is kept very close to the supply voltages.

For a 5V supply voltage the datasheet states the typical value for Vn is 1.9V and Vp is 2.9V. Note: these are not perfectly symmetric around the 2.5V midpoint voltage at -0.6V and +0.4V, respectively.

Input and Output Signals on Oscillator's NAND GATE

Oscilloscope on the oscillator on the MH-EDU-Electronics LogicBoard

The vacillators have found a new gadget, a Zoyi ZT-703S, an oscilloscope, signal generator, and multimeter. They use it in oscilloscope mode to look at the second input of the NAND gate and its oscillating output. The output is a square wave, as expected, and the input looks convincing like a typical capacitor charging and discharging.

The capacitor appears to get near a maximum and minimum value suggesting it fully charges and fully discharges, the gate appears to take a considerable amount of time to change output and on close inspection the voltage appears to fall very slightly after the capacitor charges. This doesn't quite make sense as

  1. the capacitor charging would never reach the the maximum value of approximately power supply voltage and would never reach the minimum voltage of approximately 0V,
  2. the gate's output change should be more sensitive and change very quickly as the Schmitt trigger's Vn or Vp are reached and
  3. the peak to peak voltage of approximately 0.6V looks suspiciously small.

The passive oscilloscope probe has two modes, 1x and 10x, selectable via a switch. The 1x mode was used for this video. The next page shows the use of the 10x setting for comparison.

Signals Using a 10x Probe on Gate's Input

zt703sscope-inputoutputwaveforms-10xinput-65.JPG

The probes have been swapped around to use the meter manufacturer's probe for the input signal. It's now set to the 10x setting on the probe and on the oscilloscope (setting is visible from the Menu button). The waveform (shown above) now looks like a capacitor partially and slowly charging and discharging with the output changing quickly at certain voltage levels. A typical modern probe set to 10x has a 10 megaohm total impedance rather than the default 1 megaohm impedance. This is less likely to affect "weak" signals from high impedance devices.

The first incorrect and misleading waveform in the video shows some thought and care is required to ensure a measuring device does not significantly affect the value it's trying to measure.

The input signal voltage measured in multimeter mode varies between 3.09V and 4.56V (1.47V range) with a supply voltage of 7.77V. This voltage is strangely low for a PP3 (alkaline) battery with nominal voltage 9V. This is explained by the use of a used battery which is getting flat.

Testing Zoyi Oscilloscope Impedance

The impedance is likely to vary with frequency but a trivial test with DC is useful as it's going to be representative due to the low frequencies in use here.

A new AA battery producing 1.58V was connected to a 2.26M resistor. The oscilloscope for the probe shows:

  • 1x: 7.8 divisions at 200mV per div = 1.56V across battery;
  • 1x: 2.2 divisions at 200mV per div = 0.44V across battery and resistor;
  • 10x: 7.8 divisions at 200mV per div = 1.56V across battery;
  • 10x: 6.3 divisions at 200mV per div = 1.26V across battery and resistor.

Taking the 1x numbers, this shows the oscilloscope has an impedance of 0.87M (at 0Hz) which isn't too far from the ideal value of 1M. It is still a little surprising that this affects the oscillator's input so much but this may be due to the relatively high current needed to drive the LED at a useful brightness.

Formula for Oscillation Period

cd4093b-ds-st-fig18-65.png

The CD4093B datasheet includes a formula (shown above) for the period of a NAND-based oscillator for this type of oscillator for specified ranges of the values for R and C valid for periods between 2 microseconds and 0.4 seconds.

Going Further

keysight-active-passive-probe-impedance-65.png

Some ideas for areas to explore:

  • Make a variable frequency version using a potentiometer (a variable resistor) - a 10k resistor in series is still useful to limit the current from the gate's output.
  • Find some uses for this square wave output.
  • Make an S-R latch and then a clocked D latch on the LogicBoard.
  • Explore the Combinatorial Logic and Sequential Logic library examples in Falstad Circuit Simulator.

Related projects:

Further reading: