CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall...
-
Upload
jayson-shaw -
Category
Documents
-
view
218 -
download
0
Transcript of CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall...
![Page 1: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/1.jpg)
CSCI1600: Embedded and Real Time SoftwareLecture 4: Introduction to the Arduino
Steven Reiss, Fall 2015
![Page 2: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/2.jpg)
What is an Arduino
![Page 3: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/3.jpg)
Arduino Chip: ATmega48
![Page 4: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/4.jpg)
Arduino CPU
![Page 5: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/5.jpg)
Embedded Processors Arduino: a microcontroller
Others exist as well
General purpose processors ARM processor (low power)
Raspberry Pi
Special purpose processors DSP for sound, video processing
Graphics processors
![Page 6: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/6.jpg)
Other alternatives Field-Programmable Gate Arrays
Less expensive than creating chip
Like having a bucket of parts to wire together Except the wiring is done programmatically
And the whole thing fits on a chip
Easy and cheap to make in quantity
Programmed in a high-level language
![Page 7: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/7.jpg)
Arduino Restrictions
Simple CPUSingle core, single threaded
No pipelining
No floating point processorHow is floating point done
![Page 8: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/8.jpg)
What you need to knowPower/USB InputGround and power outputsDigital input/outputsAnalog input/outputsReset button
![Page 9: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/9.jpg)
Clapper
Two circuitsOne to provide input
Analog based on sound intensity
One to provide outputTwo lights
Digital (on or off)
![Page 10: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/10.jpg)
Clapper Input Circuit
![Page 11: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/11.jpg)
How does this workMicrophone generates a weak signal
https://www.jameco.com/Jameco/Products/ProdDS/136574.pdf
LM386 is an amplifier chipAmount controlled by resistor, capacitor
http://www.ti.com/lit/ds/symlink/lm386.pdf
Output balanced between 0 and 5 volts
![Page 12: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/12.jpg)
Output circuit
Connect Digital Output Pin to LEDThrough a resistor (why)
Other side of LED is grounded
![Page 13: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/13.jpg)
How should the clapper work?Read the input
How often
Check if we have a clapWhat does a clap look like
How would you find out
Check if we have a clap sequence
![Page 14: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/14.jpg)
Clapper requirements
Turn lights on or offBased on clap input
Handle flashing lightsHow often to check
![Page 15: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/15.jpg)
Tasks The basic concept in RT/EM software
Break your project into tasks
Tasks are independent Communicate via shared variables
Communicate via network, etc.
Tasks are run periodically or on demand Periodic – run every k microseconds
Demand – run on event, interrupt
![Page 16: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/16.jpg)
Clapper Tasks
Listen for soundHandle clapper logicHandle first lightHandle second light
![Page 17: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/17.jpg)
Clapper Stateclap_count (# claps)clap_done (clap interval over) last_clap (whether clap has ended)do_clap (take action based on clap)cur_state (state of lights)orig_state (state at start of all claps)
![Page 18: CSCI1600: Embedded and Real Time Software Lecture 4: Introduction to the Arduino Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062409/5697bf921a28abf838c8f20b/html5/thumbnails/18.jpg)
Homework
https://www.arduino.cc/en/Tutorial/HomePage
Think about what the code should look like logically