Sie sind auf Seite 1von 80

Open source software and

hardware
Pritish M. Vibhute
Open source
• Why to use open source?
• We’d like to minimize our investment in time required
for this task.
• After all, we usually are not paid based on how well we
understand every hardware detail of a given processor, but
rather on our ability to deliver a working solution in a
timely manner.
• Indeed, this is one of the primary reasons open source has
flourished.
• Open Source Hardware
Introduction to...

Arduino Board
-Mr. Pritish M. Vibhute
Content of course
• Introduction to Arduino Board
– Concept of prototyping & Open source boards
• Different types of Arduino Board
• IDE:- Who to download, install and procedure
• Procedure to write & execute program
• Sample projects!
• Upload program to Arduino Uno
• Demonstration of different programs
Course Structure
• Session 1(TH 2Hrs): Introduction to the concept of • Session 5(PR 2Hrs): Implementation of simple
– Open source hardware projects
– Prototyping board • Calculator
– Arduino and it types • Simple Audio Player
– Shields • Line Follower and different type of Robots
• Session 2 (TH + PR 2Hrs): Introduction to IDE and • Session 6(PR 2Hrs): Introduction to the concept
programming of IOT & its implementation
• Introduction to IDE and programming style / Language • Concept of IOT
• Implementation of simple problem statement • Opportunities in IOT
• Session 3(PR 2Hrs): Interfacing with hardware • Uploading Sensor parameter on internet and
(Simple) monitoring using cloud based services
• Interfacing LED • Session 7(TH 2 Hrs): Alternatives to Arduino
• Interfacing LDR and their capabilities
• Interfacing LM35 Temperature Sensor • Raspberry Pi
• Interfacing Ultrasonic Sensor • Beaglebone Black
• Interfacing PIR Motion Sensor • Intel Galileo
• Interfacing on board peripherals • TI LaunchPad
• Session 4(PR 2Hrs): Interfacing with hardware • Panda Board
(Complex) • Session 8(PR 2 Hrs): Exploring capabilities of
• Interfacing GSM module Raspberry Pi 2 B+
• Interfacing GPS module • Introduction to Raspberry Pi
• Interfacing ZigBee module • Raspberry Pi 2 B+ as a single board computer
• Interfacing Keypad • Introduction to OS supported by Raspberry Pi-
• Interfacing RF module Raspbian, Noobs, Windows 10 IOT
• Interfacing LCD 16 X 2 • Applications of Raspberry Pi
Prerequisites : Microcontroller
•It is a micro-computer(small).
•As any computer it has internal
CPU, RAM, IOs interface etc.
•It is used for control purposes,
and for data analysis.
•One who executes program

•Famous microcontroller
manufacturers are
MicroChip, Atmel, Intel,
Analog devices, and more.
Prerequisites : Microprocessor

•Big brother of Microcontroller with less


number of on chip peripheral

•The line is blurring between these two.


•Eg:-
•Pentium
•i-series
•AMD
Arduino
1. Simple microcontroller based board
2. A development environment (IDE) for writing
software for the board
• “Strong Friend” (Massimo Banzi & David Cuartielles )
Created it at Ivrea, Italy in 2005
• Advantages:-
– Inexpensive
• Bought less than $50.00
• Assemble your own
– Cross Platform IDE
– Large Community
– Open Source IDE & extension
Open Source
• Open Source Hardware
• Open Source Bootloader
• Open Source Development Kit(IDE)
• Community Driven Support
What is Arduino?
• Arduino is an open-source Atmel microcontroller based
electronics prototyping platform based on flexible, easy-
to-use hardware and software. It's intended for artists,
designers, hobbyists, and anyone interested in creating
interactive objects or environments.
• It simplify the process of creating any control system by
Arduino.

providing the standard board that can be programmed and


connected to the system without the need to any sophisticated
PCB design and implementation.
• Hardware Abstracted Wiring Language. Simplified C++
• USB powered and programmable through PC
•Many different versions
•Number of input/output channels
•Form factor
•Processor
Arduino boards: •14 current boards

UNO Mega LilyPad

Arduino BT Arduino Nano Arduino Mini


More Boards
Compatible Boards
Shields
• Shields are circuit
boards that plug into
the top of an Arduino.
GPS Module
• They extend the
capabilities of an
Arduino.
• shieldlist.org

Bluetooth
Module
Shields

LCD
Shields
Shields
Temperature &
Humidity Sensor

RFID Module
Wave Shield

Touchscreen
Shield
More Shields…

XBee Shield Datalogging Shield

Ethernet Shield Wifi Shield


And more shields…
Micro SD
MP3 Trigger
Even more shields!

Trackduino

APRS Shield
Arduino Shields usage procedure
PCB Built Shield Inserted Shield
Arduino Uno
SCL\SDA
(I2C Bus)
& PWM(3, 5, 6, 9, 10, 11)
Arduino Board Overview
Specifications: Arduino Uno
• Microcontroller: ATmega 328(8 BIT)
• RISC @ 16 Mhz, 20 MIPS
• Operating Voltage 5V(regulated Voltage)
• Input Voltage (recommended) 7-12V
• Input Voltage (limits) 6-20V
• Digital I/O Pins 14 (6 -PWM output)
• Analog Input Pins 6 Channels (10 Bit resolution)
• DC Current per I/O Pin 40 mA
• DC Current for 3.3V Pin 50 mA
• Flash Memory 32 KB (0.5 KB used bootloader)
• SRAM 2 KB (ATmega328)
• EEPROM 1 KB (ATmega328)
• Clock Speed 16 MHz
• PWM, I2C, SPI
Specifications: Arduino Mega

• Physically larger than all the other boards


• More digital and analog pins.

• Microcontroller: ATmega1280
• Operating Voltage 5V
• Input Voltage: 7-12V
• Digital I/O Pins 54 (of which 14 provide PWM output)
• Analog Input Pins 16
• Flash Memory 128 KB (4 KB used by bootloader)
• SRAM 8 KB
• EEPROM 4 KB
• Clock Speed 16 MHZ
Getting Started
1. Download & install the Arduino environment (IDE)
http://arduino.cc/en/Main/Software
2. Connect the board to your computer via the USB cable
3. If needed, install the drivers
4. Launch the Arduino IDE
5. Select your board
6. Select your serial port
7. Open the blink example
8. Upload the program
Arduino IDE
Select Serial Port and Board
Input Output:- Digital or Analog
Digital and analog.
• All physical quantities are analog.
• Analog means that the quantity can take any value between its minimum
value and maximum value(Eg:- temperature, sine wave)
• Digital means that the quantity can take specific levels of values with specific
offset between each other(like true of false, square wave).
Digital Input/Output

1
• Digital IO is binary
valued—it’s either on or
0
off, 1 or 0
• Internally, all
microprocessors are
digital, why?
Data Types and operators

• Integer: used with integer variables with value between


2147483647 and -2147483647. Ex: int x=1200;
• Character: used with single character, represent value from
-127 to 128. Ex. char c=‘r’;
• Long: Long variables are extended size variables for
number storage, and store 32 bits (4 bytes), from -
2,147,483,648 to 2,147,483,647.
• Floating-point numbers can be as large as 3.4028235E+38
and as low as -3.4028235E+38. They are stored as 32 bits (4
bytes) of information. Ex. float num=1.291;
[The same as double type]
• We hope you already know about Array, Boolean, byte, etc
Statement and operators

• Statement represents a command, which ends with ;


– eg: int x; x=13;
• Operators are symbols that used to indicate a specific function:
– Math operators: [+,-,*,/,%,^]
– Logic operators: [==, !=, &&, ||]
– Comparison operators: [==, >, <, !=, <=, >=]
• Syntax/Components:
– ; Semicolon, {} curly braces, //single line comment, /*Multi-line
comments*/
• Compound Operators:
• ++ (increment) -- (decrement) += (compound addition)
• -= (compound subtraction) *= (compound multiplication)
• /= (compound division)
Control statements
If Conditioning: Switch case:
if(condition) switch (var) {
{ case 1:
statements-1; //operation when var equals 1
break;

case 2:
Statement-N;
//Operation when var equals 2
} break;
else if(condition2) default:
{ // if not match do the default
Statements; // default is optional
} }
Else{statements;}
Loop statements
Do… while: While:
do While(condition)
{ {statements;}
Statements; for
} for (int i=0; i <= val;
while(condition); // the i++){
statements are run at least statements;
once. }

Use break statement to stop the loop whenever needed.


Code structure

• What is a Sketch?
• What is libraries
• Void setup(){}
• Used to indicate the initial values of
system on starting.
• Void loop(){}
• Contains the statements that will run
whenever the system is powered after
setup.

• Online IDE:- https://codebender.cc


Sketches

Includes

Globals

void setup()
void loop()
Arduino Digital
I/0

pinMode(pin, mode)
Sets pin to either INPUT or OUTPUT
digitalRead(pin)
Reads HIGH or LOW from a pin
digitalWrite(pin, value)
Writes HIGH or LOW to a pin
Electronic stuff
Output pins can provide 40 mA of current
Writing HIGH to an input pin installs a 20KΩ pullup
eg1:- Blink an LED
eg2: Digital IO

• Use a push-button to turn ON/Off LED


Analog Input
• Think about music stored on a CD---an analog
signal captured on digital media
– Sample rate
– Word length
Arduino Analog Input
• Resolution: the number of different voltage levels (i.e.,
states) used to discretize an input signal
• Resolution values range from 256 states (8 bits) to
4,294,967,296 states (32 bits)
• The Arduino uses 1024 states (10 bits)
• Smallest measurable voltage change is 5V/1024 or 4.8 mV
• Maximum sample rate is 10,000 times a second
Sensors
• A device that transforms the physical quantity into
electrical value.
• Ex.: Light sensor transducer (Photodiode or LDR)
converts the light into voltage or resistance.
Sensors
Sensors
• Sensors can be both binary or a range.
• Usually, sensors that measure a range of values
vary their resistance to reflect their detection.
• Arduinos can only sense voltages, not resistances.
• Sensors that only vary their resistances require a
circuit called a voltage divider to provide the
Arduino a voltage.
Common Sensors
• Dials on a radio are • Infrared sensor & light
simply potentiometers • Hall effect sensor and
• Temperature magnet
• Light • Ball tilt sensor (for
• Angle measuring orientation)
• Switches • Force
– did the user throw a
switch or push a
button?
• Accelerometer (measures
motion and tilt)
Sensors Fingerprint Scanner

Temp & Humidity

Gas Sensor

Flex Sensor Geiger Counter


Sensors
Photo/ thermistor, infrared, force sensitive resistor, Hall effect,
Piezo, tilt sensor..
Light sensors

Photo Resistor (photo-cell):


- The value of the resistance depends
on the incident light density.
- 1 K-Ohm at light, 10 K-Ohm at
darkness.

Photo Diode:
Sensors

- The current is controlled by the incident light


density.

Photo Transistor:
- Base-emitter junction is
controlled by the incident light
density, has an amplification
effect.
Analog Output
• Can a digital devise produce analog output?

• Analog output can be simulated using pulse


width modulation (PWM)
Pulse Width Modulation
• Can’t use digital pins
to directly supply say
2.5V, but can pulse
the output on and off
really fast to produce
the same effect

• The on-off pulsing


happens so quickly,
the connected output
device “sees” the
result as a reduction
in the voltage
PWM Duty Cycle
output voltage = (on_time / cycle_time) * 5V

Fixed cycle length; constant


number of cycles/sec
PMW Pins

• Command:
analogWrite(pin,value)

• value is duty cycle:


between 0 and 255
• Examples:
analogWrite(9, 128)
for a 50% duty cycle

analogWrite(11, 64)
for a 25% duty cycle
eg3: Analog IO

A light Theremin
eg4: Analog IO

Add an LED
• Add a 330 ohm resistor and an LED to pin 9
• Using the analogWrite() command, set the
intensity of the LED as a function of the value
of prReading
Serial Communication
Serial Communication
• Compiling turns your program into
binary data (ones and zeros)
• Uploading sends the bits through
USB cable to the Arduino
• The two LEDs near the USB
connector blink when data is
transmitted
Serial to USB • RX blinks when the Arduino is
Chip:- receiving data
As ATMEGA don’t
support USB
• TX blinks when the Arduino is
transmitting data
Open the Serial Monitor and Upload
the Program
Some Commands
• Serial.begin()
- e.g., Serial.begin(9600)
• Serial.print() or
Serial.println()
- e.g., Serial.print(value)
• Serial.read()
• Serial.available()
• Serial.write()
• Serial.parseInt()
Two different communication
protocols

Serial (TTL):
Applications
• Light control
• Motor control
• Automation
• Robotics
• Networking
• Custom protocols
• Your imagination is the limit…
eg5: Serial Communication
Modify your program from in-class
exercise 2-part 2 to control the intensity
of the LED attached to pin 9 based on
keyboard input.

Use the Serial.parseInt() method to


read numeric keyboard input as an
integer.

An input of 9 should produce full


intensity and an input of 0 should turn
the LED off.
Applications
• Weather Stations
• Remote Antenna Switches
• Morse Code Keyboard

• Arduino Controlled Tuner


Some Good References
• http://arduino.cc/en/Guide/HomePage
• Recommend starting with: “Learning Arduino” by
Alan G. Smith
– http://introtoarduino.com/
• Full language reference available here:
– http://arduino.cc/en/Reference/HomePage
• Youtube
Introduction to Raspberry Pi
-- By Pritish M. Vibhute
Raspberry Pi (ARM Microcontroller)
Raspberry Pi (ARM Microcontroller)
• Full Linux Computer for $35
• Size of a business card
• Smart Phone Apps Compatible
• GPIO Ports Arduino Compatible
• Idea for HAM use (12V 700 mA 3.5W) Solar?
• Optional 12MP Camera (slow scan TV anyone?)
• LCD interface
• Raspberry Pi Fedora Remix (linux)
• Windows Port Coming soon
• Ideal for mobile computer system / experiments
• Repeater controller with VOIP all in one??
Raspberry Pi
• Low end computer, not a controller
• As it is a computer and not a controller, its role in
these projects are different.
• Hierarchy: computers control controllers,
controllers control hardware.
• Uses Debian Linux
– Arch Linux ARM, Fedora, FreeBSD, Slackware…
• Programmed with Python
– BBC BASIC, C, Perl
What is a Raspberry Pi?
• University of Cambridge’s Computer Laboratory
– Decline in skill level
– Designed for education
• A credit card sized PC
• Plugs into a TV or monitor
• Inexpensive(ish) ~$35 each
• Capability:
– Programming
– Electronic Projects
– Office
– Play HD Videos
Kit Components
• Essential:
– Raspberry Pi board
– Prepared Operating System SD Card
– USB keyboard
– Display (with HDMI, DVI, or Composite input)
– Power Supply
• Highly suggested extras include:
– USB mouse
– Internet connectivity - LAN cable
– Powered USB Hub
– Case
Programming Languages
• The Raspberry Pi Foundation recommends Python
• Any language which will compile for ARMv6 can
be used
• Installed by default on the Raspberry Pi:
– C
– C++
– Java
– Scratch
– Ruby
GPIO RCA Video 3.5mm Audio
(General (works with LAN Standard
Purpose most older TVs) Controller headphone socket
Input &
Output) 2 x USB 2.0
ports
DSI
CSI
(display
(camera
interface)
interface)
SOC 10/100Mb
Broadcom Ethernet
BCM2835 5v micro HDMI Audio & Video
700Mhz USB (works with modern TVs and DVI
connector monitors)
Storage

SD Card Slot
(supports SD cards up to 32GB)
Applications

Programming tools

Web server

Tor router
Game
Console
HTPC
Supercomputer
PiBot!

Clock
VLSI EGY- I.GEEK – S3Geeks
Thanks for coming 

Das könnte Ihnen auch gefallen