Date post: | 17-May-2015 |
Category: |
Engineering |
Upload: | ahmed-magdy-farid |
View: | 354 times |
Download: | 2 times |
ABOUT THE SPEAKER: AHMED FARID
• MSA CSE Graduate • IBM Application Developer • CU SSTLab Engineer • IEEE EED Best CE Project
Awardee • Presenter @ 5th NanoSat
Symposium in Japan • Trainee in Vodafone Egypt &
BWNGO
WHAT ARE SYSTEMS?
WHAT ARE SYSTEMS?
• Basic definition: A set of components/tools working together as a whole, taking inputs and providing outputs.
System Inputs Outputs
WHAT ARE COMPUTING SYSTEMS?
WHAT ARE COMPUTING SYSTEMS?
• I/O are basically data • Responsible for predefined flow of calculations (Hardwired/
Program) • Usually low electrical currents
Calculator Input Data Output Data
Examples: • 2+2=? • Celsius to Fahrenheit
LOGIC GATES
• Hardware representation of logical operations: AND, OR, NOT, and more.
• Building blocks of modern computer system designs.
Design for computer chips
PROCESSORS
• Systems that do arithmetic, logical, and memory allocation operations.
• Reads sequential instructions (Program) from a memory space (ROM), and executes at a given speed (Hz).
• Center of all complex computational hardware: • Desktop/Laptops • Smartphones • Servers • Embedded Systems
MICROCONTROLLERS
• Small programmable ICs, already containing a processor.
• Used as the computational part of embedded systems. (Ex: Home Alarm System)
• Usually low cost and low current usage (mili-ampere range).
• Usually programmed in C or assembly.
• Known brands: • Atmel (Atmega, Attiny …etc.) • Microchip (PIC12, PIC16, PIC24 …etc.) • Texas Instruments • Siemens • NXP • Others
WHAT IS ARDUINO?
WHAT IS ARDUINO?
• It is a rapid prototyping platform for embedded systems.
• It is in the form of software (IDE, chip firmware) and development boards.
• Most of their development boards are based on Atmel microcontrollers.
• Programming language is C++. (Giving OO capabilities)
• There are several boards of different sizes and applications.
Visit arduino.cc for more.
WE HAVE…
• Arduino Uno • USB Cable • Laptop with Arduino IDE • Breadboard • Components: • R,G,B LEDs • 1 K Ohm Resistors • LM35 Temperature Sensor • Speakers • Lots of wires
LET’S CONNECT OUR STUFF
1. Take a copy of Arduino IDE. (http://arduino.cc/en/main/software)
2. Connect your Arduino Uno via USB.
3. If you are using Windows, follow the driver installation guide. (http://arduino.cc/en/guide/windows#toc4 - http://mytechblog.com/tutorials/arduino/install-arduino-drivers-on-windows-8/)
4. Open the Arduino program
ARDUINO USES C++
• Let’s make a simple hello world, compile (√ icon) and see what happens:
• We notice that things won’t work. Open File > Examples > Basics > Blink
• Upload the code (-> Icon) to your arduino uno (Make sure of serial port and selected board in tools menu)
#include<iostream.h>!!void main(){!
!cout<<"Hello Arduino";!}!
ARDUINO SAMPLE CODE: BLINK
• We notice there isn’t a main function, but setup and loop.
• Input/Output are defined and operated through pinMode and digitalWrite.
• 13 is the pin number on the Arduino board.
int led = 13;!!// the setup routine runs once when you press reset:!void setup() { ! // initialize the digital pin as an output.! pinMode(led, OUTPUT); !}!!// the loop routine runs over and over again forever:!void loop() {! digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)! delay(1000); // wait for a second! digitalWrite(led, LOW); // turn the LED off by making the voltage LOW! delay(1000); // wait for a second!}!
ARDUINO APPLICATION LIFECYCLE
void setup() void loop()
Runs only for one time • We initialize system here
Runs forever in a loop • Like while(true) • All of our logic resides here
COMMUNICATIONS: SERIAL UART • Easiest communications technique for
Arduino. • Can be done over USB connection with the
computer.
• Send and receive functionality in the form of bytes (Or char).
• Easy to code (Needs to set transmission speed).
• There are other communication types in microcontrollers in general: • SPI • I2C • CAN
Transmission Speed
SERIAL CODE
void setup() { !
!Serial.begin(9600); !
}!
void loop() {!
!!
!char c = Serial.read();!
!if(c == 'a')!
! !Serial.println("Hello!");!
}!
Also check out: • Serial.readString() [http://arduino.cc/en/Reference/StreamReadString] • Serial.available() [http://arduino.cc/en/Serial/available]
DIGITAL I/O: RGB LIGHTING
RGB LIGHTING CODE
void loop() {!
!digitalWrite(red, HIGH);!
!delay(1000);!
!digitalWrite(red, LOW);!
!digitalWrite(blue, HIGH);!
!delay(1000);!
!digitalWrite(blue, LOW);!
!digitalWrite(green, HIGH);!
!delay(1000);!
!digitalWrite(green, LOW);!
}!
int red = 13;!
int blue = 12;!
int green = 11;!
!
void setup() { !
!pinMode(red, OUTPUT);!
!pinMode(blue, OUTPUT);!
!pinMode(green, OUTPUT); !
}!
ANALOG INPUT: TEMPERATURE READING
A LITTLE STORY ABOUT SIGNALS
A,B,C,… Z,1,2… 01100010011... 0v,5v,5v,0v,0v…
What computers display
What software see
What hardware see
Digital Signal Zeros and ones
Analog Signal Values between 0 volt and 5 volts
A LITTLE STORY ABOUT DATA
• Analog information is digitized depending on the reading accuracy.
• For example, Atmega328’s A/D converter has an 10-bit accuracy.
• 210 = 1024 values [0 -> 1023]
• If we are reading a voltage value between 0 and 5, we’d use the following relation:
• In case of Arduino’s analogRead() giving us 555, voltage will be ~2.71 volts
• Is this relation enough for LM35’s temperature reading? (Think)
Read more here: http://playground.arduino.cc/Main/LM35HigherResolution
TEMPERATURE READING CODE
int tmp = A5;!
!
void setup() { !
Serial.begin(9600); !
}!
!
void loop() {!
!float reading = analogRead(tmp);!
!reading = (reading*5.0*100.0)/1023.0;!
!Serial.println(reading);!
}!
Read more here: http://playground.arduino.cc/Main/LM35HigherResolution
No pinMode required!
ANALOG OUT/PWM: SPEAKERS
SPEAKER CODE int aud = 11;!
!
void setup() { !
}!
!
void loop() {!
!for(int i = 0 ; i < 256 ; i++){!
! !analogWrite(aud,i);!
!delay(10);!
!}!
}!
No pinMode required!
Same signal conversion story as analog input. Only this time its output and of 8-bit accuracy.
Read more here: http://arduino.cc/en/Tutorial/tone http://www.youtube.com/watch?v=YmPziPfaByw
• Put all the components together.
• Be creative in your implementation.
• Presentation at the end.
WHAT’S NEXT?
• Learn more about microcontrollers and alternatives. • Never do a short circuit. Look and connect carefully! • Research before you build. • Understand a system, rather than copy-pasting circuit
diagrams. • Pay attention to electronics, digital, and programming
courses!
• Have fun!
Ahmed Farid [email protected]