south jersey robotics club

25
South Jersey Robotics Club June 2014 Meeting Presentation Topic – Intro to Arduino

Upload: zev

Post on 25-Feb-2016

30 views

Category:

Documents


0 download

DESCRIPTION

South Jersey Robotics Club. June 2014 Meeting Presentation Topic – Intro to Arduino. Agenda. New Member Introductions! Building membership Show and Tell Maker Fare trip planning Intro to Arduino Next meeting planning… Lunch! But First…. Say hello to the Atlanta Hobby Robotics Club!. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: South Jersey Robotics Club

South Jersey Robotics Club

June 2014 Meeting

Presentation Topic – Intro to Arduino

Page 2: South Jersey Robotics Club

Agenda

• New Member Introductions!• Building membership• Show and Tell• Maker Fare trip planning• Intro to Arduino• Next meeting planning…• Lunch!

• But First…

Page 3: South Jersey Robotics Club

Say hello to the Atlanta Hobby Robotics Club!

Page 4: South Jersey Robotics Club

Introductions

• Please state your:– Name– Interests in this area• Software? Electronics? Mechanical?• Which platforms (Arduino, Pic, NXT, Vex, RasPi, etc.)

– Level of experience– What you want to get out of the club– Quick description of any projects you’re currently

working on or want to start

Page 5: South Jersey Robotics Club

Building Membership

• Flyer was sent to several local high schools.• Comments on Flyer?• Ideas on how we can get the word out more?

Page 6: South Jersey Robotics Club

Show and Tell

• http://www.popularmechanics.com/technology/how-to/gadgets/10-magnificent-builds-from-maker-faire-2014-7#slide-8

• Phoenix 3D Printer on the way! http://phoenix3dprinter.com

• Xbox One Kinect coming for PC - July 15, $199

Page 7: South Jersey Robotics Club

NYC World Maker Fare 2014

• September 20+21• Do we want to do a group ride?

Page 8: South Jersey Robotics Club

Intro to Arduino

• What is it?– Hardware– Software

• Boot loader• Sketches

• How do you use it?– Basic Sketch structure– Basic wiring concepts– Libraries– Resources

Page 9: South Jersey Robotics Club

Hardware• Intended for the “artistic” crowd

– Hence, SIMPLE to program! Take away all the headaches and focus on getting something working fast and easy.

• Number of different models, each with different caveats.– Be careful of voltage levels (3.3V or 5V)– Processor speed, RAM, # pins, etc.

• Best for getting started is the Uno / Leonardo

• Small Flash storage on the chip for storing your program (1 at a time)

Page 10: South Jersey Robotics Club

Software – Boot Loader

• Boot Loader comes pre-installed– Small program that knows how to interpret the

Sketches. (Like the “Arduino OS”)– Simplifies a lot of the “dirty work” typical with

microcontrollers– Can buy the AVR chips without the bootloader and

then install it.– 99% of the time you don’t need to worry about

this…

Page 11: South Jersey Robotics Club

Software – Editor• Simple free editor for making

your own programs in.• Limited – no debugger, no

breakpoints, but does have serial output display.

• Pretty easy to add libraries, comes with lots of examples, color coding of statements, code formatting

• Edit, manage, and upload your code right from here

Page 12: South Jersey Robotics Club

Software - Sketches

• Your programs are called “Sketches” (comes from the artistic heritage of Ardiuno).

• Very C-like with some simple OO mixed in.• Pretty simple to learn to do the basics.

• Let’s look at one!

Page 13: South Jersey Robotics Club

Simple Sketch - Blink

• 3 basic parts– Global

Declarations– Setup()– Loop()

Page 14: South Jersey Robotics Club

Setup() Section

• Happens 1 time, as soon as you turn the power on.• Describe what you want each pin to do (input, output)

• Input – pinMode(10, INPUT); • Output - pinMode(13, OUTPUT);

• Initialize any variables or objects you need here.• Also a good place to put the “5 second countdown” or

anything else you need run only a single time at the start. (wait for a button press to start, etc.)

Page 15: South Jersey Robotics Club

Loop() Section• Where all the “Magic” happens!• Runs as soon as the Setup is done.• Repeats over and over until power is turned off.• Here’s where you actually read or write data to/from the pins

you set up in the setup.– Read (Digital) – value=digitalRead(10); – Read (Analog) – value=analogRead(A0);– Write (digital) – digitalWrite(13, HIGH);– Write (PWM) – analogWrite(13, 130);

• Let’s look at the Blink example…

Page 16: South Jersey Robotics Club

Analog vs. Digital5.0 V

3.234 V

1.854 V

0.01 V 0.01 V

5.0 V = On

= Off

1.854 V = ???

A-to-D (ADC)255

200

64

0

Page 17: South Jersey Robotics Club

PWM– Remember in the previous slide we had this line:• Write (PWM) – analogWrite(13, 130);• Can only do this on certain pins on the Arduino…(Marked with ~)• What does this mean???

– Pulse Width Modulation – • Think of it as a % of intensity… (0-255 scale, maps to 0-100%)• 10% duty cycle – means that every second 1/10th of the time it’s

set HIGH, the other 90% it’s set LOW• 50% duty cycle – means ½ time it’s HIGH, ½ time it’s LOW

– If applied to a LED – changes the intensity of the light.– If applied to a motor – controls the speed.

Page 18: South Jersey Robotics Club

PWM Visually80%

50%

20%

Page 19: South Jersey Robotics Club

Libraries• Arduino comes with a number of libraries to work with common

hardware (buttons, Leds, servo motors, LCDs , Stepper motors, etc.) Examples for each as well!

• Extensive stuff built in – time functions, serial input/output, and more!

• Good language reference: http://arduino.cc/en/Reference/HomePage

• Can add in libraries for new hardware (Pololu’s stuff for instance often has libraries to add to make working with their stuff simple).

• Can make your own as well! (Common functions you always use… Can just import them into your sketches..)

Page 20: South Jersey Robotics Club

Upload and run!

• When you’re ready, attach your Arduino over the USB port…

• Select the proper USB interface (might have to install a driver on your machine…)

• Compile and Upload your sketch…• Wait a couple seconds, and boom it’ll start

running! It’ll run every time you give the board power too!

Page 21: South Jersey Robotics Club

There’s a LOT more to it…• Remember, don’t put EVERYTHING into to Loop() – You CAN

call out to other functions you make… • Everything runs in a single thread of execution, so

remember that if the processor is busy reading something, or waiting for a button press, or looping through a big array, it’s NOT doing anything else. – Some advanced techniques can be used to get around this, but

it’s far from straightforward.• Interrupts• Don’t be wasteful! VERY limited memory!!!• Other interfaces (I2C, I2S)

Page 22: South Jersey Robotics Club

Suggested Progression• Start out using shields (a motor shield is usually a good starting point for a

robot).– Lets you worry more about the programming…– Remember, shields hog certain pins, can’t reuse pins for multiple

shields! • Once you get the hang of it, then move to using smaller modules that you

wire up (e.g. TB6612FNG motor controller breakout board)– More flexibility in terms of size/shape/power/combinations of

functions.• If you are REALLY good with electronics, then you can do low level circuit

design with individual chips, etc.– E.g. TB6612FNG, (just the chip)– And we all bow down to your EE greatness!

Page 23: South Jersey Robotics Club

For Example, my Sumo Bot…

• First Gen: Uno + Motor Shield

• Second Gen: Nano + TB6612FNG motor module

Page 24: South Jersey Robotics Club

Questions???• Good reference book : “Beginning Arduino”

– Covers both basic hookup of devices, as well as the code.• Be careful buying shields if you pick up a 3.3V Arduino (like the

Due). Many expect 5V…• Don’t fry the board!!! Most of the pins are only made to handle

100ma Max!• The board itself will run off USB power, but usually to drive

anything else hooked up to it, you’ll need to plug in the aux power (wall jack, battery pack, etc.)

• Don’t let pins “float” – always use pull up/down resistors• Lots of 3rd party compatible devices – Pololu Orangutan series,

Netduino, Mintduino, RFDuino, etc.

Page 25: South Jersey Robotics Club

Next meeting

• What’s a good date? July 12? 26?• Location?• Topic?– Some Ideas:

• Basic Electronics/ Circuits• Mini Sumo• IMUs + GPS• Filtering (Particle / Extended

Kahlman)• Encoders• Raspberry Pi primer• How to use an O-Scope / Logic

Analyzer• How to use EagleCAD• How to Solder

• Build a simple robot • OpenCV for beginners• Intro to ROS (Robot Operating

System)• Maze Solving• Obstacle detection and

avoidance/tracking• Web based robot control interface• Line following / line sensors / PID

control