Electronic Hobbyist Circuits
This page will house a collection of brief hobbyist experiments.
1. Pseudo-Random Number Generator
This circuit describes a simple, 6-bit random number pseudo-generator used to study binary counters and in particular, shift registers. Some very basic background information about binary counters and shift registers is provided. In reality there are dozens of different shift register topologies available and it can get quite complex. If you wish to find a good logic tutorial website, I strongly recommend Ken Bigelow's site as it has interactive diagrams. Flip-flops are also covered well on wikipedia and many other web sites.
Binary Counter: The circuit most often used as a counter is called a binary flip-flop. The basic flip-flop can be viewed as a toggle switch having either an ON or OFF position. This is the binary state 1 (HIGH) or 0 (LOW). Like the toggle switch, the binary flip-flop has 2 binary states 1 or 0. A binary flip flop counter counts in a sequence such as 0, 1, 0 ,1 etc. A straight binary counter can be built by using 1 or more flip-flops connected in a manner that the binary number stored in these flip-flops will represent the total number of trigger pulses received at the counter input.
Ring Counter: A ring counter has 2 or more flip-flops cascaded so that the output from one flip-flop becomes the input of the next flip-flop. The flip-flops are connected so that all of their outputs are at the binary state 0 except for one flip-flop. By pulsing the input of the ring counter, it will sequentially change the binary state of the succeeding flip-flop from binary 0 to binary 1. The flip-flop that contains the binary 1 indicates the count of this binary counter. The maximum number of pulses that can be counted by N flip-flops is N pulses.
Shift Register: A serial entry shift register is similar to a ring counter, except that the output flip-flop is not connected to the input flip-flop. Like the ring counter, the flip-flops are cascaded so that the output from one flip-flop becomes the input of the next flip-flop. All the set trigger and reset trigger inputs are tied together to form what is called a shift bus. Clock pulses are applied to the shift bus to cause the stored binary information to shift from left to right; one bit position per each received clock pulse. In Figure 2, this serial input/output + parallel output register has its 5th and 6th bits exclusive ORed to the serial input to form a pseudo-random sequencer, which is called a pseudo-random number generator by some.
The CMOS logic ICs used were one 4070 XOR (Exclusive OR) and three CD4013B D flip-flops. Junk box LEDs were used to observe the binary state of the clock and each of the 6 bits of the shift register.
Since only one XOR gate is needed for the shift register, the remaining gates were configured to make the clock. These gates are essentially wired up as inverters to form an astable multivibrator with a frequency of about 0.45 Hertz or 27 pulses per minute. Shown above in Figure 1 is the clock schematic and the pin 1 marking for all of the digital ICs on this web page. The output LED is not mandatory, but will instantly tell you whether or not your clock is working. I built this whole circuit using Ugly Construction with the ICs flipped upside down in a "dead bug" fashion. You can increase the clock speed by decreasing the 100K resistor or the capacitor values. F Hertz = 1/ (2.2 * R * C) with R in ohms and C in farads. The slow clock speed was chosen to better observe the digital output of the shift register.
In Figure 2 is the shift register. Each 4013 was wired up as 2
cascaded flip-flops and connected to the clock. Power was applied and then
a test lead was used to bring pin 5 of the first flip-flop HIGH (connected to 12
volts for 1-2 seconds) . Both flip-flop state monitor LEDS turned ON in sequence
with subsequent clock pulses. Afterwards, pin 5 was set LOW (shorted to ground with a test lead for
a couple of seconds) and each LED turned OFF in sequence with subsequent clock pulses.
The remaining two 4013s were wired up and tested the the same way and then
finally the last XOR gate was wired up.
To avoid error, frequent pin counting and a systematic approach is recommended. For example, for each 4013, I soldered the ground pins, wired the pin 14 VDD, connected the clock to pins 3 and 11, then wired up the pin 1 and pin 13 LEDs. Systematic construction techniques are something that you the experimenter can develop and perfect over time. This approach saves time and grief. On some projects, when you have a lot of pins wired up, tracing and repairing an early mistake can be difficult.
Shown above is a bread board of the entire pseudo-random
number generator. I just built in on a scrap of board and did not lay it out so
the LEDs were in a row, as I am not going to keep this project. The clock state
monitor is the green colored LED. There are 63 possible states or combinations
of the 6 bits (111000, 100110, 100101, 000101, 000001 etc.) State 000000 is
disallowed and will hang up the shift register. If your clock LED is flashing and no
shift register LEDs are lit, then "reset" by momentarily setting pin 5
of the first flip-flop HIGH (momentarily apply 12 volts). Long live the reset switch!
Pseudo-random numbers are now mostly generated by computer microprocessors controlled by software and have applications in cryptography, electronic music, security and many other applications. This "hardware" pseudo-random number generator experiment was really cool and if you want to randomly flash some LEDs, this could be the project to use!
If you are new to digital electronics; (like me) Welcome! Starting small with projects like this one will hopefully lead to increased confidence and problem solving skills for even bigger projects. You can also build the shift registers with J-K flip-flops, but it is more difficult and 4013s or other series D flip-flops are cheap as Борщ (borscht).
Shown above in Figure 3 is how to hook up the XOR gate(s) for 4, 6 and 8 stage pseudo-random number generators. The 6 stage shift-register is of course, Figure 2 above and is presented for reference purposes. The 8 stage version = 1 byte.
2. One Hertz Precision Time Base
Digital clocks are very interesting. In the past 6 months, 10 -15 RC clocks have been constructed and tested. RC oscillators in the KHz to Hertz range are surprisingly frequency stable. For many projects, a plain RC clock is adequate, however, like in radio design, a crystal controlled time reference is sometimes required. Two examples of projects requiring precision clocks are time of day clocks and frequency counters. Presented is a 1 Hertz clock built from two 4000 series CMOS Logic ICs. Here is a great 4000 series tutorial with pin outs and more.
Shown above in Figure 4 is the complete schematic with an output LED for testing. In the past, the MM5369 17 Stage Oscillator/Divider was popular for hobbyist precision time bases, however, it has gone obsolete. The 4060 ripple counter is a good "modern" replacement, although a different crystal is required. A 32768 Hertz crystal was used and is divided 16384 times to provide a 2 Hz output. The 4060 then drives a 4013 D Flip-flop configured as a divide by 2 to provide a 1 Hz output frequency. Key parts references may be found on the Webmaster's page.
Shown above is the frequency and output waveform when a frequency counter and oscilloscope are (respectively) connected to pin 9 of the 4060 in Figure 4. The 6.5-50 pF trimmer pot is used for calibration. Originally, I used a trimmer cap instead of the fixed 15 pF capacitor shown between the 330K resistor and the crystal. After adjusting this trimmer capacitor for the best looking waveform, I removed the trimmer cap and measured it at 13 pF. I substituted the nearest standard value I had in my parts collection; 15 pF. It was interesting to measure the 4013 output frequency at 1 Hz.
A close up photo of the 4060 oscillator/divider breadboard. The 10M resistor used was a 1/2 watt rated R as I have dozens of these in my parts collection. You can see the tiny cylindrical crystal just above and left of the orange Murata trimmer capacitor. It is oriented horizontally. This is a useful time base for the QRP workshop.
3. 10000 and 5000 Hz Multivibrator Clock
It is fun to occasionally build circuits using discrete semiconductors rather than with ICs. A 5000 Hz digital clock was needed for an experiment. It was decided to use multivibrators for the basic oscillator and a divide by 2.
Figure 5 is the entire circuit. The tuning range of the
astable multivibrator was about 7060-10650 Hz. The 5K pot was slowly
adjusted until 10000 Hz was measured in a frequency counter. Following testing
of the astable multivibrator, the flip flop was built and examined. Astable
multivibrator function has been
discussed previously on this web site.
Please refer to the bistable multivibrator. It is a one input circuit set up for toggle or flip-flop operation. Negative edge pulses applied between the two 0.001 capacitors will cause the binary state of Q1 and Q2 to change to the opposite state. The multivibrator circuit is made up of Q1, Q2 and the 47K and 1K base and collector resistors respectively. The other components D1, D2, the RS resistors and CS capacitors comprise a steering circuit to generate the proper response to the negative edge pulses. When a negative input pulse arrives, it is guided to the base terminal of the ON transistor, but prevented from reaching the base terminal of the OFF transistor.
In order to study this circuit at DC, I temporarily exchanged the 0.001 timing capacitors in the astable multivibrator with some 22 uF electrolytic caps to slow it down. Referring back to the bistable multivibrator, let us assume that Q1 is OFF and Q2 is ON. The collector voltage of Q1 is high (cut off). The collector voltage of Q2 is low (saturation). The Q1 collector is connected to the cathode of D1 by the 100K RS resistor. The cathode of D1 is reverse biased by the high Q1 collector voltage and also because its anode is held close to 0 volts by the 47K resistor connected to the collector terminal of Q2. It would take a very strong negative input pulse to forward bias D1 enough to reach the Q1 base terminal. The Q2 collector voltage is nearly 0 volts and therefore the D2 cathode has little to no reverse bias voltage via its RS. Thus, any small amplitude negative input pulse will cause D2 to become forward biased, reach the base of Q2 and drive Q2 OFF. Once Q2 switches off, in turn Q1 is toggled ON and its collector voltage goes low. The large reverse bias on D1 disappears. However, Q2 is now OFF and D2 will now be strongly reverse biased which will steer the next negative input pulse to the base of Q1. This is the basis of the circuit's negative edge flip-flop operation.
In another experiment, I changed the .001 C0G capacitors of the astable
multivibrator to 470 pF. This gave a usable range of 22968 to 14832 Hertz
(11484-7416 Hz at the Q1 and Q2 output) .
Looking at the output of the flip-flop in the oscilloscope; at the higher
frequency range, the flip-flop could
not keep up and failed to divide by 2. I found experimentally that the time constant
of each of the CS and RS components seemed to be the problem. When the CS capacitors
were also decreased to 470 pF, the flip-flop worked properly.
As you increase the flip-flop operation frequency, speed up bypass capacitors might also be required across the 47K base resistors of Q1 and Q2 . A suggested starting value to try is 220 pF. Some builders also bypass the resistors in the RS steering circuit at higher frequencies, however, this is getting a little crazy. It is really important to look at the output waveform in the oscilloscope to ensure reasonable performance.
Shown above is the Figure 5 breadboard prototype.
5 KHz output waveform of Q2
4. One KHz Digital and Analog Oscillator
A 1 KHz oscillator with 5 volt digital outputs 180 degrees apart and an analog output was sought. The frequency had to be near to, but not exactly 1000 Hertz. A major question to answer was how much low pass filtering is needed to remove the odd harmonics from digital circuits?
Figure 7 shows the complete schematic. NAND gates from a
74AC00 were wired as inverters and with the 13.5 K resistance and a 0.022 uF
polyester capacitor, the frequency was 2002 Hertz. To improve the digital
waveform and get the desired 2 outputs, a D flip-flop was used. The output
1001 Hertz. The digital part was completed!
For the analog filtering, active low-pass filters were tried, and in total 4 poles with a 1 KHz cuff off worked reasonably well. The filter uses the 5532 op-amp with common vales capacitors and resistors. Poly"something" caps were utilized.
In Figure 8 is the output waveform of the low pass filter stages. A pretty nice sine wave was achieved and this oscillator could see duty for testing audio amplifiers. The scope was photographed at an angle to avoid the camera reflection and this distorts the sine waves a little.
Figure 9 depicts an experiment with the op-amp biasing. If the op-amp is run at 5 volts VCC, the bias requirement is 1/2 VCC or 2.5 volts. The DC voltage at the output of the D flip-flop was 2.55 volts. The 2K2 resistor was connected directly to this output and this eliminated the VCC/2 resistor bias network and a coupling capacitor.
Figure 10 shows the output waveform of Figure 9. The AC waveform has harmonic distortion and thus the Figure 9 circuit will not be kept nor utilized.
The Figure 7 breadboard. A 0.39 coupling capacitor (not 1 uF) was used between the D flip-flop and 5532a in this particular version. Unfortunately, no 0.047 uF caps were available for the low-pass filters and therefore a 0.039 plus a 0.0082 were placed in parallel for each of the .047 uF caps.
5. One KHz Low Distortion Signal Generator
Although I own a variable frequency wein bridge oscillator, it has been been set to 1 KHz for 2-3 years and is large and temperamental. It was decided to make a low distortion sine wave oscillator for just this one frequency. The circuit will be placed in a box along with another signal generator.
There are a number of ways to build signal generators using op amps. Countless example circuits may be found on the World Wide Web and some of them are really fantastic. Chose whichever method works best for you. Some might find my circuit to be overkill, but to each his own.
Figure 11 shows the entire circuit. The Wein bridge oscillator is from EMRFD and was designed by Wes, W7ZOI.
A 0.22 uF capacitor was chosen for the tuned circuits. Using resistors from my parts collection, 1018 Hz was the closest I could get to 1 KHz. This is the 6K8 + 820 ohms resistors labeled "tuning Rs". Other values were tried. For example, a single 6K8 gave 1142 Hz and a single 8K2 gave 939 Hz.
When the circuit was first built, I used a 10K on the VCC/2 bias point to pin 2 and a 22K feedback R from pin 1 back to pin 2. The sine wave had mild distortion. By experimentation, it was learned that the resistance from the VCC/2 bias point to pin 2 significantly affected the waveform purity. The 2K2+15K plus the R1 + R2 resistance values shown were determined by using a potentiometers rather than fixed resistors. Care was taken to adjust the feedback resistance from pin 1 back to pin 2 to keep away any overdrive distortion. I do not understand this, but even changing the 820 ohm R2 to 570 ohms, altered the sine wave purity.
The best looking sine wave came when the resistance from the VCC/2 bias point to pin 2 was the same as the tuning resistance; 6K8 plus 820 ohms. Later, the pin 1 to pin 2 feedback resistance was chosen for an unclipped; waveform with a reasonable output voltage using a potentiometer. The potentiometer was removed and measured at 17.1K, thus the 15K + 2K2 were soldered in. It was also discovered that by increasing R3 from 56K or 100K to 150K slightly improved the waveform.
The Figure 7 low-pass filter was connected to the main oscillator as shown. The final op-amp stage was used as a buffer between the low-pass filter and the gain control. R4 is used to set whatever output impedance you choose. Practically speaking, it could be any value between 47 and 620 ohms. Many AF oscillators have an output impedance of 600 ohms and 620 is the nearest E24 standard value. For my project, a 100 ohm R4 was chosen. Output peak to peak voltage is 0.0 to 4.84v continuously.
Here is the raw output of the basic Wien bridge oscillator. It is hard to photograph well, but it is stellar to say the least.
The Figure 11 breadboard mounted in a plastic Hammond chassis. The voltage regulator seen to the left of the bottom polyester cap is a 7812. This project has its own regulated power supply. Other view of Fig 11. Two 10 Megohm standoff resistors were used to help support all the resistors soldered to pins 1, 2 and 3 of the main oscillator.
A front view photo of the AF oscillator. A separate 7 plus 14 MHz oscillator circuit and controls will be placed on the right hand side of this box. The orange power ON indicator LED was epoxy glued into the chassis hole. Putting circuits in cabinets is one of the most expensive aspects of homebrew construction. One must be ever vigilant for bargain chassis boxes and hardware to keep costs down. Techniques such as gluing in the LED rather than purchasing a separate holder and recycling knobs and switches are also practiced for cost containment.
The output of Figure 11 is shown in Figure 13. This is the best sine wave seen ever on my scope. I looked at it closely and there is no change in line thickness or symmetry anywhere. It inverts with no change on the scope. Testing audio amplifiers will now be much more fun.
6. LM386 Power Experiments
The LM386 is an IC audio amp that has been used in thousands of hobbyist projects over the past 2 decades. By adding a capacitor +/- a resistor between pins 1 and 8, this device's internal gain can be changed from x20 to up to x200.
Test circuit schematic in Figure 14.
The experiment breadboard is shown above. A very standard configuration. The amplifier drove an 8 ohm, 1 watt resistive load.
Over the years, I have noticed some kit sellers and project authors claiming that their LM386 based AF stages gave 1 or occasionally even 2 watts of output power into an 8 ohm speaker. This was confirmed on the bench. This device will output 1 watt into 8 ohms at 1018 Hertz with little problem. However, this is clearly 1 watt of square wave distortion.
The quiescent current of the LM386 was around 7 mA. The signal generator gain was increased until the first signs of distortion appeared. The gain was then backed off a little so a pure sine wave was observed in the oscilloscope. The current was ~ 155 mA and the measured power was 289 mW. Please refer to Figure 15 for the 289 mW sine wave. This was the clean signal power of the LM386 on my bench. The output waveforms at 563 mW and 1 watt are also shown. Extreme harmonic distortion occurred above 300 mW. This device will draw 240 mA or more when driven and clipping hard. It is not my intention to malign the LM386. It is a useful part, albeit a little dated. Its AF gain capability versus size is something to behold. Many builders have moved to the TDA7052 audio amplifier IC, or like myself, build their own low noise audio power amps.
The 12.24 volt DC supply and the 1018 Hz AF audio oscillator used in these experiments.