Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
CCD
lens
Upgraded Technology
Surface Mount Device (SMD)
Ball Grid Array (BGA)
Microcontrollers
Microcontrollers can be used to build projects directly,
but often packaged with other components onto a PCB
to make them easier to use for beginners and for rapid
prototyping.
Power
Performance Size
NRE cost
Design Metrics
Time required to develop a product to the point it can be sold
to customers
Market window
Period during which the product would have highest sales
Average time-to-market constraint is about 8 months
Delays can be costly
Revenues ($)
Time (months)
Revenue Models
Simplified revenue model
Product life = 2W, peak at W
Time of market entry defines a triangle, representing market
penetration
Triangle area equals revenue
Loss
The difference between the on-time and delayed triangle areas
Peak revenue
delayed entry
On-time
Market rise Market fall
Delayed
D W 2W
On-time Delayed Time
entry entry
Losses due to delayed market entry
Area = 1/2 * base * height
On-time = 1/2 * 2W * W
Delayed = 1/2 * (W-D+W)*(W-D)
Percentage revenue loss = (D(3W-D)/2W2)*100%
Lifetime 2W=52 wks, delay D=4 wks
(4*(3*26 4)/2*26^2) = 22%
Lifetime 2W=52 wks, delay D=10 wks
(10*(3*26 10)/2*26^2) = 50%
Delays are costly! Peak revenue
Delayed
D W 2W
On-time Delayed Time
entry entry
NRE(Non Recurring Engineering costs)
Costs:
Unit cost: the monetary cost of manufacturing each copy of the system,
excluding NRE cost
NRE cost (Non-Recurring Engineering cost): The one-time monetary cost of
designing the system
total cost = NRE cost + unit cost * # of units
per-product cost = total cost / # of units
= (NRE cost / # of units) + unit cost
Example
NRE=$2000, unit=$100
For 10 units
total cost = $2000 + 10*$100 = $3000
per-product cost = $2000/10 + $100 = $300
p e r p ro d uc t c o st
$120,000 $120
$80,000 $80
$40,000 $40
$0 $0
0 800 1600 2400 0 800 1600 2400
Number of units (volume) Number of units (volume)
Performance design
Widely-used measure of system, widely-abused
frequency, instructions per second not good measures
Digital camera example a user cares about how fast it
processes images, not clock speed or instructions per second
Latency (response time)
Time between task start Clock and end
e.g., Cameras A and B process images in 0.25 seconds
Throughput
Tasks per second, e.g. Camera A processes 4 images
per second
Throughput can be more than latency seems to imply
due to concurrency, e.g. Camera B may process 8
images per second (by capturing a new image while
previous image is being stored).
Speedup of B over S = Bs performance / As performance
Throughput speedup = 8/4 = 2
Embedded System Technologies
Technology
A manner of accomplishing a task, especially using
technical processes, methods, or knowledge
Three key technologies for embedded systems
Processor technology
IC technology
Design technology
Arduino
Worlds First Open Source
Embedded Platform.....
Arduino Board
An Arduino development board consists of
8 bit microcontroller
Programming hardware
USB programming interface
I/O Pins
Arduino Board
Arduino Board
Arduino board has a software environment, an
IDE which is an integrated development
environment.
It is having
Cross-compiler
Debugger
Simulator
Programmer
Arduino Environment
You write the code in IDE.
And you don't have to use the Arduino IDE to
write code .
You could program an Arduino using eclipse or
some other IDE
Arduino IDE is easier to handle.
Arduino Shields
Arduino environment has different shields
They are
Special purpose boards
With unique functionalities
Easy to attach
Good libraries provided
Arduino board is an open source board
You can modify the board schematic and design
your own board.
As its expensive to do that, buy a pre-made
board.
Execution
The two types of code executing on a
microcontroller is the
1) Application Code
This executes systems main functionality
And we write this code
2) Firmware
Its a low level code written to support the main
functionality
And that is the USB interface code in
ATMega16u2, Power modes, reset etc.
Bootloader
The bootloader is a
Firmware on a microcontroller
Allows the flash and EEPROM to be
programmed
Manages USB communication, since
application programming is via USB.
The bootloader cannot be updated through
USB interface.
In-Circuit Serial Programming (ICSP) is used to
update bootloader by using the special pins
on the board.
Arduino Board
The board got two ICSP ports for ATmega328,
and ATmega16U2
One ICSP header near the ATmega16U2.
And theres another ICSP header for the
ATmega328.
Prerequisites
Familiar with the basics of C Language &
Object Oriented programming languages.
Arduino Uno R3
Arduino Uno R3 SMD
Red Board
Arduino Pro 3.3v/8 MHz
Arduino Pro 5V/16MHz
Arduino mini 05
Arduino Pro mini 3.3v/8mhz
Arduino Pro mini 5v/16mhz
Arduino Ethernet
Arduino Fio
Types of Boards
Boards Based on ATMEGA32u4 microcontroller
LilyPad Arduino 328 main board
LilyPad Arduino simply board
Duemilanove
Nano
Diecimila
Types of Boards
Boards based on ATMEGA2560 microcontroller
Arduino Mega 2560 R3
Mega Pro 3.3V
Mega Pro 5V
Mega Pro Mini 3.3V
Boards based on AT91SAM3X8E microcontroller
Arduino Mega 2560 R3
Arduino UNO board
Pins on Arduino Board
Pin 1. Power USB :
Arduino board can be powered by using the USB cable from your
computer.
All you need to do is connect the USB cable to the USB connection.
Materials needed
Arduino-compatible board ex: Arduino UNO
USB cable A to B
2 - LEDs
2 - 330 resistors
A mini breadboard
5 - Jumper wires
Connecting the Arduino
The computer should say that your Arduino UNO (USB) has been
successfully installed on COM port (xx). Here xx refers to a single or
double digit number.
If this message didn't pop up, go back to the Device Manager and
check if it has been installed under COM ports.
Arduino IDE
The Arduino software, commonly referred to
as the Arduino IDE (Integrated Development
Environment)
The IDE for Windows, Mac OS, and Linux is
almost identical.
When you use Arduino IDE package your
sketches must follow a specific coding format.
Arduino Sketches
The Arudino sketches dont have a main
function in the code.
Setup()
Loop()
void setup()
{
serial.begin(9600);
serial.println("Hello World!");
}
void loop()
{
}
Output
Click on the Serial Monitor button on the right
side
Switch the baud rate on the Serial Monitor
window to 9600.
You should see your message Hello World!
waiting for you there.
LED Sketch
Go to File Examples Basics Blink
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
}
Double LED Blink
Sketch
int led1 = 12;
int led2 = 13;
void setup()
{
// initialize the digital pins as an output.
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
// turn off LEDs before loop begins
digitalWrite(led1, LOW); // turn the LED off (LOW is the voltage level)
digitalWrite(led2, LOW); // turn the LED off (LOW is the voltage level)
}
//the loop routine runs over and over again forever:
void loop()
{
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(led2, LOW); // turn the LED off (LOW is the voltage level)
delay(1000); // wait for a second
digitalWrite(led1, LOW); // turn the LED off (LOW is the voltage level)
digitalWrite(led2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
}
Structure OF Arduino sketch
Boolean
A Boolean holds one of two values, true or false.
Each Boolean variable occupies one byte of memory.
Unsigned
Data type that occupies one byte of memory.
The unsigned char data type encodes numbers from 0
to 255.
Unsigned Char chrQ = 121 ;
Byte
stores an 8-bit unsigned number, from 0 to 255
byte m = 25 ;
int
Primary data-type for number storage.
int stores a 16-bit (2-byte) value. This yields a
range of -32,768 to 32,767
int counter = 32 ;
Data Types
Unsigned int
same as int data type.
They only store positive values.
Yielding a range of 0 to 65,535 ((2^16) - 1)
The Due stores a 4 byte (32-bit) value, ranging
from 0 to 4,294,967,295 (2^32 - 1)
i.e 2 N 1 where N = 16 or 32 bits
Data Types
Word
On the Uno and other ATMEGA based boards,
word stores a 16-bit unsigned number.
On the Due and Zero,
it stores a 32-bit unsigned number
word w = 1000 ;
Data Types
long
Long variables are extended size variables Store
32 bits (4 bytes) from 2,147,483,648 to
2,147,483,647
long velocity = 102346 ;
Unsigned Long
store 32 bits (4 bytes).
will not store negative numbers
Their range is 0 to 4,294,967,295 (2^32 - 1)
Ex : unsigned Long velocity = 101006 ;
Data Types
short
A 16-bit data-type.
On ATMega and ARM based a short stores a
16-bit (2-byte) value.
yields a range of -32,768 to 32,767
EX : short val = 13 ;
Data Types
float
Floating-point numbers are often used to
approximate the analog and continuous
values
They are stored as 32 bits (4 bytes)
Can be as large as 3.4028235E+38 and as low
as 3.4028235E+38
ex : float num = 1.352;
Data Types
Double
On the Uno and other ATMEGA based boards,
Double floating-point number occupies four
bytes.
On the Arduino Due, double have 8-byte
(64 bit) precision.
ex: double num = 45.352 ;
Scope of a Variable
A scope is a region of the program and there
are three places where variables can be
declared.
Inside a function or a block, which is
called local variables
Outside of all functions, which is called global
variables
In the definition of function parameters,
which is called formal parameters
Operators
An operator is a symbol that tells to perform
specific mathematical or logical functions.
Types of operators
Arithmetic Operators
Comparison Operators
Boolean Operators
Bitwise Operators
Compound Operators
Arithmetic Operators
A and B are variables
= A=B
+ A+B
- A-B
* A*B
/ A/B
% A%B
Comparison Operators
A and B are variables
== (A == B) is not true
!= (A != B) is true
< (A < B) is true
> (A > B) is true
<= (A <= B) is less than or equal to
>= (A >= B) is greater than or equal to
Boolean Operators
}
Arrays
Declaration
type arrayName [ arraySize ] ;
Reserves the appropriate amount of memory
To reserve 11 elements for integer array
- int c[12] ; c is an array of 12 integers
- int n[10]; n is an array of 10 integers
Array example
int n[ 7 ] ; // n is an array of 10 integers
void setup ()
{
}
void loop ()
{
for ( int i = 0; i < 7; ++i ) // initialize of array n to 0
{
n[ i ] = 0; // set element at location i to 0
serial.print (i) ;
serial.print (\r) ;
}
for ( int j = 0; j < 7; ++j ) // output each array value
{
serial.print (n[j]) ;
serial.print (\r) ;
}
}
Output
Element Value
0 0
1 0
2 0
3 0
4 0
5 0
6 0
Measurements
Sensors
accelerometers
pressure sensors
light sensors
sound sensors
temperature sensors
Sensors
Flame Sensor
int Buzzer = 13; // Use buzzer for alert
int FlamePin = 2; // This is for input pin
int Flame = HIGH; // HIGH when FLAME Exposed
void setup()
{
pinMode(Buzzer, OUTPUT);
pinMode(FlamePin, INPUT);
Serial.begin(9600);
}
void loop() {
Flame = digitalRead(FlamePin);
if (Flame== HIGH)
{
Serial.println("HIGH FLAME");
digitalWrite(Buzzer, HIGH);
}
else
{
Serial.println("No flame");
digitalWrite(Buzzer, LOW);
}
}
Sensors
Sensors
Humidity Sensor - DHT-22
It is a digital-output, relative humidity, and
temperature sensor.
It uses a capacitive humidity sensor and a
thermistor to measure the surrounding air,
and sends a digital signal on the data pin.
Humidity Sensor
Humidity Sensor
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
// Connect pin 2 of the sensor to whatever your
DHTPIN is
// Connect pin 4 (on the right) of the sensor to
GROUND
// Connect a 10K resistor from pin 2 (data) to pin
1 (power) of the sensor
// Initialize DHT sensor.
Humdity Sensor
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
Serial.println("DHTxx test!");
dht.begin();
}
void loop()
{
delay(2000); // Wait a few seconds between measurements
float h = dht.readHumidity();
// Reading temp or humidity takes about 250 msec
float t = dht.readTemperature();
// Read temperature as Celsius
float f = dht.readTemperature(true);
// Read temperature as Fahrenheit (isFahrenheit =
true)
// Check if any reads failed and exit early (to try
again).
if (isnan(h) || isnan(t) || isnan(f))
{
Serial.println("Failed to read from DHT sensor!");
return;
}
Humidty Sensor
// Compute heat index in Fahrenheit (the default)
Logic HIGH at RS pin selects data register and logic LOW at RS pin
selects command register.
If RS pin HIGH and feed an input to the data lines (DB0 to DB7), this
input will be treated as data to display on LCD screen.
If RS pin LOW and feed an input to the data lines, then this will be
treated as a command (a command to be written to LCD controller
like positioning cursor or clear screen or scroll)
Pins of LCD
Pin5(R/W) : Read/Write modes.
This pin is used for selecting between read and
write modes.
Logic HIGH at this pin activates read mode and
Logic LOW at this pin activates write mode.
LCD module and Arduino are interfaced in the 4-bit mode. This means only four of
the digital input lines( DB4 to DB7) of the LCD are used.
Digital lines DB4, DB5, DB6 and DB7 are interfaced to digital pins 5, 4, 3 and 2 of
the Arduino.
The 10K potentiometer is used for adjusting the contrast of the display. 560 ohm
resistor R1 limits the current through the back light LED.
The Arduino can be powered through the external power jack provided on the
board.
+5V required in some other parts of the circuit can be tapped from the 5V source
on the Arduino board. The Arduino can be also powered from the PC through the
USB port.
Interfacing LCD
#include<LiquidCrystal.h>
void setup()
{
lcd.begin(16, 2); // initializes the 16x2 LCD
}
void loop()
{
lcd.setCursor(0,0); //sets the cursor at row 0 column 0
lcd.print("16x2 LCD MODULE"); // prints 16x2 LCD MODULE
lcd.setCursor(2,1); //sets the cursor at row 1 column 2
lcd.print(United Engineers"); // prints United Engineers
}
Wireless Communication
Wireless is a form of communication or transmission
of information over a distance without requiring wires,
cables or any other electrical conductors.
void setup()
{
Serial.begin(115200);
delay(10);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW); // Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500); Serial.print(".");
}
Arduino sketch
Serial.println("");
Serial.println("WiFi connected"); // Start the server
server.begin();
Serial.println("Server started"); // Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void loop()
{
// Check if a client has connected
WiFiClient client = server.available();
if (!client)
{
return;
}
// Wait until the client sends some data
Arduino sketch
Serial.println("new client");
while(!client.available())
{
delay(1);
}
// Read the first line of the request
byte byteRead;
void setup()
{
Serial.begin(9600); // Turn the Serial Protocol ON
}
void loop()
{
if (Serial.available()) /* check if data has been sent from the computer: */
{
/* read the most recent byte */
byteRead = Serial.read();
/*ECHO the value that was read, back to the serial port. */
Serial.write(byteRead);
}
}
Servo Motors
Special types of applications of electrical motors
where rotation of the motor is for a certain angle
but not continuously for long period of time.
A servo motor is a rotary actuator that allows for
precise control of angular position and has a
motor coupled to a sensor for position feedback.
It Requires a servo drive to complete the system.
Servo Motors are recommended for high-speed
(greater than 2,000 RPM) and high torque
applications requiring dynamic load changes.
Applications
Robotics
Conveyor Belts
Camera Auto Focus
Solar Tracking System
Metal Cutting & Metal Forming Machines
Antenna Positioning
Woodworking/CNC
Textiles-Spinning and Weaving
Printing Presses/Printers
Automatic Door Openers
Arduino with Servo motor
Servo motors have 3 connections
Black/Brown ground wire
Red wire (5V)
Yellow or White PWM wire.
Connect
the power and ground pins directly to the Arduino
5V and GND pins.
PWM input will be connected to Arduino's digital
output pin.
Arudino Servo
Write the sketch in Arudino IDE and Upload
#include <servo.h>
Servo servoMain; //initialize a servo object for the servo
int angle = 0;
void setup()
{
servoMain.attach(9);
// attach signal pin of servo to pin9 of Arduino
}
void loop()
{
for(angle = 0; angle < 180; angle += 1)
// command to move from 0 degrees to 180 degrees
{
servoMain.write(angle);
//command to rotate the servo to the specified angle delay(15);
}
Arudino Servo
delay(1000);
for(angle = 180; angle>=1; angle-=5)
// command to move from 180 degrees to 0 degrees
{
servo_test.write(angle);
//command to rotate the servo to the specified
angle delay(5);
}
delay(1000);
}
Stepper Motors
Stepper motors are DC motors that move in
discrete steps.
They have multiple coils that are organized in
groups called "phases". By energizing each
phase in sequence, the motor will rotate,
one step at a time.
They are either bipolar, requiring two power
sources or a switchable polarity power source,
or uni-polar, requiring only one power source.
The Stepper Motors are manufactured with
steps per revolution of 12, 24, 72, 144, 180,
and 200.
Resulting in stepping angles of 30, 15, 5, 2.5,
2, and 1.8 degrees per step.
The stepper motor can be controlled with or
without feedback.
Stepper Motors are commonly recommended
for applications that are cost-sensitive and low
maintenance.
Stepper Motor
Stepper Motor Control
#include <Stepper.h>
const int stepsPerRevolution = 90;
// change this to fit the number of steps per
//revolution for your motor. Initialize the stepper library
//on pins 8 through 11