Step 1 - shaft decoder to generate clockwise/anticlockwise signals

Similar documents
Part IA Computer Science Tripos. Hardware Practical Classes

Part IA Computer Science Tripos. Hardware Practical Classes

MUHAMMAD NAEEM LATIF MCS 3 RD SEMESTER KHANEWAL

CPE 200L LABORATORY 3: SEQUENTIAL LOGIC CIRCUITS UNIVERSITY OF NEVADA, LAS VEGAS GOALS: BACKGROUND: SR FLIP-FLOP/LATCH

Experiment # 12. Traffic Light Controller

PHYSICS 5620 LAB 9 Basic Digital Circuits and Flip-Flops

Laboratory Sequential Circuits

Laboratory Exercise 7

Electrical and Telecommunications Engineering Technology_TCET3122/TC520. NEW YORK CITY COLLEGE OF TECHNOLOGY The City University of New York

MODULE 3. Combinational & Sequential logic

0 0/1 0/1 0/1 0/1 0/1 0/1 0/1 0/1 1 1 Stop bits. 11-bit Serial Data format

Advanced Devices. Registers Counters Multiplexers Decoders Adders. CSC258 Lecture Slides Steve Engels, 2006 Slide 1 of 20

Review : 2 Release Date : 2019 Last Amendment : 2013 Course Code : SKEE 2742 Procedure Number : PK-UTM-FKE-(0)-10

Sequential Digital Design. Laboratory Manual. Experiment #3. Flip Flop Storage Elements

The basic logic gates are the inverter (or NOT gate), the AND gate, the OR gate and the exclusive-or gate (XOR). If you put an inverter in front of

Microprocessor Design

When the OR-array is pre-programed (fixed) and the AND-array. is programmable, you have what is known as a PAL/GAL. These are very low

Laboratory Sequence Circuits

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

CSCB58 - Lab 4. Prelab /3 Part I (in-lab) /1 Part II (in-lab) /1 Part III (in-lab) /2 TOTAL /8

Counters

Copyright 2011 by Enoch Hwang, Ph.D. and Global Specialties. All rights reserved. Printed in Taiwan.

California State University, Bakersfield Computer & Electrical Engineering & Computer Science ECE 3220: Digital Design with VHDL Laboratory 7

DIGITAL CIRCUIT LOGIC UNIT 11: SEQUENTIAL CIRCUITS (LATCHES AND FLIP-FLOPS)

ELCT201: DIGITAL LOGIC DESIGN

Sequential Digital Design. Laboratory Manual. Experiment #7. Counters

EECS150 - Digital Design Lecture 19 - Finite State Machines Revisited

Palestine Technical College. Engineering Professions Department. EEE Digital Logic Fundamentals. Experiment 2.

EE 121 June 4, 2002 Digital Design Laboratory Handout #34 CLK

Laboratory Exercise 7

Chapter Contents. Appendix A: Digital Logic. Some Definitions

Logic Design ( Part 3) Sequential Logic- Finite State Machines (Chapter 3)

Chapter 5: Synchronous Sequential Logic

Chapter 11 State Machine Design

CS302 Digital Logic Design Solved Objective Midterm Papers For Preparation of Midterm Exam

1. a) For the circuit shown in figure 1.1, draw a truth table showing the output Q for all combinations of inputs A, B and C. [4] Figure 1.


Figure 30.1a Timing diagram of the divide by 60 minutes/seconds counter

Decade Counters Mod-5 counter: Decade Counter:

cs281: Introduction to Computer Systems Lab07 - Sequential Circuits II: Ant Brain

EECS 140 Laboratory Exercise 7 PLD Programming

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District UNIT-III SEQUENTIAL CIRCUITS

Assignment 2b. ASSIGNMENT 2b. due at the start of class, Wednesday Sept 25.

DIGITAL SYSTEM FUNDAMENTALS (ECE421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE422) COUNTERS

Introduction to Digital Logic Missouri S&T University CPE 2210 Exam 3 Logistics

ni.com Sensor Measurement Fundamentals Series

Solution to Digital Logic )What is the magnitude comparator? Design a logic circuit for 4 bit magnitude comparator and explain it,

DIGITAL CIRCUIT LOGIC UNIT 9: MULTIPLEXERS, DECODERS, AND PROGRAMMABLE LOGIC DEVICES

AIM: To study and verify the truth table of logic gates

Switching Circuits & Logic Design, Fall Final Examination (1/13/2012, 3:30pm~5:20pm)

problem maximum score 1 28pts 2 10pts 3 10pts 4 15pts 5 14pts 6 12pts 7 11pts total 100pts

Universidad Carlos III de Madrid Digital Electronics Exercises

Chapter 3. Boolean Algebra and Digital Logic

Asynchronous (Ripple) Counters

Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts)

1. Convert the decimal number to binary, octal, and hexadecimal.

IT T35 Digital system desigm y - ii /s - iii

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

Lecture 11: Synchronous Sequential Logic

Final Exam review: chapter 4 and 5. Supplement 3 and 4

Computer Systems Architecture

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

DIGITAL SYSTEM FUNDAMENTALS (ECE421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE422) LATCHES and FLIP-FLOPS

Operating Manual Ver.1.1

ECE 301 Digital Electronics

Computer Architecture and Organization

UNIT III. Combinational Circuit- Block Diagram. Sequential Circuit- Block Diagram

CPSC 121: Models of Computation Lab #5: Flip-Flops and Frequency Division

CS150 Fall 2012 Solutions to Homework 4

EE292: Fundamentals of ECE

Synchronous sequential circuits

Logic. Andrew Mark Allen March 4, 2012

LAB 3 Verilog for Combinational Circuits

1.b. Realize a 5-input NOR function using 2-input NOR gates only.

Tribhuvan University Institute of Science and Technology Bachelor of Science in Computer Science and Information Technology

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Chapter 7 Memory and Programmable Logic

Chapter 2. Digital Circuits

Logic Design Viva Question Bank Compiled By Channveer Patil

The reduction in the number of flip-flops in a sequential circuit is referred to as the state-reduction problem.

CSE115: Digital Design Lecture 23: Latches & Flip-Flops

CPSC 121: Models of Computation Lab #5: Flip-Flops and Frequency Division

ENGG 1203 Tutorial. D Flip Flop. D Flip Flop. Q changes when CLK is in Rising edge PGT NGT

Principles of Computer Architecture. Appendix A: Digital Logic

Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 151) Pass Marks: 24

CPS311 Lecture: Sequential Circuits

Figure 1: segment of an unprogrammed and programmed PAL.

Introduction to Digital Electronics

11.1 As mentioned in Experiment 10, sequential logic circuits are a type of logic circuit where the output

A Tour of PLDs. PLD ARCHITECTURES. [Prof.Ben-Avi]

Experiment # 9. Clock generator circuits & Counters. Digital Design LAB

Serial In/Serial Left/Serial Out Operation

CS6201 UNIT I PART-A. Develop or build the following Boolean function with NAND gate F(x,y,z)=(1,2,3,5,7).

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science. EECS 150 Spring 2000

DIGITAL TECHNICS. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

Chapter 7 Counters and Registers

# "$ $ # %!"$!# &!'$("!)!"! $ # *!"! $ '!!$ #!!)! $ "# ' "

CSC258: Computer Organization. Combinational Logic

Rensselaer Polytechnic Institute Computer Hardware Design ECSE Report. Lab Three Xilinx Richards Controller and Logic Analyzer Laboratory

Physics 120 Lab 10 (2018): Flip-flops and Registers

Transcription:

Workshop Two Shaft Position Encoder Introduction Some industrial automation applications require control systems which know the rotational position of a shaft. Similar devices are also used for digital volume controls, etc, on domestic appliances. A shaft encoder is used to record the rotation typically in the form of a digital Gray code. In this workshop you need to build a decoder for such an encoder. The shaft encoder you will be using produces a 2-bit Gray code. Such encoders are usually optical (e.g., those commonly used in a mouse), but in this case, we will be using a mechanical encoder. A disk is connected to the shaft which rotates with it. Electrical contacts are made with this disk to produce one of two Gray code sequences shown below depending upon the direction of rotation. Contact 1 (A) Contact 2 (B) Contact 1 (A) Contact 2 (B) A shaft decoder module is required to convert this 2-bit Gray code (A,B) into a 4-bit position count. The 4-bit position should be incremented every time the input from the encoder changes owing to a clockwise rotation (e.g., from 00 to 01, or from 10 to 00). Similarly, the 4- bit position should be decremented every time the input from the encoder changes owing to an anticlockwise rotation (e.g., from 00 to 10, or from 01 to 00). Components 1a prototyping box connecting wire rotary shaft encoder a PAL - GAL16V8 74HC193 - counter Note: The recommended circuit for the shaft encoder is given in the lab booklet - remember to use the 4.7k pull-down resistors to turn the switch open state into a firm logic value. Also note that the encoder provided steps through all four of the output combinations for each click position. Step 1 - shaft decoder to generate clockwise/anticlockwise signals Design task 1: Draw a state diagram to decode this movement. Generate two independent

outputs, one that goes high for one clock cycle when the shaft rotates one output combination change clockwise, namely CW, and the other for one output combination change anticlockwise, namely AW. Assume 4 states, i.e., 00, 01, 11 and 10, and make the next state equal to the current input values A and B. For example, assume we are in state 00 and the shaft rotates one output combination anticlockwise giving current input values, A=1, B=0, the next state will be 10 and the outputs are AW=1 and CW=0. Now complete the state diagram for all 4 states and for all possible inputs per state (3 per state). Design task 2: From the state diagram, create a state transition table. Note that this table will have columns for the Current State, the Next State (remember that is the same as the current inputs) and for the clockwise (CW) and anticlockwise (AW) outputs. Now determine expressions for the AW and CW outputs. Remember that it is possible to use don t care conditions to simplify the expressions for AW and CW. For example, one don t care condition for both AW and CW is for the 00 to 11 state transition that we know does not ever occur. We now wish to implement a synchronous (clocked from an independent free-running clock) finite state machine (FSM) inside a PAL. The PAL has 8 possible output pins labelled P19 to P12 and 8 inputs labelled P2 to P9. Connect P2 to Contact 1 (A) and P3 to Contact 2 (B). This exercise can be completed by designing a four-state FSM, where the D type flip-flops (FFs) having inputs labelled P17 and P16 hold this state. Your equations should look something like this: P19 = p2 P18 = p3 P17 = p19 P16 = p18 P15 = <Some function of p16, p17, p18 and p19> P14 = <Some function of p16, p17, p18 and p19> This means that FF output P19 is a registered version of its input P2 (that is connected to A) and FF output P18 is a registered version of its input P3 (that is connected to B). The state of the FSM is held in the FFs having outputs P17 and P16 and these are registered versions of the FF outputs P19 and P18 respectively. Effectively, the Next State (that we have made equivalent to the current inputs) is FF outputs P19 and P18, and the Current State are FF outputs P17 and P16. The outputs labelled P15 and P14 are the Clockwise (CW) and Anticlockwise (AW) signals respectively and are therefore some function of the state (P17 and P16) and the registered inputs (P19 and P18). NOTE: As indicated, we make the outputs from the shaft encoder (A and B) synchronous by using 2 FFs before these signals are applied to the 2 FFs that implement the FSM. To do this, make sure that the PAL compiler is in registered mode. Implementation task 1: Now run your equations through the PAL compiler. Read the Appendix on PALs and the PAL compiler if you are unfamiliar with them. The compiler should be running on a stand-alone PC connected to the programmer. Implementation task 2: Now connect your PAL to a rotary encoder and your two outputs to LEDs. Connect the clock to pin 1 and make sure that the output enable (pin 11) is connected to ground. To test your design start by setting the clock to 10Hz. Make sure that each LED flashes once as the rotary encoder is moved one output combination clockwise or anticlockwise.

Step 2 - count clockwise/anticlockwise pulses Implementation task: Use the clockwise/anticlockwise signals as up/down signals for the 74HC193 counter. Connect the output of the counter to the 7-segment display. Make sure the unused inputs of the 74HC193 and tied off appropriately. Optional Bonus Step Task: How could you make use of two 74HC193 chips to provide an 8-bit up/down counter? Assessment Ticking criteria: Write up your design and answer the following questions. Demonstrate that your rotary position counter works. Once your work has met the Common Ticking Criteria (see Introduction), get your work ticked by an assessor. Remember that you need to hand in this assessed exercise as part of your portfolio of work (see the Head of Department's notice). Questions 1. Why didn't we ask you to debounce the inputs from the rotary encoder? 2. How fast can the rotary encoder be rotated before your circuit fails to count correctly? Appendix PALs and the PAL Compiler A PAL (programmable array logic) is a circuit which can be configured by the user to perform a logic function. It consists of an AND array followed by an OR array, the former being programmable. Inputs are fed into the AND array, which performs the desired AND functions and generates product terms. The various product terms are then fed into the OR array. In the OR array, the outputs of the various product terms are combined to produce the desired outputs. You will be using a small, relatively modern PAL called a GAL16V8. It has between 0 and 16 inputs and 8 to 0 outputs respectively, a common configuration is for up to 8 inputs and up to 8 outputs. Each output is driven by a single 8-input OR gate, which in turn is driven by eight 32-input AND gates. These 32 inputs can be programmed to be connected to the 16 possible inputs to the chip and their inverses. Note that when used to implement an FSM up to 8 of these inputs are actually outputs from the D-type FFs in each of the 8 output macrocells.

The output from the each OR gate is connect to an output pin through an output macrocell. This can be programmed to latch (using a D-type FF) the output or feed the output signal back into AND array. For a more detailed description of this PAL, read the datasheet. PAL Compiler To program the PAL with the functions necessary to implement a state machine, you will need a PAL compiler. This will produce a JEDEC file which is needed by the programmer. You will be using a web-based compiler. You need to type in equations using variables p2 to p9 on the input side (representing the input pins) and p12 to p19 on the output side (representing output pins).

When using the PAL Compiler you should have the above diagram in mind. The compiler expects 8 equations, one to drive each output logic macrocell (OLMC). The OLMCs in turn drive pins 19 to 12. What the 16 inputs are depends on the configuration mode of the PAL. Pins 2 to 9 are always inputs, but in registered mode pins 12 to 19 make the other 8, in complex mode pins 1, 11 and 13 to 18 are used and in simple mode pins 1, 11 to 14 and 17 to 19. The mode can be selected using the check boxes. The equations for each output (called P19 to P12, in that order) can consist of inputs, operators and brackets. The input must be referred to by the "P" followed by a number. Operators are &,, ^ and! for AND, OR, XOR and NOT respectively Examples: P19 = p2 P19 = p2 ^ p3 A half adder P18 = p2 & p3 P19 =!p19 A simple assignment latch A 1-bit counter When you have typed in your equations, click the compile button. 2011 DJ Greaves, DL Gordon, SW Moore and IJ Wassell Page last updated on 11-Aug-2011