Lab 5: Digital IO Bits, Nybbles, and Bytes

Similar documents
Lab 11 Digital Dice. Figure Digital Dice Circuit on NI ELVIS II Workstation

First Bytes Programming Lab 2

Objectives: Part 1: Build a simple power supply. CS99S Laboratory 1

Servo Motors (SensorDAQ only) Evaluation copy. Vernier Digital Control Unit (DCU) LabQuest or LabPro power supply

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Different Ways of Connecting to. 3DLevelScanner II. A.P.M Automation Solutions LTD. Version 3.0

4.1 DESCRIPTION OF CONTROLS cont.

FREQUENCY RESPONSE OF AN AUDIO AMPLIFIER

Lab 4 - Data Acquisition

CHAPTER 11: Flip Flops

Decimal Number (base 10) Binary Number (base 2)

LabVIEW Day 1 Basics. Vern Lindberg. 1 The Look of LabVIEW

Cornerstone Electronics Technology and Robotics I Week 15 Voltage Comparators Tutorial

Mini Effect Gizmo. User s Manual. RJM Music Technology, Inc.

EET 310 Programming Tools

TEECES DOME LIGHTING SYSTEMS

FORDHAM UNIVERSITY CISC Dept. of Computer and Info. Science Spring, Lab 2. The Full-Adder

SYMETRIX SOLUTIONS: TECH TIP August 2015

Lab 3 - DC Circuits and Ohm s Law

ELEC EXPERIMENT 1 Basic Digital Logic Circuits

2011, The McGraw-Hill Companies, Inc. Chapter 3

The Answer to the 14 Most Frequently Asked Modbus Questions

RGB for ZX Spectrum 128, +2, +2A, +3

IMMS-CCC. IMMS-CCC Hardwire Central Interface. Installation Instructions

The components. E3: Digital electronics. Goals:

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

PRODUCTIVITY THROUGH INNOVATION 600 CONTROL DIRECT DRIVE TECHNICAL/OPERATION MANUAL

COMBINATIONAL and SEQUENTIAL LOGIC CIRCUITS Hardware implementation and software design

ECEN 1400, Introduction to Analog and Digital Electronics

Upon completion of unit 1.1, students will be able to

LAB2 Resistors, Simple Resistive Circuits in Series and Parallel Objective:

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 TUTORIAL OUTCOME 2 Part 1

Lecture N -1- PHYS Microcontrollers

Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

Arduino Lesson 0. Getting Started

2 ASCII TABLE (DOS) 3 ASCII TABLE (Window)

Digital Electronics Detailed Outline

Lab 1: Introduction to Xilinx ISE Tutorial

MIDECO 64-outputs MIDI note decoder USER MANUAL. Roman Sowa 2012

Operating instructions Diffuse reflection sensor. OJ50xx / / 2004

PC2400 EEPROM PROGRAMMER INSTRUCTION MANUAL

ABB Drives. User s Manual. Pulse Encoder Interface Module RTAC-01

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

How to connect to a Class II router using a mobile-phone data cable specifically for Solwise & Safecom routers

Physics 3330 Experiment #2 Fall DC techniques, dividers, and bridges R 2 =(1-S)R P R 1 =SR P. R P =10kΩ 10-turn pot.

Introduction to LogixPro - Lab

Binary Representation

Parts of a Computer. Preparation. Objectives. Standards. Materials Micron Technology Foundation, Inc. All Rights Reserved

POINTS POSITION INDICATOR PPI4

GPIB Instrument Control

CHD603BM-U USB Mifare Card Reader User Manual

RS-485 Protocol Manual

2 : BISTABLES. In this Chapter, you will find out about bistables which are the fundamental building blocks of electronic counting circuits.

Designing VM2 Application Boards

SYSTEM 4C. C R H Electronics Design

How to Install a Motherboard

Lab E1: Introduction to Circuits

BUILDING INSTRUCTIONS

Numeration systems. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

The basic set up for your K2 to run PSK31 By Glenn Maclean WA7SPY

Hands On ECG. Sean Hubber and Crystal Lu

1.1 The 7493 consists of 4 flip-flops with J-K inputs unconnected. In a TTL chip, unconnected inputs

Evaluation copy. Build a Temperature Sensor. Project PROJECT DESIGN REQUIREMENTS

Controlling a Dot Matrix LED Display with a Microcontroller

Annex: VISIR Remote Laboratory

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6

Hexadecimal and Numeric Indicators. Technical Data

MICROPROCESSOR AND MICROCOMPUTER BASICS

Introduction the Serial Communications Huang Sections 9.2, 10.2 SCI Block User Guide SPI Block User Guide

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Measuring Electric Phenomena: the Ammeter and Voltmeter

Model 201 Wiegand Touchpad Reader Installation Guide

K-Type Thermocouple Sensor User s Guide

Tutorial: Configuring GOOSE in MiCOM S1 Studio 1. Requirements

Digital circuits make up all computers and computer systems. The operation of digital circuits is based on

Tutorials Drawing a 555 timer circuit

Interfacing To Alphanumeric Displays

Product Information. Gateway For Connecting EnDat Encoders to PROFIBUS-DP

PLL frequency synthesizer

Installation Guide. AXIS 2191 Audio Module Sight, Speech and Sound over IP!

The RIDZ 8x2 Audio Switcher

Maximum value. resistance. 1. Connect the Current Probe to Channel 1 and the Differential Voltage Probe to Channel 2 of the interface.

Picture 1 Lead Color Code Lead Function V-Link Function V-Link Pin Table 2 Picture 2 Node Commander software

Car Racing Game. Figure 1 The Car Racing Game

Lab 17: Building a 4-Digit 7-Segment LED Decoder

You can probably work with decimal. binary numbers needed by the. Working with binary numbers is time- consuming & error-prone.

DSP Laboratory: Analog to Digital and Digital to Analog Conversion

Digital To Analog Converter with Sine Wave Output

Fundamentals of Signature Analysis

Environment Temperature Control Using Modbus and RS485 Communication Standards

0832 Dot Matrix Green Display Information Board User s Guide

Experiment: Series and Parallel Circuits

USER GUIDE. Publication AP8509. Allen & Heath 1 XONE:K2 User Guide

OPERATING INSTRUCTIONS Model ST-888 DTMF ANI/ENI Display Decoder

Programming PIC Microcontrollers in PicBasic Pro Lesson 1 Cornerstone Electronics Technology and Robotics II

Measuring Resistance Using Digital I/O

Counters and Decoders

Switch board datasheet EB

Jianjian Song LogicWorks 4 Tutorials (5/15/03) Page 1 of 14

Transcription:

Lab 5: Digital IO Bits, Nybbles, and Bytes Introduction We live in a digital world where music, pictures, and control algorithms are all stored as digital bits. One form of communication between the real world and the digital world is done through digital IO ports. Fig.1 VU-Meter with Screen LED Indicators MyDAQ has one 3.3 V digital port consisting of eight digital bits that can be configured as inputs, outputs, or a combination of both. The port can talk to a single line (a bit), 4 bits in parallel (a nybble), or 8 bits in parallel (a byte). Feeling hungry? Four bits make a nybble and two nybbles make a byte. Purpose This lab shows how to use the mydaq port to talk to switches (inputs) or LEDs (outputs). The switches will be used to enter a secret number, which you will try to guess. This will lead us to the successive approximation technique, a common algorithm used in most analog-to-digital converter chips. Eight LEDs will be used to build a common VU-meter (Volume Unit meter) display, as in Fig 1. Equipment National Instruments Corporation 1

NI mydaq 1 Push Button Switch (SPST) 8 Switches in a DIP Package Resistors: 8 x 330 Ω and 9 x 1 kω LEDs: 2 Red, 2 Yellow, and 4 Green Solderless Breadboard Prerequisite Reference Materials Using the mydaq Digital Reader: http://zone.ni.com/devzone/cda/tut/p/id/11507 Using the mydaq Digital Writer: http://decibel.ni.com/content/docs/doc-12945 Output Light Using a Basic 5 mm LED: http://zone.ni.com/devzone/cda/epd/p/id/6410 Exercise 5-1: Getting Started The first step is to make a single input switch for the mydaq digital port. Connect a 1kΩresistor to the +5 V mydaq screw terminal. The output after the resistor is called a logic 1 or HI. The mechanical switch goes between the logic 1 and ground (DGND on the mydaq connector). The digital input will be taken at the node point (logic 1 and Switch). Connect a wire from this point to DIO(0) on the mydaq connector. Fig. 2 Connection Circuit for a Single Switch to the mydaq Port Note: the 1 kω resistor limits the current from the power supply and prevents damage that may occur if the power supply was accidentally shorted. From the NI ELVISmx Instrument Launcher strip, select DigIn. 2 ni.com

Fig. 3 NI ELVISmx Digital Reader Instrument Panel Verify the settings seen in Fig. 3 and press the button [Run]. With no switch pushed, bit 0 will be ON or HI, and the Numeric Value will read 1. Pressing the push button produces the opposite state, OFF or LO, and the numerical value will read 0. Now that we have verified our test circuit, it is time to build a complete 8-bit input port. 8-Bit Data Input Port You will need to replicate your test circuit for all the other bits (b1-b7). An easy way is to employ a 16-pin dual-in-line set of eight switches. You will also need eight 1 kω resistors, 10 wires, and a breadboard. Build the circuit as shown in Fig. 4. National Instruments Corporation 3

Fig. 4 Wiring Layout for Connecting Eight Switches to the mydaq Digital Port After checking all the wires, connect the bit lines (yellow and green) and power lines (red and black) to the mydaq black edge connector. [Run] the DigIn Virtual Instrument. For all bits OFF, the Numerical Value reads 0. For all bits ON, the Numerical Value reads FF. Nybble Bits A nybble consists of four lines (bits) connected in parallel, and each bit binary is weighted 2 i, where i = 0-3. Weights are 1, 2, 4, and 8. Example: Bits (0111) read as 7, and bits (1011) read as B. There are 2 4 or 16 possible bit combinations with numerical values running from 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E to F Note: MyDAQ will display bit values in hexadecimal (x). 4 ni.com

A small x beside the numerical value on the mydaq display indicates that the port value is in hexadecimal notation. Try various switch combinations of the first four switch positions. Byte Bits A byte consists of eight lines (bits) connected in parallel with each bit binary weighted as 2 i,where i = 0 7. Weights are 1, 2, 4, 8, 16, 32, 64, and 128. Example: Bits (0000 0111) read as 07, and bits (1001 1011) read as 9B. There are 2 8 or 256 possible combinations from 00 to FF (hexadecimal). MyDAQ DigIn reads the 8-bit port values as two binary encoded nybbles called the LOW nybble and HI nybble. Each is represented by a single character: The numerical value is just 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F HI Nybble (Character Value) *16 + LO Nybble (Character Value) or Hex Decimal 0000 0000 0 0 0001 0001 11 17 1111 1111 FF 255 Any number between and including the numbers 0 to 255 can be represented by eight binary encoded bits. These can be represented by two hexadecimal characters or three numerical characters. What combination of switch positions would correspond to 123? Exercise 5-2: A Guessing Game Suppose you asked a friend to guess a number between 0 and 255, and you would attempt to guess it in as few tries as possible. If you are really National Instruments Corporation 5

lucky, you might guess it within a few tries. If you were really unlucky, it could take 256 tries. No fun at all! Now suppose you changed the rules and asked your friend to tell you if your guess was too high, too low, or right on. You would probably get his secret number within 10 to 15 tries. But there is a method that will always give you the correct number within eight or fewer tries. It is called the successive approximation technique and uses an inverse binary scheme guessing from the most significant bit to the least significant bit. Successive Approximation is central to most analog-to-digital converter ICs. Our next project demonstrates how SA works. Load the LabVIEW program called Guessing Game.vi. It uses the 8-bit I/O port connected to a bank of eight switches, as discussed above. Have a friend load a secret binary encoded number into the switches. Now, when ready, [Run] the program. Guesses are loaded into the [Guess #] control box. Click on the blue button to test your guess. Responses are shown as Red: Guess is greater than secret number Green: Guess is less than secret number Yellow: Guess is correct. Bingo! The number of tries is also shown. Fig. 5 LabVIEW Front Panel for Simple Guessing Game 6 ni.com

How Did They Do That? Take a look at the program s block diagram in Fig. 6. Fig. 6 LabVIEW Block Diagram for Simple Guessing Game The DAQAssistant has been used to read mydaq s 8-bit I/O port. It outputs an array of unsigned 8-bit integers. The first array element index (0) contains the measured bit values on the port. [Guess #] is compared with the port value using two compare VIs. One tests for greater than (>), while the other tests for equality (=). The output of [>] is an LED indicator (red {true} and green {not true}). The output of [=] is an LED indicator (yellow {true} and transparent {not true}). Both indicators have the same size and location; however, the [>] indicator is on top of the [=] one. When the correct guess is found, the top indicator (red or green) becomes invisible, and the underlying yellow indicator becomes visible. BINGO! Exercise 5-3: Successive Approximation (SA) Algorithm Successive Approximation creates a test value equal to the most significant bit in an 8-binary number (128). National Instruments Corporation 7

o If the test value is greater than the secret number, then this bit is set to 1 in an answer register. o If the test value is less than the secret number, then this bit is set to 0 in an answer register. The next test value becomes the answer register. Now add the next msb value (64) to the test value and repeat the above test. o If the test value is greater than the secret number, then this bit is set to 1 in an answer register. o If the test value is less than the secret number, then this bit is set to 0 in an answer register. The next test value becomes the answer register. Continue until you have tested all the remaining bits, b5-b0. When completed, you will have the secret number after exactly eight guesses. If you also test for equality, then you will get the answer in fewer tries if the secret number is some simple combination of 128, 64, 32, 16, 8, 4, or 2. Set up a secret number on the eight switches. Use the Successive Approximation technique with the Guessing Game.vi program to find out how many tries it takes to find the secret number. Example: Guess (128). If n > 128, then keep 128. Next guess is 128 + 64, If n < 128, then do not keep 128. Next guess is 64. Continue until you have completed eight guesses. Works every time! Exercise 5-4: MyDAQ Binary Outputs Binary bits can be output easily with the mydaq digital writer. From your NI ELVISmx Instrument Launcher strip, select DigOut. 8 ni.com

Fig. 7 NI ELVISmx Digital Writer Instrument Panel Set the Lines to Write to [0-7]. This mydaq virtual instrument is capable of outputting manually an 8-bit binary number with operations like Toggle, Rotate, or Shift (left or right) applied. In addition, common binary operations such as Ramp, Alternating 1/0 s, and Walking 1 s generate useful binary bit shows. To see these patterns in the real world, connect eight LEDs to the digital port lines (b0-b7). Each LED has a 333 Ω current-limiting resistor wired from the LED to +5 V. The anode (long leg) is on the side of the +5 V power supply. National Instruments Corporation 9

Take your LEDs for a test ride. Fig. 8 Eight Colored Leds in a VU-Meter Format Exercise 5-5: VU Meter A VU meter is a bar graph display consisting of a linear series of eight LEDs. The greater the number, the more LEDs are lit. Example: If V = 0, no LEDs are lit; if V = 1.0, all LEDs are lit. In this project, use eight LEDs (four green, two yellow, and two red) configured as green for the lower numbers, yellow for mid-range numbers, and red for the highest numbers. Load the LabVIEW program VU Meter.vi. The front panel is shown in Fig. 1. View the block diagram in Fig. 9. 10 ni.com

Fig. 9 VU Meter.vi BD Converts Audio Levels to a db-scaled LED Output The VU meter has a bar-like graphical display where all LEDs are lighted, up to and including the measured value. The VU meter uses a relative scale measured in decibels. For this example, the maximum signal is set to 1.0 V, which is suitable for use with audio signals. The reference voltage is 1.0 V. Hence, the maximum output is 0 decibels with all LEDs lit. Just like we embedded a digital reader inside a LabVIEW program to read external switches, you can use the NI ELVISmx Digital Writer to embed a digital writer into a program to write to external LEDs. Note: The front panel [Input] box is set to a logarithmic scale to better reflect audio input levels. Give it a try. In later labs, you can use this program and circuit as an external VU Meter. The VU meter then becomes an interesting real-world display. Any signal, such as audio level, temperature, or frequency range, can be expressed in a VU meter-type display. National Instruments Corporation 11