Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI1600: Embedded and Real Time Software Lecture 14: Input/Output II Steven Reiss, Fall 2015.

Similar presentations


Presentation on theme: "CSCI1600: Embedded and Real Time Software Lecture 14: Input/Output II Steven Reiss, Fall 2015."— Presentation transcript:

1 CSCI1600: Embedded and Real Time Software Lecture 14: Input/Output II Steven Reiss, Fall 2015

2 Input Management  We can attach inputs to the Arduino  Directly or indirectly  What are the problems  Sampling  Latency  Conditioning  Range, sensitivity, noise

3 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

4 Switch Input  Ideal Switch  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

5 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

6 Input Issues  Pull-Up  Set Arduino switch mode

7 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

8 Response Curves  Different devices react differently  Can be linear, log, …  Can saturate

9 Response Curves  May be other  Specific to the device

10 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?

11 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)

12 Low Pass Filter

13 Analog Signals  Include Noise  Need to know S/N ratio  Input should take this into account

14 Input Issues: Analog to Digital  Analog signals are continuous, digital discrete  Digital signal  Set of bits (8, 12, …)  Binary value represents the voltage level

15 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 (its not immediate)  Samples per second

16 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

17 Analog to Digital

18 Input Arrays  Does this work?  What can go wrong

19 Input Array Issues

20

21 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

22 Acceptable Latency  Reaction should be << 100 ms  100 ms is noticable  How is latency affected by conditioning  How does this affect the sampling rate

23 Output Array

24 Output Array Alternatives

25 Output Issues: Glitches  Intermediate values  Output glitches  Arduino library minimizes these

26 Homework (for Wednesday)  Read Chapters 8 and 9  Hardware issues are for your enlightenment  We will concentrate on the programming issues


Download ppt "CSCI1600: Embedded and Real Time Software Lecture 14: Input/Output II Steven Reiss, Fall 2015."

Similar presentations


Ads by Google