Slide 1

Slide 1 text

Arduino Rapid Prototyping with Python, C++ and Web Services 1 Robert Smallshire @robsmallshire Friday, 16 November, 12

Slide 2

Slide 2 text

2 Norway Friday, 16 November, 12

Slide 3

Slide 3 text

3 Arduino Out of the Box An introduction to Arduino hardware and development Behind the Scenes Understanding how Arduino works and using professional tools Developing with Web Services Application architectures to ease Arduino prototyping 1 2 3 Friday, 16 November, 12

Slide 4

Slide 4 text

4 ATmega328P ATmega16U2 power regulation serial I/O 16 MHz crystal Friday, 16 November, 12

Slide 5

Slide 5 text

                                                                                   !  " "  "#$" ""    ""  "   " "         ""  "    ""   ""  ""   "" "  "  "   "   " "    %  &    "$  !  !  !                                    " " !         Friday, 16 November, 12

Slide 6

Slide 6 text

8271ES–AVR–07/2012 Features • High Performance, Low Power Atmel®AVR® 8-Bit Microcontroller Family • Advanced RISC Architecture – 131 Powerful Instructions – Most Single Clock Cycle Execution – 32 x 8 General Purpose Working Registers – Fully Static Operation – Up to 20 MIPS Throughput at 20MHz – On-chip 2-cycle Multiplier • High Endurance Non-volatile Memory Segments – 4/8/16/32KBytes of In-System Self-Programmable Flash program memory – 256/512/512/1KBytes EEPROM – 512/1K/1K/2KBytes Internal SRAM – Write/Erase Cycles: 10,000 Flash/100,000 EEPROM – Data retention: 20 years at 85qC/100 years at 25qC(1) – Optional Boot Code Section with Independent Lock Bits In-System Programming by On-chip Boot Program True Read-While-Write Operation – Programming Lock for Software Security • Atmel® QTouch® library support – Capacitive touch buttons, sliders and wheels – QTouch and QMatrix® acquisition – Up to 64 sense channels • Peripheral Features – Two 8-bit Timer/Counters with Separate Prescaler and Compare Mode – One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture Mode – Real Time Counter with Separate Oscillator – Six PWM Channels – 8-channel 10-bit ADC in TQFP and QFN/MLF package Temperature Measurement – 6-channel 10-bit ADC in PDIP Package Temperature Measurement – Programmable Serial USART – Master/Slave SPI Serial Interface – Byte-oriented 2-wire Serial Interface (Philips I2C compatible) – Programmable Watchdog Timer with Separate On-chip Oscillator – On-chip Analog Comparator – Interrupt and Wake-up on Pin Change • Special Microcontroller Features – Power-on Reset and Programmable Brown-out Detection – Internal Calibrated Oscillator – External and Internal Interrupt Sources – Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby, and Extended Standby Atmel 8-bit Microcontroller with 4/8/16/32KBytes In- System Programmable Flash ATmega48A; ATmega48PA; ATmega88A; ATmega88PA; ATmega168A; ATmega168PA; ATmega328; ATmega328P SUMMARY • 32768 bytes flash • bootloader • program • const static data† • 2048 bytes EEPROM • persistent data • 2048 bytes SRAM • stack • static • heap‡ † If you know what you’re doing ‡ A luxury you can’t afford Friday, 16 November, 12

Slide 7

Slide 7 text

7 Friday, 16 November, 12

Slide 8

Slide 8 text

8 The Arduino programming language: “Wiring” Friday, 16 November, 12

Slide 9

Slide 9 text

9 Friday, 16 November, 12

Slide 10

Slide 10 text

Many neat shields on the market Arduino Shields ‣ Many neat shields on the market ‣ Easy to fabricate your own using protoshields or PCB production 10 Friday, 16 November, 12

Slide 11

Slide 11 text

Oh dear! Arduino Shields ‣ Shield physical design is incredibly dumb ‣ Most shields are badly designed, amateurish and mutually incompatible ‣ Getting some shields to work on the Mega requires hardware modification (better with Arduino R3) 11 Friday, 16 November, 12

Slide 12

Slide 12 text

12 Arduino Out of the Box An introduction to Arduino hardware and development Behind the Scenes Understanding how Arduino works and using professional tools Developing with Web Services Application architectures to ease Arduino prototyping 1 2 3 Friday, 16 November, 12

Slide 13

Slide 13 text

13 avr-gcc avr-libc avrdude http://www.nongnu.org/avr-libc/ Arduino.h Wire Serial SPI Ethernet SD EEPROM “Libraries” Arduino bootloader Arduino IDE core.a avr-ar blink.ino blink.cpp avr-objcopy blink.cpp.o SPI.cpp.o blink.cpp.elf blink.cpp.hex blink binary make Friday, 16 November, 12

Slide 14

Slide 14 text

Removing the training wheels ‣ Eclipse IDE with CDT (C/C++ integration) • Arduino plugin : Higher level http://eclipse.baeyens.it/ • AVR plugin : Lower level http://avr-eclipse.sourceforge.net/wiki/index.php/The_AVR_Eclipse_Plugin ‣ arscons - SCons builds for Arduino • https://github.com/suapapa/arscons ‣ AVR Freaks - Arduino-free AVR programming in C, C++, assembler • http://www.avrfreaks.net/ 14 Beyond the Arduino IDE Friday, 16 November, 12

Slide 15

Slide 15 text

Expect to be tripped up by this stuff Gotchas ‣ Different Arduino models (Uno / Mega) use different programmers “Arduino” versus “Atmel STK500 Version 2.0 firmware” ‣ Arduino community is (mostly) a bunch of amateurs with little experience of ‘real’ programming. Lots of bad information and unfounded hearsay. Mythology. ‣ Some C++ features rely on ‘missing’ pieces of libc (such as pure virtual functions) • extern "C" void __cxa_pure_virtual(void) { while(1); } 15 Friday, 16 November, 12

Slide 16

Slide 16 text

16 Arduino Out of the Box An introduction to Arduino hardware and development Behind the Scenes Understanding how Arduino works and using professional tools Developing with Web Services Application architectures to ease Arduino prototyping 1 2 3 Friday, 16 November, 12

Slide 17

Slide 17 text

17 HTTP Friday, 16 November, 12

Slide 18

Slide 18 text

18 WiFi shields Friday, 16 November, 12

Slide 19

Slide 19 text

19 Other Arduino web services ‣ RESTduino • http://jasongullickson.posterous.com/restduino-arduino-hacking-for-the-rest-of-us • low level pin access (digitalWrite, analogRead) • badly named - it’s not RESTful at all (no HATEOAS, no HTTP verbs) ‣ Teleduino • https://www.teleduino.org/ • Allows access to Arduino over the Internet (not just the network) via their centralised server. • low level pin access (digitalWrite, analogRead) Friday, 16 November, 12

Slide 20

Slide 20 text

20 Arduino Mega 2560 Arduino Ethernet & SD Card Shield Prototype Shield (PIC16F77 as servo controller) MAX6651 shield MAX6651 shield I2C bus SPI bus Linux laptop Ethernet Dallas One Wire bus H% Proprietary One Wire Bus Server cabinet environment controller Friday, 16 November, 12

Slide 21

Slide 21 text

21 Friday, 16 November, 12

Slide 22

Slide 22 text

22 16℃ Friday, 16 November, 12

Slide 23

Slide 23 text

23 7℃ Friday, 16 November, 12

Slide 24

Slide 24 text

24 -5℃ Friday, 16 November, 12

Slide 25

Slide 25 text

25 Friday, 16 November, 12

Slide 26

Slide 26 text

26 Friday, 16 November, 12

Slide 27

Slide 27 text

Friday, 16 November, 12