IOT Design: An Embedded System Overview Definitions DAY NETW 1010 IOT Design: An Embedded System Overview Definitions DAY Dr. Eng. Amr T. Abdel-Hamid Fall 2016
IRing: Anti-Cheating RING
IRing: Remote Control
Embedded Systems According to forecasts, future of IT characterized by terms such as Disappearing computer, Ubiquitous computing, Pervasive computing, Ambient intelligence, Post-PC era, Cyber-physical systems. Internet of Things Basic technologies: Embedded Systems Communication technologies
Embedded Systems & Cyber-Physical Systems “Dortmund“ Definition: [Peter Marwedel] Embedded systems are information processing systems embedded into a larger product Berkeley: [Edward A. Lee]: Embedded software is software integrated with physical processes. The technical problem is managing time and concurrency in computational systems. Definition: Cyber-Physical (cy-phy) Systems (CPS) are integrations of computation with physical processes [Edward Lee, 2006].
Embedded System Hardware Embedded system hardware is frequently used in a loop (“hardware in a loop“):
Automotive electronics Functions by embedded processing: ABS: Anti-lock braking systems ESP: Electronic stability control Airbags Efficient automatic gearboxes Theft prevention with smart keys Blind-angle alert systems ... etc ... Multiple networks Body, engine, telematics, media, safety, ... Multiple networked processors Self DRIVING Vehicles Can be skipped
Forestry Machines Networked computer system Controlling arms & tools Navigating the forest Recording the trees harvested Crucial to efficient work “Tough enough to be out in the woods” Can be skipped
Smart buildings Examples Integrated cooling, lightning, room reservation, emergency handling, communication Goal: “Zero-energy building” Expected contribution to fight against global warming
ES 2016 Grand Failure
Can ES get Hacked?
Embedded System Hardware Embedded system hardware is frequently used in a loop (“hardware in a loop“):
Some common characteristics of ES Dependability Single-functioned (dedicated System) Executes a single program, repeatedly Tightly-constrained (Efficient) Low cost, low power, small, fast, etc. Reactive and real-time Continually reacts to changes in the system’s environment Must compute certain results in real-time without delay
Dependability ES Must be dependable, Reliability R(t) = probability of system working correctly provided that is was working at t=0 Maintainability M(d) = probability of system working correctly d time units after error occurred. Availability A(t): probability of system working at time t Safety: no harm to be caused Security: confidential and authentic communication Even perfectly designed systems can fail if the assumptions about the workload and possible errors turn out to be wrong. Making the system dependable must not be an after-thought, it must be considered from the very beginning
Efficiency ES must be efficient Code-size efficient Run-time efficient Weight efficient Cost efficient Energy efficient
Real-time constraints Many ES must meet real-time constraints A real-time system must react to stimuli from the controlled object (or the operator) within the time interval dictated by the environment. For real-time systems, right answers arriving too late are wrong. “A real-time constraint is called hard, if not meeting that constraint could result in a catastrophe“ [Kopetz, 1997]. All other time-constraints are called soft. A guaranteed system response has to be explained without statistical arguments
Real-Time Systems embedded embedded real-time real-time Embedded and Real-Time? Most embedded systems are real-time Most real-time systems are embedded embedded embedded real-time real-time © Jakob Engblom
Reactive & hybrid systems Typically, ES are reactive systems: “A reactive system is one which is in continual interaction with is environment and executes at a pace determined by that environment“ [Bergé, 1995] Behavior depends on input and current state. automata model appropriate, model of computable functions inappropriate. Hybrid systems (analog + digital parts).
Dedicated systems Dedicated towards a certain application Knowledge about behavior at design time can be used to minimize resources and to maximize robustness Dedicated user interface (no mouse, keyboard and screen)
Design Challenge Time-to-prototype: the time needed to build a working version of the system Time-to-market: the time required to develop a system to the point that it can be released and sold to customers NRE cost (Non-Recurring Engineering cost): The one-time monetary cost of designing the system Flexibility: the ability to change the functionality of the system without incurring heavy NRE cost
Design challenge – optimizing design metrics Obvious design goal: Construct an implementation with desired functionality Key design challenge: Simultaneously optimize numerous design metrics Design metric A measurable feature of a system’s implementation Optimizing design metrics is a key challenge
Design metric competition -- improving one may worsen others Expertise with both software and hardware is needed to optimize design metrics Not just a hardware or software expert, as is common A designer must be comfortable with various technologies in order to choose the best for a given application and constraints Size Performance Power NRE cost
Hypothetical design flow Design repository Specification Design hardware Test * Application Knowledge Application mapping Evaluation & Validation (energy, cost, performance, …) Optimization * Could be integrated into loop System software Generic loop: tool chains differ in the number and type of iterations
Design Questions How much Power is needed? Is power an issue? Average Current needed? Max. Transient Current Do I need communications/Networking module? How far? (Distance Travelled) Authorized Frequencies Antenna Size Required Power It is 1 device or in a network? Do I need routing? …………
Data Rate
Power Dissipation
IOT EXTRA Design Challenges Larger Scale: Scalability, the ability of a network to support the increase of its limiting parameters. We discuss the first four scalability issues here. Large Network Size: In the Internet of Things, we are talking about interaction with thousands of devices in one place. Massive Number of Events: A significant challenge is posed by the enormous number of events generated by objects. Mobility Rate: Higher mobility rate causes more breakage of links and causes more routing information becoming out-of-date. Heterogeneous Devices: In the Internet of Things there is a wide variety of hardware and devices, in all shapes and sizes.
IOT EXTRA Design Challenges (cont.) Spontaneous Interaction: Sudden interactions happen as the objects move around and come into other objects’ wireless range. This leads to the spontaneous generation of events. Zero Infrastructure: In the Internet of Things setting, devices need to discover each other as well as the resources provided by other devices in the surroundings. The challenge here is that there is no fixed infrastructure to manage resource publication, discovery and communication.
IOT GENERIC Architecture Processing API Communication Module Sensor/ Actuator Communication API Database Database API Processor Power Supply (Battery) Power Manger
Hardware Node
Controller Four important factors for the controller Number of transistors -> size, cost, power Number of clock cycles -> power Time to MARKET-> cost, acceptance Nonrecurring engineering cost (NRE) -> cost, acceptance Ideal: Minimize all factors at the same time!
Tasks of the controller Running of (real time) data processing and communication protocols Perform and control the application program Energy management of the node Different operation modes available (active, idle, listen, sleep, etc.)
Embedded processors (MicroControllers ) Programmed once by manufacturer of system Executes a single program (or a limited suite) with few parameters Task-specific can be optimized for specific application Interacts with environment in many ways direct sensing and control of signal wires communication protocols to environment and other devices real-time interactions and constraints
Microprocessors and Microcontrollers A microprocessor unit (MPU) is a processor on one silicon chip. Microcontrollers are used in embedded computing. A Microcontroller unit (MCU) is a microprocessor with some added circuitry on one silicon chip.
A Single Chip Microcontroller Contains
Typical general-purpose architecture CSE 477 Typical general-purpose architecture Display (with dual-port video RAM) CPU Memory system bus I/O (serial line, keyboard, mouse) Network Interface Disk all the parts around the processor are usually required standard interfaces
Typical task-specific architecture Microcontroller I/O Interface custom logic ROM RAM any of the parts around the microcontroller are optional standard interface
MCUs can be classified according: Introduction to Embedded Systems & Microcontrollers MCU Types MCUs can be classified according: MCU bits (e.g. 8-bit, 16-bit, 32-bit) Instruction Set Architecture (ISA) CSEN701: Embedded Systems
MCU Bit Definition The number of bits describing the data path defines Microcontroller Bit Definition
Instruction Set Architecture Instruction Set Architecture (ISA) is the part of the computer architecture related to programming, including the native data types, instructions, registers, addressing modes, memory architecture, interrupt and exception handling, and external I/O. The ISA defines: Operations that the processor can execute, The mechanism of Data Transfer and how to access data, Control Mechanisms (branch, jump, etc) “Contract” between programmer/compiler and hardware The main ISAs are CISC and RISC: CISC stands for Complex Instruction Set Computer RISC stands for Reduced Instruction Set Computer
"LOAD" and "STORE“ are incorporated in instructions The CISC Approach Emphasis on hardware Includes multi-clock Instructions Has a large amount of different (in length) and complex instructions The philosophy behind it is that hardware is always faster than software, therefore one should make a powerful instruction-set, Memory-to-memory: "LOAD" and "STORE“ are incorporated in instructions Small code sizes (use less number of instructions), Requires more transistors
(i.e. one clock), pipelining is possible. The RISC Approach RISC processors only use simple instructions that can be executed within one clock cycle. Because there are more lines of code, more RAM is needed to store the assembly level instructions. The compiler must also perform more work to convert a high-level language statement into code of this form. Because each instruction requires only one clock cycle to execute, the entire program will execute in approximately the same amount of time as the multi-cycle "MULT" command. These RISC "reduced instructions" require less transistors of hardware space than the complex instructions, leaving more room for general purpose registers. Because all of the instructions execute in a uniform amount of time (i.e. one clock), pipelining is possible. It’s also called : Load-Store Architecture
Microcontroller Features Processor speed: Fundamental measure of processing rate of device Value of interest is in MIPS, not MHz Supply voltage/current: Measure of the amount of power required to run the device Multiple modes (sleep, idle, etc) 3) Usually only for heavy ADC
Common Memory Types in MCUs RAM EEPROM Flash Memory
RAM: Random Access Memory Volatile or Non-Permanent Memory, i.e., data is lost after the removal of power, Can be Written too Many Times, It is a general purpose memory which is typically used for storing user data, temporary or Changeable Data Most microcontrollers have some amount of internal RAM. Generally, 1 kbytes (“Embedded” in MCUs) is a common amount, although some microcontrollers have more, some less.
It is electrically-erasable-and-programmable. EEPROM: Electrically Erasable Programmable Read-Only Memory It is electrically-erasable-and-programmable. Internally, they are similar to EPROMs, but the erase operation is accomplished electrically, rather than by exposure to ultraviolet light. Any byte within an EEPROM may be erased and rewritten.– Erased by higher voltage. The primary tradeoff for this improved functionality is higher cost, though write cycles are also significantly longer than writes to a RAM. EEPROM are typically used to store permanent data
Flash Memory Flash memory devices are high density, low cost, nonvolatile, fast (to read, but not to write), and electrically reprogrammable. Write/Erase large blocks of bytes Read bytes EEPROM is similar to flash memory (sometimes called flash EEPROM). The principal difference is that EEPROM requires data to be written or erased one byte at a time whereas flash memory allows data to be written or erased in blocks. Flash memory is typically used in MCUs for storing program code
Popular Microcontrollers Intel 8051 Microchip PIC Atmel AVR ARM
Why study the ARM architecture (and the Cortex-M3 in particular)?
Lots of manufacturers ship ARM products
Introduction to ARM Acorn Computers Ltd. (Cambridge, England) Nov. 1990 First called Acorn RISC Machine, then Advanced RISC Machine Based on RISC architecture work done at UCal Berkley and Stanford ARM only sells licenses for its core architecture design Optimized for low power & performance VersatileExpress board with Cortex-A9 (ARMv7) core will be “emulated” using Linaro builds. This also means some things may not work. You’ve been warned. RISC which stands for Reduced Instruction Set computing is an idea that simple instructions can provide higher performance if this enables faster execution of each instruction
ARM architecture versions Family ARMv1 ARM1 ARMv2 ARM2, ARM3 ARMv3 ARM6, ARM7 ARMv4 StrongARM, ARM7TDMI, ARM9TDMI ARMv5 ARM7EJ, ARM9E, ARM10E, Xscale ARMv6 ARM11, ARM Cortex-M ARMv7 ARM Cortex-A, ARM Cortex-M, ARM Cortex-R ARMv8 Not available yet. Will support 64-bit addressing + data
Handling electronics - How NOT to Do It! Improper Handling - NEVER!!!
Handling electronics - The Proper Way Proper Handling - by the edges!!! Wash your hands after handling the boards. Solder contains lead (not RoHS compliant yet!)
ATmega328 Microcontroller Pin number Pin name Special function
Microcontroller Ports and Pins The communication channels through which information flows into or out of the microcontroller Ex. PORTB Pins PB0 – PB7 May not be contiguous Often bi-directional C
Port Pin Data Directionality Input When you want to take information from the external world (sensors) into the MCU Output When you want to change the state of something outside the MCU (turn a motor on or off, etc.) Pins default to input direction on power-up or reset Your program can set or change the directionality of a pin at any time This is really important!
ATmega328 Block Diagram Input Output
Setting the Pin Data Direction Arduino pinMode(pin_no., dir) Ex. Make Arduino pin 3 (PD3) an output pinMode(3, OUTPUT); pinMode(PIN_D3, OUTPUT); // with me106.h Note: one pin at a time Suppose you wanted Arduino pins 3, 5, and 7 (PD3, PD5, and PD7) to be outputs? Is there a way to make them all outputs at the same time? Yes! Answer coming later…
Pin Voltages Microcontrollers are fundamentally digital devices. For digital IO pins: Information is ‘coded’ in two discrete states: HIGH or LOW (logic: 1 or 0) Voltages TTL 5 V (for HIGH) 0 V (for LOW) 3.3 V CMOS 3.3 V (for HIGH)
Pin Used as an Output Turn on an LED, which is connected to pin Arduino pin 0 (PD0) (note the resistor!) What should the data direction be for pin 0 (PD0)? pinMode(____, ____); Turn on the LED digitalWrite(PIN_LED,HIGH); Turn off the LED digitalWrite(PIN_LED,LOW); ATmega328 Arduino pin 0 (PD0) Explain circuit schematic symbol and behavior of an LED Sources for parts: HSC Electronics (Ryder St. near Lawrence and Central) 10% discount with student ID; Electronics Flea Market (coming on March 8, 2014); Jameco; DigiKey; Avnet; Mouser; Adafruit; SparkFun; Seeed; NKC; eBay pinMode(0,OUTPUT);
Pins as Inputs and Pull-up Resistors - 1 Using a switch as a sensor Ex. Seat belt sensor Detect the switch state What should the data direction be for Arduino pin 3 (PD3)? pinMode(____, ____); What will the voltage be on PD3 when the switch is closed? What will the voltage be on PD3 when the switch is open? Indeterminate! ATmega328 Arduino pin 3 (PD3) SPST Schematic symbol for the switch is a single-pole, single-throw (SPST). Poles are the number of separate circuits controlled by the switch. Throws are the number of separate contacts that the movable element can mate with. pinMode(3, INPUT); momentary
Pins as Inputs and Pull-up Resistors - 2 Switch as a sensor, cont. Make the voltage on the pin determinate by turning on the pull-up resistor for PD3 Assuming PD3 is an input: digitalWrite(PIN_SWITCH,HIGH); turns on the “pull-up” resistor pinMode(PIN_SWITCH,INPUT_PULLUP); What will the voltage on PD3 be when the switch is open? VTG What will the voltage on PD3 be when the switch is closed? ATmega328 VTG= +5V 1 PD3 To here 9/4/12
Pins as Inputs and Pull-up Resistors - 3 Switch as a sensor, cont. To turn off the pull-up resistor Assuming PD3 is an input: digitalWrite(PIN_SWITCH,LOW); turns the “pull-up” resistor off ATmega328 PD3 VTG= +5V 1 Refer them to the schematic of the PortMaster board, which they are building.
Pins as Inputs and Pull-up Resistors - 4 Possibility of ‘weak drive’ when pull-up resistor is turned on Pin set as an input with a pull-up resistor turned on can source a small current Remember this! ATmega328 PD3 VTG= +5V 1 iweak
Example 1 Make Arduino pins 3, 5, and 7 (PD3, PD5, and PD7) to be outputs Arduino approach Alternate approach pinMode(3, OUTPUT); pinMode(5, OUTPUT); pinMode(7, OUTPUT); DDRD = 0b10101000; or DDRD = 0xA8; Or if me106.h is used: pinMode(PIN_D3, OUTPUT); pinMode(PIN_D5, OUTPUT); pinMode(PIN_D7, OUTPUT); DDRD | = 1<<PD7 | 1<<PD5 | 1<<PD3; More on this coming soon!
Example 2 Make pins Arduino pins 0 and 1 (PD0 and PD1) inputs, and turn on pull-up resistors Arduino approach Alternate approach pinMode(0, INPUT); pinMode(1, INPUT); digitalWrite(0, HIGH); digitalWrite(1, HIGH); DDRD = 0; // all PORTD pins inputs PORTD = 0b00000011; or PORTD = 0x03; or better yet: Or if me106.h is used: pinMode(PIN_D0, INPUT); pinMode(PIN_D1, INPUT); digitalWrite(PIN_D0, HIGH); digitalWrite(PIN_D1, HIGH); DDRD & = ~(1<<PD1 | 1<<PD0); PORTD | = (1<<PD1 | 1<<PD0); More on this coming soon!
Structure of an Arduino Program /* Blink - turns on an LED for DELAY_ON msec, then off for DELAY_OFF msec, and repeats BJ Furman rev. 1.1 Last rev: 22JAN2011 */ #define LED_PIN 13 // LED on digital pin 13 #define DELAY_ON 1000 #define DELAY_OFF 1000 void setup() { // initialize the digital pin as an output: pinMode(LED_PIN, OUTPUT); } // loop() method runs forever, // as long as the Arduino has power void loop() digitalWrite(LED_PIN, HIGH); // set the LED on delay(DELAY_ON); // wait for DELAY_ON msec digitalWrite(LED_PIN, LOW); // set the LED off delay(DELAY_OFF); // wait for DELAY_OFF msec An arduino program == ‘sketch’ Must have: setup() loop() configures pin modes and registers runs the main body of the program forever like while(1) {…} Where is main() ? Arduino simplifies things Does things for you This slide is meant as a quick overview of an Arduino sketch. We’ll unpack and describe the pieces in more detail later. Think of setup() as what you would do when you first get in a rental car or a car you have borrowed from a friend: adjust the mirrors, adjust the steering wheel, the seats, change the stereo channel settings, etc. The car can be driven by anyone, but everyone likes to customize it for their comfort. main() { init(); setup(); while (1) loop(); } And the reason that they do it this way is so it's guaranteed that init() gets called, which is critical for Arduino initialization.
Digital IO – Practice 1 ‘Reading a pin’ Write some lines of C code for the Arduino to determine a course of action if the seat belt has been latched (switch closed). If latched, the ignition should be enabled through a call to a function ig_enable(). If not latched, the ignition should be disabled through a call to a function ig_disable() Write pseudocode first ATmega328 PD3 Assumes D3 is set as an input and pull-up resistor is turned on. Work up as an in-class active learning exercise. Problem statement: “Write a short program that calls a function, ig_enable() if the seat belt is latched or a function ig_disable() if the seatbelt is not latched.” If latched, then call function ig_enable() If not latched then call function ig_disabled()
Digital IO – Practice 1 Pseudocode ‘Reading a pin’ Pseudocode: Set up PD3 as an input Turn on PD3 pull-up resistor Read voltage on Arduino pin 3 (PIN_D3) IF PIN_D3 voltage is LOW (latched), THEN call function ig_enable() ELSE call function ig_disable() ATmega328 PD3 VTG= +5V 1 Assumes D3 is set as an input and pull-up resistor is turned on. Work up as an in-class active learning exercise. Problem statement: “Write a short program that calls a function, ig_enable() if the seat belt is latched or a function ig_disable() if the seatbelt is not latched.”
Digital IO – Practice 1 Code ‘Reading a pin’ Pseudocode: Set up PD3 as an input Turn on PD3 pull-up resistor Read voltage on Arduino pin 3 (PIN_D3) IF PIN_D3 voltage is LOW (latched), THEN call function ig_enable() ELSE call function ig_disable() ATmega328 PD3 VTG= +5V 1 One way (snippet, not full program) #define PIN_SWITCH 3 #define LATCHED LOW pinMode(PIN_SWITCH,INPUT_PULLUP); belt_state = digitalRead(PIN_SWITCH); if (belt_state == LATCHED) { ig_enable(); } else { ig_disabled(); } Assumes D3 is set as an input and pull-up resistor is turned on. Work up as an in-class active learning exercise. Problem statement: “Write a short program that calls a function, ig_enable() if the seat belt is latched or a function ig_disable() if the seatbelt is not latched.”
Digital IO – Practice 2 ‘Reading from and writing to a pin’ Write some lines of C code for the Arduino to turn on a lamp (PD2) and buzzer (PD3) if the key is in the ignition (PD0 closed), but seat belt is not latched (PD1 open) (diagram shows only one of the two switches, but both are similar) Pseudocode first ATmega328 PD0, PD1 PD2 PD3 Set up data direction of pins Make PD0 and PD1 inputs Turn on pull up resistors for PD0 and PD1 Make PD2 and PD3 outputs Loop forever IF key is in ignition THEN IF belt is latched, THEN Turn off buzzer Turn off lamp ELSE Turn on lamp Turn on buzzer
Digital IO – Practice 2 Pseudocode Set up data direction of pins Make PD0 and PD1 inputs Turn on pull up resistors for PD0 and PD1 Make PD2 and PD3 outputs Loop forever IF key is in ignition THEN IF belt is latched, THEN Turn off buzzer Turn off lamp ELSE Turn on lamp Turn on buzzer ATmega328 PD0, PD1 VTG= +5V 1 PD2 PD3 Arduino style Note #define for state of switches – an Abstraction
Digital IO – Practice 2 (Arduino style code) #define PIN_IGNITION 0 #define PIN_SEATBELT 1 #define PIN_LED 2 #define PIN_BUZZER 3 #define SEATBELT_LATCHED LOW #define KEY_IN_IGNITION LOW #define LED_ON HIGH #define LED_OFF LOW #define BUZZER_ON HIGH #define BUZZER_OFF LOW void setup() { pinMode(PIN_IGNITION, INPUT_PULLUP); // key switch pinMode(PIN_SEATBELT, INPUT_PULLUP); // belt latch switch pinMode(PIN_LED, OUTPUT); // lamp pinMode(PIN_BUZZER, OUTPUT); // buzzer } void loop() { /* see next page for code */} ATmega328 PD0, PD1 VTG= +5V 1 PD2 PD3 Arduino style Note #define for state of switches – an Abstraction. Deals with the condition as a concept rather than just a number.
Digital IO – Practice 2 (Arduino style code) /* see previous page for code before loop() */ void loop() { int key_state = digitalRead(PIN_IGNITION); int belt_state = digitalRead(PIN_SEATBELT); if (key_state == KEY_IN_IGNITION) if (belt_state == SEATBELT_LATCHED) digitalWrite(PIN_BUZZER, BUZZER_OFF); digitalWrite(PIN_LED, LED_OFF); } else // key is in ignition, but seatbelt NOT latched digitalWrite(PIN_BUZZER, BUZZER_ON); digitalWrite(PIN_LED, LED_ON); else // key is NOT in ignition ATmega328 PD0, PD1 VTG= +5V 1 PD2 PD3 Arduino style Note #define for state of switches – an Abstraction. Deals with the condition as a concept rather than just a number.
Digital IO – Practice 3 (Register style code) /* NOTE: #defines use predefined PORT pin numbers for ATmega328 */ #define PIN_IGNITION PD0 #define PIN_SEATBELT PD1 #define PIN_LED PD2 #define PIN_BUZZER PD3 #define SEATBELT_LATCHED LOW #define KEY_IN_IGNITION LOW #define LED_ON HIGH #define LED_OFF LOW #define BUZZER_ON HIGH #define BUZZER_OFF LOW #define _BIT_MASK( bit ) ( 1 << (bit) ) // same as _BV( bit) void setup() { PORTD = 0; // all PORTD pullups off DDRD = _BIT_MASK(PIN_LED) | _BIT_MASK(PIN_BUZZER); // LED and buzzer PORTD | = _BV(PIN_IGNITION) | _BV(PIN_SEATBELT); // pullups for switches } /* See next page for loop() code */ ATmega328 PD0, PD1 VTG= +5V 1 PD2 PD3 PORT style Use descriptive symbolic names or const int definitions for the pins Use compound if statement instead of nested if
Digital IO – Practice 3 (Register style code) /* see previous page for setup() code */ void loop() { uint8_t current_PORTD_state, key_state, belt_state; current_PORTD_state = PIND; // snapshot of PORTD pins key_state = current_PORTD_state & _BV(PIN_IGNITION); belt_state = current_PORTD_state & _BV(PIN_SEATBELT); if (key_state == KEY_IN_IGNITION) if (belt_state == SEATBELT_LATCHED) PORTD & = ~( _BV(PIN_LED) | _BV(PIN_BUZZER) ); } else PORTD | = ( _BV(PIN_LED) | _BV(PIN_BUZZER) ); PORTD & = ~( _BV(PIN_LED) | _BV(PIN_BUZZER) ); ATmega328 PD0, PD1 VTG= +5V 1 PD2 PD3 PORT style uint8_t is a platform-independent way to say that the variable is to store an 8-bit value that is to be interpreted as an unsigned integer Use compound if statement instead of nested if