This chapter introduces you to the type of practical electronics that you need to work correctly and effectively in interfacing electronic circuits with the Raspberry Pi (RPi) platform. The chapter begins by describing some equipment that can be very helpful in developing and debugging electronic circuits. It continues with a practical introductory guide to circuit design and analysis, in which you are encouraged to build the circuits and utilize the equipment that is described at the beginning of the chapter. The chapter continues with a discussion on the typical discrete components that can be interfaced to the general-purpose input/outputs (GPIOs) on the RPi, including diodes, capacitors, transistors, optocouplers, switches, and logic gates. Finally, the important principles of analog-to-digital conversion (ADC) are described, as such knowledge is required in Chapter 9 to build circuits that interface the RPi to analog sensors.
After completing this chapter, you should hopefully be able to do the following:
- Describe the basic principles of electrical circuit operation, build circuits on breadboards, and measure voltage and current values.
- Use discrete components such as diodes, LEDs, transistors, and capacitors in your own circuit designs.
- Use transistors and FETs as switches to control higher current and voltage signals than would be possible by using the RPi outputs on their own.
- Interconnect and interface to logic gates, being particularly aware of the issues that arise with “floating” inputs.
- Describe the principles of analog-to-digital conversion and design basic operational-amplifier circuits.
- Combine all of these skills to build the type of circuits that are important for safely interfacing to the RPi GPIOs.
- 1 Parts for this Chapter
- 2 Digital Media Resources
- 2.1 Custom Cables with the Raspberry Pi
- 2.2 The Analog Discovery (Analog Discovery 2)
- 2.3 Debouncing a SPDT Slider Switch
- 2.4 Debouncing a SPST Push Button Switch
- 2.5 The Two’s Complement
- 2.6 Overflow, Overflow Detection and Underflow
- 2.7 Logic Gates – Integrated Circuits
- 2.8 The JK Flip-Flop
- 2.9 A 555-Timer Circuit
- 3 Some Images from the Chapter
- 4 External Resources
In this video I investigate the use of the Digilent Analog Discovery with Waveforms and look how it can be used for the analysis of analog and digital circuits. The Analog Discovery (and Analog Discovery 2) is a USB oscilloscope, waveform generator, digital pattern generator and logic analyzer. The Analog Disovery 2 is priced at $279. l demonstrate three different applications of the Discovery:
– Analog analysis of a rectifier diode.
– Using the digital pattern generator and logic analyzer to investigate the behavior of a JK flip-flop.
– Using the logic analyzer and its I2C interpreter to connect to the BeagleBone I2C bus and analyse how it behaves when we use the Linux i2c tools. This is exactly the same under the Raspberry Pi platform.
Debouncing a SPDT Slider Switch
This video discusses what is switch bouncing and explains how we can debounce a SPDT (single pole double throw) slide switch. It uses an SR latch to achieve debouncing and it shows how we can implement this circuit using 74LS00 NAND gates. It also examines the output of this circuit using an oscilloscope and demonstrates that the circuit is working effectively. This is part 1, in the next part I will explain how to debounce a SPST momentary push button switch using a RC circuit and a Schmitt trigger.
Debouncing a SPST Push Button Switch
This video explains how we can debounce a SPST (Single Pole Single Throw) momentary push button switch. It describes the concept of hysteresis and the use of a Schmitt Trigger. The circuit uses a RC low-pass filter as the input to a 74HCT14 Hex Schmitt Trigger to achieve debouncing and it shows how we can implement and test this circuit using an oscilloscope. This is part 2 – in the previous video I explained how to debounce a SPDT slide switch using a SR latch.
The Two’s Complement
The Two’s Complement is a method of representing negative/signed binary numbers that is commonplace in digital electronics and is the basis for how signed integers are represented in embedded systems. This tutorial explains the need for the Two’s Complement form and describes how you can perform operations such as additions/subtractions and multiplications using this form. It provides some numerical examples with solutions to allow you to test your understanding of the materials that are presented.
Overflow, Overflow Detection and Underflow
In this video I will look at the problems that can arise in unsigned and signed systems with overflow and underflow, which is where our system goes beyond its physical limitations. I will look at how you can detect that overflow is occurring in a digital system and how you can design a logic circuit to detect its occurrence. The video then describes underflow and finally, presents a few interesting questions with solutions.
Logic Gates – Integrated Circuits
An introduction to simple logic gates using the 74HC08 quad two-input AND gates.
The JK Flip-Flop
This video lecture/tutorial describes the JK Flip-Flop in detail. I begin by describing the general operation of a 7473 JK flip-flop, showing the toggle state that makes this flip-flop important for many applications. Then I show in detail how we can create a JK flip-flop using NAND gates, describing both edge-triggered and pulse-triggered configurations. I implement both types of circuit, using a pulse generator for the edge-triggered version and a master-slave JK flip-flop for the pulse-triggered implementation. Finally, I show how we can add asynchronous set and reset inputs for the master-slave configuration and implement a circuit to demonstrate that this works correctly.
A 555-Timer Circuit
This is an experiment to set up a low frequency clock signal that we can use to drive our logic gate circuits. The clock will have a frequency of 1Hz, which will allow us to see the changes to our circuit as the clock cycles.
- T. R. Kuphaldt, “Lessons in Electric Circuits,” a free series of textbooks on the subjects of electricity and electronics: www.ibiblio.org/kuphaldt/electricCircuits/
- All About Circuits: www.allaboutcircuits.com provides excellent applied examples of many types of electronic circuits.
- The Electronics Club: www.electronicsclub.info