CSCI1600: Embedded and Real Time Software

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 6 Digital Inputs
Advertisements

Encoders, Motors, Power, Mini Project #1 10/24/2014.
Lecture 9: D/A and A/D Converters
Analogue to Digital Conversion
Quantization Prof. Siripong Potisuk.
Digital Signal Processing Techniques ECE2799 Lecture Prof. W. Michalson.
JF 12/04111 BSC Data Acquisition and Control Data Representation Computers use base 2, instead of base 10: Internally, information is represented by binary.
COMP3221: Microprocessors and Embedded Systems Lecture 20: Analog Output Lecturer: Hui Wu Session 2, 2004.
Digital I/O Connecting to the Outside World
Digital to Analog Converters
Embedded Programming and Robotics
Engineering 1040: Mechanisms & Electric Circuits Fall 2011 Introduction to Embedded Systems.
ACOE2551 Microprocessors Data Converters Analog to Digital Converters (ADC) –Convert an analog quantity (voltage, current) into a digital code Digital.
Teachers Name : Suman Sarker Telecommunication Technology Subject Name : Microcontroller & Embedded System Subject Code : 6871 Semester : 7th Department.
Data Acquisition Systems
ELN5622 Embedded Systems Class 7 Spring, 2003 Aaron Itskovich
COMP3221: Microprocessors and Embedded Systems Lecture 18: Computer Buses and Parallel Input/Output (II) Lecturer: Hui.
SIGMA-DELTA ADC SD16_A Sigma-Delta ADC Shruthi Sujendra.
Khaled A. Al-Utaibi  The Push Button  Interfacing Push Buttons to Arduino  Programming Digital Inputs  Working with “Bouncy”
Representing Numerical Data Analog Any signal that varies continuously over time Mechanical Pneumatic Hydraulic Electrical Digital Quantities are represented.
CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.
CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.
CSCI1600: Embedded and Real Time Software Lecture 2: Introduction Steven Reiss, Fall 2015.
Analog Capture- Port E. Digital to Analog and Analog to Digital Conversion D/A or DAC and A/D or ADC.
CSCI1600: Embedded and Real Time Software Lecture 9: Input Output Concepts Steven Reiss, Fall 2015.
CSCI1600: Embedded and Real Time Software Lecture 14: Input/Output II Steven Reiss, Fall 2015.
Analog/Digital Conversion
CSCI1600: Embedded and Real Time Software Lecture 16: Advanced Programming with I/O Steven Reiss, Fall 2015.
Digital to Analog Converter (DAC)
INTERNET OF EVERYTHING SDU 2016 Week 4. Simple Digital and Analog Inputs  The Arduino’s ability to sense digital and analog inputs allows it to respond.
CSCI1600: Embedded and Real Time Software Lecture 15: Advanced Programming Concepts Steven Reiss, Fall 2015.
Lecture Notes / PPT UNIT III
Analog-Digital Conversion. Analog outputs from sensors and analog front- ends (analog signal conditioning) have to be converted into digital signals.
Components of Mechatronic Systems AUE 425 Week 2 Kerem ALTUN October 3, 2016.
Application Case Study Christmas Lights Controller
Digital to analog converter [DAC]
MECH 373 Instrumentation and Measurements
Microprocessors Data Converters Analog to Digital Converters (ADC)
EKT124 Digital Electronics 1 Introduction to Digital Electronics
Assist. Prof. Rassim Suliyev - SDU 2017
Application Case Study Security Camera Controller
Microcontroller basics
EI205 Lecture 13 Dianguang Ma Fall 2008.
A lecture for Arduino Course, Winter 2017/18
IR Control Materials taken from a variety of sources including IR Remote for the Boe-Bot by Andy Lindsay.
CSCI1600: Embedded and Real Time Software
Sequential Circuits: Latches
ECET 340 Competitive Success/snaptutorial.com
ECET 340 Education for Service-- snaptutorial.com.
ECET 340 Teaching Effectively-- snaptutorial.com.
Internet-of-Things (IoT)
CSCI1600: Embedded and Real Time Software
Analog to Digital Converters Electronics Unit – Lecture 7
Digital Acquisition of Analog Signals – A Practical Guide
Sequential Circuits: Latches
McCrometer Nano Board Test Procedure
لجنة الهندسة الكهربائية
Lesson 8: Analog Signal Conversion
CSCI1600: Embedded and Real Time Software
Digital Control Systems Waseem Gulsher
CSCI1600: Embedded and Real Time Software
Conversation between Analogue and Digital System
Sequential Circuits: Latches
Digital Fundamentals Floyd Chapter 1 Tenth Edition
CSCI1600: Embedded and Real Time Software
CSCI1600: Embedded and Real Time Software
CSCI1600: Embedded and Real Time Software
Chapter 7 Converters.
CSCI1600: Embedded and Real Time Software
CSCI1600: Embedded and Real Time Software
Presentation transcript:

CSCI1600: Embedded and Real Time Software Lecture 16: Input/Output II Steven Reiss, Fall 2016

Simon Game Tasks Detect buttons Initialize Reset Periodically (every 10 ms) check 3 sets of buttons Set flags indicating on for > 20 ms Initialize Based on selected game flag Set up play array play[32], play_length Set up state time, play time Reset If start is ever pressed, go back to initialization state Lecture 16: Input/Output II 5/24/2019

Simon Game Tasks Game Task Alternate between play and read Play: incr ctr, play current sequence through counter Handle illegal inputs Reset counter when done, enter read Read: incr ctr, read input for current sequence element Time out (> k sec in state) go to error Input matches  loop back Input doesn’t match  go to error ctr == length, go to play state with next element or to win state Lecture 16: Input/Output II 5/24/2019

Simon Game Tasks Win/Lose task Read sequence task Play sound task Choose sequence based on win/lose Play that sequence Afterwards go to start state Read sequence task Play sound task Lecture 16: Input/Output II 5/24/2019

Simon Tasks What do the models for these tasks look like What will the code look like The code should reflect the models The models should reflect the code Lecture 16: Input/Output II 5/24/2019

Input Management We can attach inputs to the Arduino Directly or indirectly What are the problems Sampling Latency Conditioning Range, sensitivity, noise Lecture 16: Input/Output II 5/24/2019

A simple switch You want to read the switch Can’t do it continually – you need to sample How fast should you sample? What does this depend upon? Minimum On time Minimum Off time Bouncing Lecture 16: Input/Output II 5/24/2019

Switch Input Ideal Switch Minimum inter-event sampling time Assume min on-time is 2 units Assume min off-time is 1 units What is the minimum sampling rate What is a safe sampling rate Minimum inter-event sampling time Might need to compute these values How to check min on time given sampling rate Lecture 16: Input/Output II 5/24/2019

Switch Input Real switches bounce Input takes some time to stablize Possibly 10-20 ms What happens if you sample faster than that Debouncing Sample > 50 ms Condition the inputs Check it is on/off for at least k samples Lecture 16: Input/Output II 5/24/2019

Input Issues Pull-Up Set Arduino switch mode Lecture 16: Input/Output II 5/24/2019

Sampling Actual Signals Actual signals are continuous Digital inputs are discrete Certain number of values This determines the accuracy of your input Sensors have different response curves Lecture 16: Input/Output II 5/24/2019

Actual Signals Microphone Thermistor Light Sensitive Diode Lecture 16: Input/Output II 5/24/2019

Response Curves Different devices react differently Can be linear, log, … Can saturate Lecture 16: Input/Output II 5/24/2019

Response Curves May be other Specific to the device Lecture 16: Input/Output II 5/24/2019

Sampling Changing Inputs Suppose we sample audio How fast should we sample? Need to avoid aliasing Need to be > 2 times the maximum input frequency What is audio range? What is a CD range? Lecture 16: Input/Output II 5/24/2019

Aliasing Suppose there is a high-frequency component to the input What would this show up as in low-frequency sampling? Need for a low-pass (anti-aliasing) filter Can be done in software (if you sample fast enough) Very easy to do in hardware (capacitor and resistor) Lecture 16: Input/Output II 5/24/2019

Low Pass Filter Lecture 16: Input/Output II 5/24/2019

Low Pass Filter Lecture 16: Input/Output II 5/24/2019

Analog Signals Include Noise Need to know S/N ratio Input should take this into account Lecture 16: Input/Output II 5/24/2019

Input Issues: Analog to Digital Analog signals are continuous, digital discrete Digital signal Set of bits (8, 12, …) Binary value represents the voltage level Lecture 16: Input/Output II 5/24/2019

Analog-Digital Conversion Range Highest and lowest possible values (0 ..5, -2 .. 2) Precision Number of bits (0..255, 0..1023, …) This is all you can tell apart Sampling Rate How fast the ADC can sample (it’s not immediate) Samples per second Lecture 16: Input/Output II 5/24/2019

How a ADC works Successive approximation Controller guesses next value DAC converts guess to analog value Comparator sees compares input and reference value Controller takes result and makes next guess Lecture 16: Input/Output II 5/24/2019

Analog to Digital Lecture 16: Input/Output II 5/24/2019

Input Arrays Does this work? What can go wrong Lecture 16: Input/Output II 5/24/2019

Input Array Issues First note that if no switch is pressed, noting is connected to the input ports – might get random values. Hence diagram 2 Second note what happends if switches 3,5,6 are pressed – it will look like 2,3,5,6 are all on. Hence the use of diodes as in second figure Lecture 16: Input/Output II 5/24/2019

Input Array Issues In the second case the pins serve double duty depending on their polarity. 4 pins used for 12 switches What happens with multiple switches on the first example. R1*R1/(R1+R2). What type of precision would you need on the analog input for 8 switches. What about pair-wise? Lecture 16: Input/Output II 5/24/2019

Latency Difference in time between input and corresponding output What if user pushes switch for his TTT move The machine does computation to determine its move Then it turns on both lights Would this work? Difference between setting output and actual output Motor won’t react immediately Lecture 16: Input/Output II 5/24/2019

Acceptable Latency Reaction should be << 100 ms 100 ms is noticable How is latency affected by conditioning Filtering, waiting for stability, eliminating noise How does this affect the sampling rate When latency is important Processing sound, other multimedia Detecting events (button presses, mouse movement, …) Lecture 16: Input/Output II 5/24/2019

Other I/O Issues To be covered later Communications between components Serial I/O and timing Handshaking Protocols Lecture 16: Input/Output II 5/24/2019

Homework Read Chapters 8.2 and 9 Exercises 8.3, 9.2, 9.3 Other parts of 8 might be interesting (not covered) Exercises 8.3, 9.2, 9.3 Lecture 16: Input/Output II 5/24/2019

Output Array This lecture might be short. Lecture 16: Input/Output II 5/24/2019

Output Array Alternatives First is shift register with serial input Second is latch register with parallel input Lecture 16: Input/Output II 5/24/2019

Output Issues: Glitches Intermediate values Output glitches Arduino library minimizes these Lecture 16: Input/Output II 5/24/2019