introduction to digital electronics -...

Post on 06-Feb-2018

217 Views

Category:

Documents

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Introduction to Digital

ElectronicsPierce Nichols

23 Apr 2014

Presentation © Logos Electromechanical LLC 2014

CC BY-NC-SA-3.0

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

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.

Digital Waveforms

Logic symbols

Logic 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

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…

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

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

Trinket Pin-Out

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

Setting up your breadboard

• We use the Trinket and USB as power supply

First circuit: the inverting buffer

Now with open drain…

• Replace the 74HC14 with the 74HC05

• What happens?

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

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

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

Schmitt Trigger inverter oscillator

• Inversion + hysteresis lets us build a relaxation oscillator…

• �� ≈�.�

����

Schmitt Trigger Oscillator

Grab example code from Github…

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

Switch bounce

• Load the SwitchBounce sketch on your Trinket.

• It should flash the LED once per button press…

Why does it blink more than once per press?

Debouncing with a Schmitt Trigger (74HC14)

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

Address decoder circuit with 74HC238

• Choose one of eight outputs with three inputs

Decoder circuit

• Load DecoderDemo sketch

Shift register internal logic

Shift register truth table

Shift Register simulator

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

Shift register circuit

• Load the ShiftRegisterDemo sketch

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.

PWM circuit

• Load the PWMOutDemo sketch

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

Important elements of the datasheet

• Function & pinout

• Voltage levels

• Rise & fall times

• Current limits

• Quiescent power draw

• Total power dissipation

top related