FeatureImage6

Chapter 4: Interfacing Electronics

Chapter 4: Interfacing Electronics

/Chapter 4: Interfacing Electronics
Chapter 4: Interfacing Electronics2019-01-11T16:13:54+00:00

Introduction

This is the chapter web page to support the content in Chapter 4 of the book: Exploring BeagleBone – Tools and Techniques for Building with Embedded Linux. The summary introduction to the chapter is as follows:

This chapter introduces you to the type of practical electronics that you need in order to work effectively and correctly with the BeagleBone platform. One chapter cannot be a substitute for full textbooks on digital and analog electronics; however, there are concepts with which you must be comfortable before connecting electronics to the interface headers on the BeagleBone, as incorrect configurations can easily destroy the board.

Learning Outcomes

After completing this chapter, you should be able to:

  • 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 BBB 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 BBB GPIOs and ADCs

Parts for this Chapter

Here is a full list of the components that are used in this chapter:

■ Breadboard
■ Diodes: 1N4001, general‐purpose LED
■ Transistors: NPN: BC547, FET: BS270
■ Voltage regulator: KA7805/LM7805
■ PTC: 60R110
■ Button and Switch: General purpose SPST and SPDT
■ ICs: 74HC73N, 74HC03N, 74LS08N, 74HC08N, 74HC14, LM358N
■ Resistors: 1 MΩ, 2.2 kΩ, 2×10 kΩ, 50 kΩ, 100 Ω, 50Ω, 1 kΩ, 470Ω, 220 Ω, 100 kΩ POT.
■ Capacitors: 10μF, 1μF, 0.33μF, 0.1μF.
■ Opto‐isolator: SFH617A

Digital Media Resources

Here the digital resources referred to in the chapter web page are provided. There are high-resolution versions of some of the important figures and links to videos, resources and websites that are described in the chapter.

The Analog Discovery

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 is a USB oscilloscope, waveform generator, digital pattern generator and logic analyzer. It is priced at $99 for US students and generally for $219. 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.

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.

Some Images from the Chapter

External Resources

Important Documents

External Web Sites

Lessons in Electric Circuits

Lessons in Electric Circuits − Volume IV-Digital, T. R. Kuphaldt

BeagleBone Black System Reference Manual

The BeagleBone Black System Reference Manual (SRM)

Errata

  • Page 107. The manufacturer Owon is incorrectly named as Owen on this page.
  • Page 111. Reference is made to a “blue potentiometer” but the print text is in grey scale. The blue potentiometer is the 10kΩ resistor on the bottom left of the figure.
  • Page 117. (Loc. 3868) “If the diode is reverse‐biased by applying a greater voltage on the anode than the cathode…” should read “If the diode is reverse‐biased by applying a greater voltage on the cathode than the anode…”. It is correctly described elsewhere.
  • Page 130. In the equation: R = V/I = (3.3 V − 1.15 V)/0.0045 mA = 478Ω, the mA should be A. The calculation was performed correctly.
  • Page 144. The bottom of the page states “The circuit example used in 4-27(b) could be used to generate a PWM signal…”. This should be Figure 4-28(b).

Recommended Books on the Content in this Chapter

       

18 Comments

  1. TB December 15, 2014 at 9:54 pm

    Loc 3868: Section on diodes, in the paragraph that starts “When a diode is forward-biased…” The second sentence says this:

    “A diode is forward-biased when the voltage on the anode (+ve) terminal is greater than the voltage on the cathode (-ve) terminal;…”

    However, then the next sentence then says this:

    “If the diode is reverse-biased by applying a greater voltage on the anode than the cathode, then almost…”

    Those describe exactly the same thing, as I see it. They both describe forward-biasing.. That second sentence should say that a greater voltage is applied to the cathode than the anode, when the diode is reverse-biased…correct?

    What am I missing here?

    • Derek December 15, 2014 at 10:23 pm

      Well spotted. Yes, the second sentence should state if the diode is “reverse biased by applying a greater voltage on the cathode than the anode“. Thanks. Derek.

  2. TB December 16, 2014 at 5:50 pm

    Loc 4276: In the body of the “Binary Numbers” sidebar, what is “RHS”? In this section “…but you tend to add the negative number of the RHS of the operation…”

    Although I might have missed it, I didn’t see RHS defined anywhere before that in the chapter. So I’m not sure what that acronym represents.

    • Derek December 16, 2014 at 6:52 pm

      Thanks. It stands for “right-hand side”. I’ll check to see if it was introduced before. There may be an error of omission there!

  3. Vignals January 17, 2015 at 1:01 am

    Just reporting some typos on page 107 / Chapter 4:
    When listing the Oscilloscopes the brand name is Owon and not Owen.
    I have used the SDS6062V for about two years (it is among the list you provided) and I am quite happy with it so far.
    Great book so far, I like the detailed yet condensed style.

    • Derek January 17, 2015 at 1:22 am

      Thanks Vignals. Missed that and I have one on my desk beside me! Derek.

  4. Michael K Johnson January 21, 2015 at 2:18 am

    Page 130, line 2: “4.5mA” is referenced in the equation on line 4 as “0.0045mA” which should be either “0.0045A” or “4.5mA”

    • Derek January 21, 2015 at 8:54 pm

      Thanks Michael, you are correct — I will add that to the list of errata. Thanks, Derek.

  5. The Reynolds January 21, 2015 at 3:58 am

    Chapter 4 Page 111, last paragraph 2nd sentence, reference is made to the blue potentiometer, yet the pics are black and white. I assume the text was written when color pics may have been an option.

    • Derek January 21, 2015 at 8:52 pm

      Thanks for that — you are perfectly correct. The book was always going to be printed in grey scale but my brain was still working in color! Yes, the blue multi-turn potentiometer is on the bottom left of the figure. I’ll add a color copy of the figure to the web page. Thanks, Derek.

  6. Hyusein Gyulyustan March 7, 2015 at 7:32 pm

    On page 114: “The circuit example used in 4-27(b) could be used to generate PWM signal…”, I think you mean “4-28(b)” instead of “4-27(b)”.

    • Derek March 8, 2015 at 12:08 pm

      Thanks Hyusein, Yes, that should be Figure 4-28(b). I’ll add it to the list of errata, Derek.

  7. Gordon March 19, 2015 at 7:49 pm

    Hi Derek,

    In Chapter 4, Page 139, Figure 4-26, the 74HC03 would appear to have clamping diodes on pin 11 output. Would this not limit the max output voltage to Vcc plus the diode drop (3.3v + 0.7v)? I think this should still be okay to feed a TTL gate but Vout won’t reach more than 4 volts.

    Really enjoying your book! Good mix of theory and practical examples.

    Regards,
    Gordon.

    • Derek March 20, 2015 at 2:04 pm

      Hi Gordon — thanks for your support! That’s an interesting point. I found many textbooks to be quite dated in their treatment of circuits (op-amps in particular have evolved hugely compared to their textbook description!) so I built every circuit in the book. The plot on the RHS is the actual output from a M74HC03B1R wired as per the figure. I checked the datasheet for a few different 74HC03s and they state that “The 74HC03 have open-drain N-transistor outputs, which are not clamped by a diode connected to Vcc.” The figure on the LHS is somewhat simplified (as is the datasheet) and the diode that is displayed is referred to in the M74HC03B1R datasheet as an “output protection diode”. It appears that its presence does not appear to clamp the output at all — the exact reason for this is not clear to me and it will require further reading as there is not enough information in the datasheet alone. To confirm my sanity, I connected a M74HC03B1R to the Analog Discovery as per the figure and the output is exactly the same as in the plot on the RHS (i.e., sitting nicely at 4.924V for 4.980V/3.323V supplies). Hope that helps, Derek.

  8. Gordon March 20, 2015 at 8:26 pm

    Hi Derek,
    Thanks for the quick response! After posting my comments yesterday I thought that I had better test the circuit myself. I used an Arduino Due with a slightly modified Blink program to generate a 3.3v square wave. As well as the square wave the Due was used to supply 3.3v power to the 74HC03. (The exact chip I used was a Texas Instruments SN74HC03N) I connected a 10k ohm resistor, as a pull up load, between the open drain output and the positive of a variable DC power supply. The negative was connected to a common point. I set the variable supply to 3.3 volts and monitored the output square wave on a ‘scope. The voltage was switching between 0v and 3.3v, as expected. As the variable voltage was increased, the output tracked the supply rail until it reached 4 volts. After this point the output voltage did not change with increasing supply voltage. I repeated the same test with an Arduino Uno. This time the supply power, to the 74HC03, was 5 volts. Again, output voltage tracked the supply until it reached 5.7 volts. Once more it did not change with increasing voltage on the variable supply.
    It seems strange, but there must be changes between 74HC03s made by different manufacturers. Finally, if you have the time, I would be more than happy to send you my 74HC03 for testing.
    Kind regards,
    Gordon.

    • Derek March 21, 2015 at 2:21 am

      Hi Gordon, I agree that the way you have tested the SN74HC03 is perfectly correct. One thing I noticed in the datasheets that is different is that the SN74HC03 gives the output state as explicitly High/Low, whereas the M74HC03 lists the outputs as High-Impedance(Z)/Low. There isn’t much detail in the SN74HC03 datasheet but my guess is that both ICs have an entirely different internal configuration and behaviour, despite both having an open-drain output. Very interesting! Derek.

  9. Shawn March 13, 2016 at 5:14 am

    Hi Derek,
    I have a question about figure 4-26. When B is high, the output of NAND gate should be low, and the FET acts just like switch opened. So the Out will be ~5V, but it doesn’t make sense. Did I miss something? I just feel overwhelmed in this chapter.
    Many thanks.
    Shawn.

    • Derek March 21, 2016 at 3:11 am

      Hi Shawn,
      First the NAND Gate: A NAND gate has an output of 0 when both inputs are 1, but 1 in all other cases. Therefore, as A is high the output is dependent on B. If B is high then the output of the NAND gate is low.
      Second the FET: A low input into the gate of the FET results in an output of 5V as the FET is turned off and so the output is tied to the 5V supply (through the 10k resistor). Similarly, when the gate input is high it turns on the FET and the voltage at the output is 0V as the current that results from the 5V supply and the 10k resistor sinks to ground through the FET (drain/source).
      This is one of the more complex circuits in that chapter, so you are doing very well if you can get a handle on this one! Kind regards, Derek.

Comments are closed.

Exploring BeagleBone

This is the companion site for the book “Exploring BeagleBone: Tools and Techniques for Building with Embedded Linux” by Derek Molloy. The site structures and contains all of the digital media that is described in the book. Each chapter in the book links to an individual web page, which can be accessed using the menu on the top right-hand side of this page when you close this menu. For details of the book itself, click here.

Recent Works

Latest from Derek Molloy YouTube Channel

Oops, something went wrong.