introduction to digital electronics -...

34
Introduction to Digital Electronics Pierce Nichols 23 Apr 2014 Presentation © Logos Electromechanical LLC 2014 CC BY-NC-SA-3.0

Upload: vudieu

Post on 06-Feb-2018

217 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Introduction to Digital

ElectronicsPierce Nichols

23 Apr 2014

Presentation © Logos Electromechanical LLC 2014

CC BY-NC-SA-3.0

Page 2: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Topics for Today

• Basic digital logic concepts• What do we mean by digital?

• Edges & levels

• Types of digital inputs & outputs

• 7400 series logic

• Buffers

• Schmitt Triggers

• Address Decoders

• Shift Registers

• PWM

• We’re concentrating on those aspects of digital logic most useful for interfacing with microcontrollers

Page 3: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

What is digital logic?

• All signals are (conceptually) either high or low, rather than continuous.

• All devices in a digital circuit are (conceptually) in one of a limited number of well-defined states.

• We can make decisions based on the current state with logic gates (AND, OR, NOT, XOR, etc)

• We can store state over time with flip-flops and similar arrangements of logic gates.

• Get enough of these together (a few billion or so), and we can build a computer.

Page 4: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Digital Waveforms

Page 5: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Logic symbols

Page 6: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Logic levels

Page 7: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Logic Families

• CD4000 series

• CMOS

• Lower power and higher speed than old TTL logic

• Easier to use than TTL logic

• Useful parts mostly ported to and/or superseded by 7400 series

• 7400 series

• Originally TTL logic levels; now mostly CMOS

• The largest and most common family of logic chips

Page 8: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Structure of a 7400 series part number

74 HCT 05 N

Technology – determines

speed, current capability, logic

levels, voltage range.

Function – 04 denotes a chip

with six independent inverters

with open drain outputs

Package type – N

denotes DIP

74 HCT {1|2}T nnn xxx

Technology One or two gates Function Package

There are also smaller packages…

Page 9: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Types of Outputs

• Totem-pole

• Driven in both positive and negative directions

• Open collector (TTL)/open drain (CMOS)

• Driven only in the ground direction

• Can handle higher voltages

• Requires pull-up resistor

• Tri-state

• Like totem pole, except with a third state

• Third state is often called ‘floating’, ‘high impedance’ or ‘high-Z’

• The output has minimal effect on the circuit when in high impedance mode

Page 10: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

The Trinket

• Based around ATTiny85 microcontroller: 8K Flash, 0.5K RAM, 8 MHz or 16 MHz clock

• We have the 5V version

• USB bootloader but no USB output

Page 11: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Trinket Pin-Out

Page 12: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Installing Trinket Software

• Installing the drivers: https://learn.adafruit.com/introducing-trinket/starting-the-bootloader

• Installing Arduino: http://arduino.cc/en/Main/Software

• Updating AVRDUDE: https://learn.adafruit.com/introducing-trinket/programming-with-avrdude

• Updating Arduino IDE: https://learn.adafruit.com/introducing-trinket/setting-up-with-arduino-ide

Page 13: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Setting up your breadboard

• We use the Trinket and USB as power supply

Page 14: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

First circuit: the inverting buffer

Page 15: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Now with open drain…

• Replace the 74HC14 with the 74HC05

• What happens?

• What happens if you reverse the polarity on the LED?

Page 16: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Pull-ups and pull-downs

• A pull-up is a resistor between an input or output and the power supply

• A pull-down is a resistor between an input or output and ground

• In either case, the resistor must be high enough resistance such that it does not overload the drive capacity of the pin

• It also needs to be low enough resistance to avoid noise susceptibility

• 1K and 10K are often a good value

Page 17: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Schmitt Trigger

• The Schmitt trigger takes the standard

logic input and adds some hysteresis.

• The input has a rising threshold and a

falling threshold, and they vary with

supply voltage.

• With 5V…

• Rising threshold is typically 2.5V (1.55V-3.15V)

• Falling threshold is 1.6V (0.9V-2.45V)

• Falling threshold is guaranteed to be at least 0.4V

Page 18: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Schmitt Trigger inverter oscillator

• Inversion + hysteresis lets us build a relaxation oscillator…

• �� ≈�.�

����

Page 19: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Schmitt Trigger Oscillator

Page 20: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Grab example code from Github…

• https://github.com/logos-electromechanical/IntroToDigitalElectronics

Page 21: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Switch bounce

• Load the SwitchBounce sketch on your Trinket.

• It should flash the LED once per button press…

Page 22: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Why does it blink more than once per press?

Page 23: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Debouncing with a Schmitt Trigger (74HC14)

Page 24: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Binary representation of numbers

• Ordinary decimal numbers are in base 10, with ten digits (0-9)

• Any number can be represented in binary (base 2), with only two states, 0 and 1. In our code, binary numbers are denoted by a leading b. For example: 13 = b1101

• Also commonly used is hexadecimal (base 16) with sixteen digits (0-9, a-f), denoted with a leading 0x. One hexadecimal digit = four binary digits.

• One byte = 8 bits = 8 binary digits = 2 hexadecimal digits

Decimal 4 14 24 7 39 132 10

Binary b0100 b1110 b11000 b111 b100111 b10000100 b1010

Hex 0x4 0xe 0x18 0x7 0x27 0x84 0xa

Page 25: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Address decoder circuit with 74HC238

• Choose one of eight outputs with three inputs

Page 26: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Decoder circuit

• Load DecoderDemo sketch

Page 27: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Shift register internal logic

Page 28: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Shift register truth table

Page 29: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Shift Register simulator

• http://conductiveresistance.com/2011/02/28/interactive-595-shift-register-simulator/

Page 30: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Shift register circuit

• Load the ShiftRegisterDemo sketch

Page 31: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Pulse Width Modulation (PWM)

• Pulse width modulation gives us a way to turn a digital output into an analog output.

• Output voltage is controlled by changing the percentage of the time the signal is high.

Page 32: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

PWM circuit

• Load the PWMOutDemo sketch

Page 33: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Revenge of the analog

• Digital is really just over-driven analog

• Transitions are not instantaneous

• Lines have parasitic capacitance, inductance,

and resistance; the longer the line, the worse

the problem.

• Parasitic capacitance can slow down transitions

• Parasitic inductance can cause ringing, especially with long wires

• Parasitic resistance reduces the voltage at the inputs

• Series resistors deal with many noise problems

• Output current limits the number of inputs that

can be driven

Page 34: Introduction to Digital Electronics - metrixcreate.wdfiles.commetrixcreate.wdfiles.com/local--files/workshops/Introduction to...• Basic digital logic concepts ... • Edges & levels

Important elements of the datasheet

• Function & pinout

• Voltage levels

• Rise & fall times

• Current limits

• Quiescent power draw

• Total power dissipation