* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Session 1 Slides - Wolf Den Electronics
Survey
Document related concepts
Electronic engineering wikipedia , lookup
Variable-frequency drive wikipedia , lookup
Power engineering wikipedia , lookup
Power inverter wikipedia , lookup
Immunity-aware programming wikipedia , lookup
Buck converter wikipedia , lookup
Voltage optimisation wikipedia , lookup
Alternating current wikipedia , lookup
Power electronics wikipedia , lookup
Switched-mode power supply wikipedia , lookup
Mains electricity wikipedia , lookup
Transcript
Intro to Arduino Basic Arduino John Wolf (WolfDenElectronics.com) There are 10 types of people. Those that understand binary, and those that do not understand binary. Make that 11 types. Those that understand binary, those that don't, and those who didn't grasp this joke even if they did understand binary. Objectives – We’ll Learn Arduino pedigree Arduino Integrated Development Environment (IDE) Serial Monitor interface and other IDE features-works well with Processing Start writing code dJi>gbisea Add concepts describing physical computing as we go – Why explosions occur More Objectives… Pulse Width Modulation (PWM) Analog signals -> Digital Driving motors – H-Bridges How servos work – feedback loops Pulling it together with Ohm’s Law Voltage regulators Power limitation of the USB port MOST IMPORTANT – Glossary of terms (learn to use a pencil again) There are shields for everything you can think of. If not, build one and get rich. This is why Arduino is so popular… www.Arduino.cc or .org How to keep up on Arduinos Match Arduino to Application (8-bit computing – yeah!) Alternatives Raspberry Pi Texas Instruments LaunchPad MSP430 Texas Instruments BeagleBone Black Arduino Board of Direction “Teach the Youth” Ivrea, Italy in 2005, Massimo Banzi & David Cuartielles Open Source Hardware Atmel Processor (8-bit power) Coding is accessible (C++, Processing, ModKit and MiniBloq) What’s an Arduino? Digital I/O header USB USB processor Atmel AVR Computer Power in (7~12V) Analog I/O header Microcontroller board with all the support electronics built-in on the board. Has 14 digital I/O and 6 analog I/O connections. USB port, power jack, and voltages for support electronics attached to the board via the headers. Arduino IDE – resides on laptop Where you write your source code Compile, link your code and upload to the board Code checker Code layout feature Organize code and libraries available Provides a serial interface via the USB port to the Arduino board (IDE => Integrated Development Environment) App to interface to the Arduino via USB console area Serial Monitor How to get the Arduino S/W Go to www.arduino.cc Click the “Download” tab Now you have a choice: If you have a new computer with the latest OS… go to the turquoise box and click the appropriate download. I suggest zip files. Or… click on “Previous Releases” and download arduino1.0.6. This is the classic Arduino IDE that matches the basic set of Arduino boards. The new software adds-in compatibility with the new specialty boards and later OS’s. Where to place the Arduino folder Two logical places (although – anyplace will work, because the IDE is self contained – not installed into the OS) Just put it in your My Documents folder. Better: Put it in your Program Files (86) folder at C:\Program Files(86)\ This way, it’s part of your other programs Easy to find How to use the IDE Let’s walk through this… When you write your first sketch and go to “save as” to store it, browse to a new folder you set up in your regular My Documents directory. The IDE will remember this path an store all your sketches there, plus give you a library folder to place Third Party libraries you will want to use. Integrated Development Environment What you do see: Area for variables The “setup()” function – void setup(); The “loop()” function – void loop(); int main(void); and Arduino.h are active, but hidden(C++) More Arduino.h “methods” pinMode – used to tell the compiler whether a pin is an input or an output digitalWrite – whether to write-out a HIGH or LOW voltage digitalRead – read-in the pin voltage for a HIGH or LOW value analogRead – use the A/D converter to read an analog value (0-5V) analogWrite – triggers the PWM feature Analog to Digital Convertion +5V Arduino uses 10bits or 1024 individual levels from 0 to 1023 Pins A0 to A5 0V Time(or analogReads) Pulse Width Modulation Outputs are always digital, even when representing analog. For PWM the Arduino pin turns on then off very fast 2 ms 5 Volts 0 Volts (Arduino PWM base frequency is approx 490 Hz, 980Hz on pins 5, 6) Let’s Get Our Hands Dirty… Must be aware of Uno Power Limitations VIN Barrel Connector Atmel328 GND USB power called USBVCC. VIN cuts off USBVCC and applies power directly to +5V regulator, which also supplies 3.3V regulator. Barrel connection basically at the VIN point. Note: VIN polarity not protected like barrel connector. Regulator can accept 7 to 12V in, 5V out at ~500ma Basic gear to start fiddling around Breadboard has two sets of +5V rails and Gnds. Each middle row is connected across, but not down. 9V battery can supply about double the current the USB port can Center gutter is there for and IC to straddle. 9V Wall-wart usually supply about 1.5A to 2A so are good. Beef up the +5 Volts for more elaborate projects. Many projects require current loads or other voltages only and external supply can adequately handle. GND Can use Vin to power the Arduino Addition Power Supply Built from old ATX supply from a discarded computer Old ATX Pwr Box 2.0 Done the same way with better construction technique. So… you have to learn about electronics as we go. Next level is learning how to solder your projects together – then make PCBs. All supported by Open Source developers. Ohm’s Law E=IxR I = 3.8/220 I = 17mA 0 to 5V input Pot Fritzing CAD layout 220 W +5V 1.2v 3.8v here LED 220 W (190W 20ma) +5V GND GND Example Sketch (C++) type end int ledPin = 9; int potPin = A3; int val = 0; // LED connected to digital pin 9 (PWM pin) // potentiometer connected to analog pin 3 // variable to store the value read void setup() { pinMode(ledPin, OUTPUT); // sets the pin as output pinMode(potPin, INPUT); // sets the pin as input } void loop() { val = analogRead(potPin); // read the input pin with ADC 10-bits analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, //analogWrite values from 0 to 255 } Last statement scales the input-read to the output capability of the PWM Pulse Width Modulation Outputs are always digital, even when representing analog. For PWM the Arduino pin turns on then off very fast 2 ms 5 Volts 0 Volts (Arduino PWM base frequency is approx 490 Hz, 980Hz on pins 5, 6) Initially HIGH until button is pushed, then LOW Initially LOW until button is pushed, then HIGH Either circuit only draws 0.5 ma Logic set by path of least resistance What defines a 1 or 0 ? Logic circuits will register a “0” for voltages from 0 to about 0.8 volts. Logic circuits will register a “1” for voltages from 2 to 5 volts. (some sources quote 3v) Notice there is a dead-band where the logic level is questionable. Stay out of there in your designs. Supplies that can’t hold up the current will cause voltage sag that can reach a point where logic gets faulty Switch bounce caught in the act 0.1ms Debounce is handled here in software. Debounce can also be handled in hardware. The 74HLS279 was specifically designed to do this task. Use button to select different LED colors. int Pot values from the serial interface