Read ArduinoProject.pdf text version

Arduino Project

A Open Source Hardware and Software Project

Wednesday, July 21, 2010

1

Arduino Project

· ATmel AVR Micro Controller · Open Source Hardware · Open Source Software · The board can be build by hand · http://arduino.cc

Wednesday, July 21, 2010 2

Why Arduino

· · · · ·

Inexpensive Cross Platform Simple and Clear Programming Environment Open Source and Extensible Software Open Source and Extensible Hardware

Wednesday, July 21, 2010

3

Licensing

· · ·

Physically embedding an Arduino board inside a commercial product does not require you to disclose or open-source any information about its design. Deriving the design of a commercial product from the Eagle files for an Arduino board requires you to release the modified files under the same Creative Commons Attribution Share-Alike license. You may manufacture and sell the resulting product. Using the Arduino core and libraries for the firmware of a commercial product does not require you to release the source code for the firmware. The LGPL does, however, require you to make available object files that allow for the relinking of the firmware against updated versions of the Arduino core and libraries. Any modifications to the core and libraries must be released under the LGPL. The source code for the Arduino environment is covered by the GPL, which requires any modifications to be open-sourced under the same license. It does not prevent the sale of derivative software or its inclusion in commercial products.

·

Wednesday, July 21, 2010

4

ATMEL AVR

· · · · · · · ·

Wednesday, July 21, 2010

8 bit AVR RISC Processor up to 20MIPS 4/8/16/32KB Flash Memory 256/512/1024 Bytes EEPROM 512/1024/2048 Byte SRAM 6 PWM/10bit ADC/USART/SPI/I2C 1.8V to 5.5V Internal OSC (0 to 20MHz) 23 I/O Lines

5

ATMEL AVR

Wednesday, July 21, 2010

6

Hardware

Serial Board

LilyPad

Pro

Mini

Mega

Diecimila

Wednesday, July 21, 2010 7

Microcontroller : ATmega168/ATmega368/ATmega1280 Operating Voltage : 5V Input Voltage (recommended) : 7-12V Input Voltage (limits) : 6-20V Digital I/O Pins : 14 (of which 6 provide PWM output) Analog Input Pins : 6 DC Current per I/O Pin : 40 mA DC Current for 3.3V Pin : 50 mA Flash Memory : 16 KB (ATmega168) : 32 KB (ATmega328) : 2 KB used by bootloader SRAM : 1 KB (ATmega168) : 2 KB (ATmega328) EEPROM : 512 bytes (ATmega168) : 1 KB (ATmega328) Clock Speed : 16 MHz

Wednesday, July 21, 2010 8

Hardware

PIC v.s. AVR

PIC

PIC18F452 ($10.35) 8/16/32 Bit 40MHz Clock 16KB/32KB Flash 768/1536 Byte SRAM 256 Byte EEPROM ESUART SPI I2C 10 bit A/D

MPLAB/CCS ($450)/ SDCC (Free)

AVR

AVRTools (Free Open Source) 8 Bit 20MHz Clock 16KB/32KB Flash 1024/2048 Byte SRAM 512/1024 Byte EEPROM SUART SPI I2C 10 Bit A/D Atmega328 ($8.17)

Wednesday, July 21, 2010

9

Hardware Open Source

Wednesday, July 21, 2010

10

Hardware Open Source

Wednesday, July 21, 2010

11

Plug-in Shields

Ethernet Shield

Motor Controller

Video Shield

Touch Shield GPS Dataloger Shield Xport Ethernet Shield

Wednesday, July 21, 2010 12

Open Source Software

· IDE and compiler for Windows/Linux/OS X

cross platform

· Simple IDE via Java · Easy to development without MICE · Work with/without Bootloader

Wednesday, July 21, 2010 13

Work Flow

Wednesday, July 21, 2010

14

Software IDE

Wednesday, July 21, 2010

15

Blink LED Source

/* Blink Turns on an LED on for one second, then off for one second, repeatedly. The circuit: * LED connected from digital pin 13 to ground. */ int ledPin = 13; // LED connected to digital pin 13

// The setup() method runs once, when the sketch starts void setup() { // initialize the digital pin as an output: pinMode(ledPin, OUTPUT); } // the loop() method runs over and over again, // as long as the Arduino has power void loop() { digitalWrite(ledPin, HIGH); // set the LED on delay(1000); // wait for a second digitalWrite(ledPin, LOW); // set the LED off delay(1000); // wait for a second }

Wednesday, July 21, 2010

16

/* * Web Server * * A simple web server that shows the value of the analog input pins. */ #include <Ethernet.h>

Web Server Code

} if (c == '\n') { // we're starting a new line current_line_is_blank = true; } else if (c != '\r') { // we've gotten a character on the current line current_line_is_blank = false; } // output the value of each analog input pin for (int i = 0; i < 6; i++) { client.print("analog input "); client.print(i); client.print(" is "); client.print(analogRead(i)); client.println("<br />"); } break;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 10, 0, 0, 177 }; Server server(80); void setup() { Ethernet.begin(mac, ip); server.begin(); } void loop() { Client client = server.available(); if (client) { // an http request ends with a blank line boolean current_line_is_blank = true; while (client.connected()) { if (client.available()) { char c = client.read(); // if we've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so we can send a reply if (c == '\n' && current_line_is_blank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println();

Wednesday, July 21, 2010

}

}

} // give the web browser time to receive the data delay(1); client.stop();

}

17

Ethernet.h

#ifndef Ethernet_h #define Ethernet_h #include <inttypes.h> #include "Client.h" #include "Server.h" class EthernetClass { private: public: static uint8_t _state[MAX_SOCK_NUM]; static uint16_t _server_port[MAX_SOCK_NUM]; void begin(uint8_t *, uint8_t *); void begin(uint8_t *, uint8_t *, uint8_t *); void begin(uint8_t *, uint8_t *, uint8_t *, uint8_t *); friend class Client; friend class Server; }; extern EthernetClass Ethernet; #endif

Wednesday, July 21, 2010

18

Ethernet.cpp

extern "C" { #include "types.h" #include "w5100.h" } #include "Ethernet.h" // XXX: don't make assumptions about the value of MAX_SOCK_NUM. uint8_t EthernetClass::_state[MAX_SOCK_NUM] = { 0, 0, 0, 0 }; uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = { 0, 0, 0, 0 }; void EthernetClass::begin(uint8_t *mac, uint8_t *ip) { uint8_t gateway[4]; gateway[0] = ip[0]; void EthernetClass::begin(uint8_t *mac, uint8_t *ip, uint8_t *gateway) gateway[1] = ip[1]; { gateway[2] = ip[2]; uint8_t subnet[] = { 255, 255, 255, 0 }; gateway[3] = 1; begin(mac, ip, gateway, subnet); begin(mac, ip, gateway); } } void EthernetClass::begin(uint8_t *mac, uint8_t *ip, uint8_t *gateway, uint8_t *subnet) { ! iinchip_init(); ! sysinit(0x55, 0x55); ! setSHAR(mac); ! setSIPR(ip); setGAR(gateway); setSUBR(subnet); } EthernetClass Ethernet;

Wednesday, July 21, 2010

19

C/C++

·

The Arduino language is merely a set of C/C++ functions that can be called from your code. Your sketch undergoes minor changes (e.g. automatic generation of function prototypes) and then is passed directly to a C/C++ compiler (avr-g++). All standard C and C++ constructs supported by avr-g++ should work in Arduino.

Wednesday, July 21, 2010

20

Software Libraries

· EEPROM · Ethernet · Firmata · LiguidCrystal · Servo · Software Serial

Wednesday, July 21, 2010

· Stepper · Wire · Matrix · Sprite · X10 · XBee

· LEDControl · Tone · Streaming · LCD · MUX · Webduino

21

Programmer ISP

· ICSP (In-Ciruit Serial Programming) · USB/Serial with USBTiny ISP · Parallel · Arduino Bit Bang mode

Wednesday, July 21, 2010 22

Parallel Programmer

Wednesday, July 21, 2010

23

TinyUSB ISP

·

http://www.ladyada.net/make/usbtinyisp/

Wednesday, July 21, 2010

24

Arduino Bitbang Mode

Wednesday, July 21, 2010

25

Write without Bootloader

Add to board.txt

############################################################## nobootloader328.name=Write without Arduino Bootloader nobootloader328.upload.protocol=stk500 nobootloader328.upload.maximum_size=30720 nobootloader328.upload.speed=57600 nobootloader328.upload.using=usbtinyisp nobootloader328.build.mcu=atmega328p nobootloader328.build.f_cpu=16000000L nobootloader328.build.core=arduino

Mac OS X : Arduino icon, Click with CTRL key Press, select "Show Package Content". Goto Contents/Resources/Java/Hardware Linux: cd arduino/lib Windows: Goto arduino directory, cd arduino/hardware

Wednesday, July 21, 2010 26

Arduino BitBang Mode

Add to programmers.txt

bitbang.name=FTDI Bitbang bitbang.protocol=diecimila -Pft0 -B4800

Mac OS X : Arduino icon, Click with CTRL key Press, select "Show Package Content". Goto Contents/Resources/Java/Hardware Linux: cd arduino/lib Windows: Goto arduino directory, cd arduino/hardware

Wednesday, July 21, 2010 27

Add new Libraries

Download library from net, unarchived, copy the directory to "libraries" directory After close and start Arduino IDE, Check the example tag, if the library provide a example.

Mac OS X : Arduino icon, Click with CTRL key Press, select "Show Package Content". Goto Contents/Resources/Java/Hardware/Libraries Linux: cd arduino/libraries Windows: Goto arduino directory, cd arduino/hardware/libraries

Wednesday, July 21, 2010 28

MultiCode Arduino

Wednesday, July 21, 2010

29

Software Simulator

VirtualBoard http://www.virtualbreadboard.net/

Wednesday, July 21, 2010 30

Arduino Projects

· · · · · · · ·

Telly Mate - TV Out http://www.batsocks.co.uk/products/Shields/TellyMate%20Shield.htm Critical Velocity LCD http://www.criticalvelocity.com/item.php?itemid=shield9 Servo/Motor/Stepper http://www.ladyada.net/make/mshield/ Touch Screen http://www.liquidware.com/shop/show/TSL/TouchShield+Slide Micro SD http://www.sensor-networks.org/index.php?page=0827727742 GPS Datalog http://www.ladyada.net/make/gpsshield/ AutoPilot http://diydrones.com/notes/ArduPilot Humane Reader a 8bit low cost PC for TVs http://humaneinfo.com/

Wednesday, July 21, 2010

31

References

· · · · · · · ·

Geting Start with Arduino Book http://oreilly.com/catalog/9780596155513/ Arduino Course http://sheepdogguides.com/arduino/FA1main.htm Designer's Guide to getting started with elevtronic sketching http://ahmedriaz.com/mind/projects/esketching4designers/ Arduino Forum http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl Arduino Blog http://arduino.cc/blog/ Arduino Manual in PDF http://www.arduino.cc/playground/Main/ ManualsAndCurriculum PIC v.s. AVR http://www.ladyada.net/library/picvsavr.html MultiCore Arduino - Humane Reader - a 8bit PC for TVs http://www.engadget.com/2010/07/20/humane-reader-is-a-20-8-bit-pc-for-tvs/

Wednesday, July 21, 2010

32

Enjoy it!

Wednesday, July 21, 2010

33

Information

33 pages

Find more like this

Report File (DMCA)

Our content is added by our users. We aim to remove reported files within 1 working day. Please use this link to notify us:

Report this file as copyright or inappropriate

300002