Arduino and Machine Science Development Boards: Programming

Preview:

Citation preview

Arduino and Machine ScienceDevelopment Boards:

Programming Microcontrollers- the AtMega 168 and 328

MPSM337Electronic Projects for Artists FA14

The Arduino(or actually, the AtMega Microcontroller)

Arduino's kind of revolutionary potential:

“ If we take a piece of technology considered, rightly or wrongly,complex, and we make it simple by working not on the technology itself

but on the experience that comes from using it, then everything getssimpler and we discover new possibilities that were not there before.

“If I were a chicken farmer, I could think of an idea to increase theefficiency or the safety of my farm. With Arduino, even those -who knowabout chickens but not about electronics and programming- are able to

achieve, by themselves and in a very short time, the kludge they need tosolve their practical problem.

All this is about moving technology towards what we might call a domainexpert. In the end, the one who raises chickens is certainly much more

expert about chickens than an engineer.”

- Massimo Banzi

Photo: Randi Silberman Klett

Five of the core Arduino developer team: David Cuartielles, Gianluca Martino, Tom Igoe, David Mellis and Massimo Banzi.

What's the difference between a microprocessorand a microcontroller?

A microprocessor: • an IC with only the Central Processing Unit (CPU) • No RAM, ROM, or peripheral I/O on the chip. (System designers must add these externally to make these function in Desktop PC’s, Laptops, notepads, tablets, etc.• (Manufacturers include: Intel's Pentium, core 2 duo, i3, i5, ARM, PowerPC, AMD, etc. )

A microcontroller: • an IC with CPU, I/O pins, a fixed amount of RAM, ROM, all embedded on a single, 'all in one' chip. • (Manufacturers include: Microchip, ATMEL, TI, Freescale, Philips, Motorola)

There are many different microcontroller ICs...

Many are available on handy “development boards”.

Parallax “Basic Stamp” :

Arduino boards...

Leah Beuchley

The UNO for example, uses the ATmega 328:

• 28 pin, 8 bit IC

• Runs at 16 MHz (but chip can run at 20 MHz).

• 32K Bytes of flash memory, 2K SRAM

• 20 I/O pins: 14 digital, 6 analog (10 bit ADC)

• regulated at 5 and 3.3 volts

The Arduino is a development platform using microcontrollers from Atmel's ATmega series.

• Open Source hardware and software

• Cross platform (Mac, Windows and Linux)

• Support from huge non-condescending community

Over one million Arduinos sold in 7 years.

Some key reasons given for its success:

Arduino is open source hardware: the Arduino hardware reference designsare distributed under a Creative Commons Attribution Share-Alike 2.5 license,

available on the Arduino Web site.

Layout and production files for some versions are also available.

The source code for the IDE is available and released under the GNU General Public License, version 2.

What is Open Source Hardware?

• License

• Schematics

• PCB layout data

• Bills of Sale (component distributors...)

– Limor Fried (Lady Ada) AdaFruit Industries

– Hernando Barragán: “Wiring” Arduino Libraries

– Karsten Schmidt “Toxi” Processing libs

– Daniel Shiffman -”Physical Computing” with Tom Igoe @ NYU's ITP

– Leah Beuchley -designed “Lilypad” Arduino

– Dr. Rafael Hernandez pd tutorials “cheetomoskeeto” YouTube channel

Some Heroes in the Creative Free Hard/Software movement:

Limor Fried Photo: Inc com

Fortunately, popularity invites copying and competition...

Apparition.

...on the higher end: Odroid-X

$130 – $200.00

• Quad core ARM processor w/ 3D graphics accel.• 1 Gig DDR2 RAM • 50 pin IO pin I/O• SD card storage• Runs Android OS

(or Shivaplug, PandaBoard...)

...on the lower end: DigiSpark (http://digistump.com):

$8.95

• 8 pin IC• 8K Bytes of flash memory• 6 digital I/O pins• 3 also do PWM, 4 with ADC

...and head-to-head: BeagleBone Black $45.00

• 1GHz ARM processor w/ 3D graphics accel.• 512 MB DDR3 RAM • 2 x 46 pin header• on Board 2 Gigs of flash storage (exp. W/ SD card)

The Raspberry Pi

• price $25-$35 USD

• Broadcom BCM2835 System on a Chip (CPU + GPU)

• 700 MHz ARM11.

• 256 MB RAM (Model A) 512 MB RAM (Model B) -not expandable

• Storage = SD Card “Hard Drive”

• 26 I/O pins total: 3 power supply 3V3 (3.3V) 5V0 (5V) and GND; 6 DNC (Do Not Connect); and 17 GPIO

• HD video (1080p30) plus audio over HDMI

Raspberry Pi specs:

Flickr.com/Poptech/CC BY SA 2.0

Eben Upton, Executive Director, Paspberry Pi Foundation

Requirements for the microcontroller:

1. Power- It's an electrical component, so of course you have to give it power. But like many ICs, the voltage used to operate it needs to be controlled relatively precisely.

2. I/O- Input and output, some way to communicate with the chip. This is generally done through some kind of connection to the chip's pins. Breadboards are handy.

3. Programming Interface- Some way to write programs and download them to the chip and run them.

Requirements for the microcontroller:

1. Power:

There are three commonly used ways for controllingthe voltage supplied to microcontrollers:

I. A voltage regulator

II. A regulated power supply

III. Battery power

Requirements for the microcontroller:

Voltage regulator

Requirements for the microcontroller:

Regulated power supply

Requirements for the microcontroller:

Battery pack

Requirements for the microcontroller:

2. I/O: I. Limited

II. “shields”

III. Roll your own.

Requirements for the microcontroller:

3. Programming Interface (computer connection):

Requirements for the microcontroller:

3. Programming Interface (computer connection):

We will be using the same microcontroller used on the Arduino board, apopular chip made by the Atmel corporation -the “Atmega” 168 or 328.

(These are 28 pin ICs with identical pin designations, but the 328 has morememory.) The hardware interface we'll be using is perhaps the simplest (andcheapest): connecting to it on a standard breadboard.

Requirements for the microcontroller:

3. Programming Interface (computer connection):

The USB serial communication with the chip is negotiated by an on-boardchip made by a company called FTDI. There are free FTDI drivers that canbe downloaded for almost every computer platform. Once installed, thecomputer will be able to send/receive serial communication via USBconnection to an FTDI chip.

The Arduino Programming interface (IDE).

If there is an error in the code (usually something simple likeleaving out a semicolon) the compiler will complain with anerror message and highlight the first line of the problem.

Once the errors in the code have beencorrected, the compiled, machineexecutable program will download tothe chip and run. If the behavior of theprogram isn't what you want, just goback and edit the code.

… and then you just keep doing thatover and over again until you get whatyou want.

Let's set things up andhave fun coding!