HAW-Arduino. Sensors and Arduino F. Schubert HAW - Arduino 1

Similar documents
FABO ACADEMY X ELECTRONIC DESIGN

Assignments from last week

Attribution Thank you to Arduino and SparkFun for open source access to reference materials.

MAKEVMA502 BASIC DIY KIT WITH ATMEGA2560 FOR ARDUINO USER MANUAL

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Labs Introduction to Arduino

Arduino Digital Out_QUICK RECAP

Learning Objectives. References 10/26/11. Using servos with an Arduino. EAS 199A Fall 2011

Using Servos with an Arduino

Arduino STEAM Academy Arduino STEM Academy Art without Engineering is dreaming. Engineering without Art is calculating. - Steven K.

Disclaimer. Arduino Hands-On 2 CS5968 / ART4455 9/1/10. ! Many of these slides are mine. ! But, some are stolen from various places on the web

Coding with Arduino to operate the prosthetic arm

Lab 2: Blinkie Lab. Objectives. Materials. Theory

Lecture 4: Basic Electronics. Lecture 4 Brief Introduction to Electronics and the Arduino

Mechatronics Engineering and Automation Faculty of Engineering, Ain Shams University MCT-151, Spring 2015 Lab-4: Electric Actuators

Arduino: Sensors for Fun and Non Profit

THE INPUTS ON THE ARDUINO READ VOLTAGE. ALL INPUTS NEED TO BE THOUGHT OF IN TERMS OF VOLTAGE DIFFERENTIALS.

DASL 120 Introduction to Microcontrollers

Lecture 6. Interfacing Digital and Analog Devices to Arduino. Intro to Arduino

J. La Favre Using Arduino with Raspberry Pi February 7, 2018

List of Items Available in the Laboratory the Lab

Arduino

Programming a Servo. Servo. Red Wire. Black Wire. White Wire

Arduino. AS220 Workshop. Part II Interactive Design with advanced Transducers Lutz Hamel

The µbotino Microcontroller Board

I2C Demonstration Board I 2 C-bus Protocol

introduction to Digital Electronics Install the Arduino IDE on your laptop if you haven t already!

The Robot Builder's Shield for Arduino

Introduction to. An Open-Source Prototyping Platform. Hans-Petter Halvorsen

Preface. If you have any problems for learning, please contact us at We will do our best to help you solve the problem.

INA169 Breakout Board Hookup Guide

Electronic Components

Computational Crafting with Arduino. Christopher Michaud Marist School ECEP Programs, Georgia Tech

Workshops Elisava Introduction to programming and electronics (Scratch & Arduino)

100UF CAPACITOR POTENTIOMETER SERVO MOTOR MOTOR ARM. MALE HEADER PIN (3 pins) INGREDIENTS

CONSTRUCTION GUIDE Robotic Arm. Robobox. Level II

Arduino An Introduction

PIC Functionality. General I/O Dedicated Interrupt Change State Interrupt Input Capture Output Compare PWM ADC RS232

Lab 5: Arduino Uno Microcontroller Innovation Fellows Program Bootcamp Prof. Steven S. Saliterman

Sten-Bot Robot Kit Stensat Group LLC, Copyright 2013

Lab 06: Ohm s Law and Servo Motor Control

Intelligent Systems Design in a Non Engineering Curriculum. Embedded Systems Without Major Hardware Engineering

Objectives: Learn what an Arduino is and what it can do Learn what an LED is and how to use it Be able to wire and program an LED to blink

Index. n A. n B. n C. Base biasing transistor driver circuit, BCD-to-Decode IC, 44 46

RT-21 Az-El Controller Manual addendum to RT-21 - August 5, 2014

Using Transistors and Driving Motors

Breadboard Arduino Compatible Assembly Guide

VMA502 BASIC DIY KIT WITH ATMEGA2560 FOR ARDUINO USER MANUAL

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

TLE9879 EvalKit V1.2 Users Manual

Programming 2 Servos. Learn to connect and write code to control two servos.

Arduino Microcontroller Processing for Everyone!: Third Edition / Steven F. Barrett

LED + Servo 2 devices, 1 Arduino

For this exercise, you will need a partner, an Arduino kit (in the plastic tub), and a laptop with the Arduino programming environment.

ZX Distance and Gesture Sensor Hookup Guide

Lesson 3: Arduino. Goals

CONSTRUCTION GUIDE IR Alarm. Robobox. Level I

ASCOM EF Lens Controller

USER MANUAL FOR THE LM2901 QUAD VOLTAGE COMPARATOR FUNCTIONAL MODULE

You'll create a lamp that turns a light on and off when you touch a piece of conductive material

AVL-10000T AUDIO VIDEO LINK TRANSMITTER TECHNICAL MANUAL

CPSC 226 Lab Four Spring 2018

Rodni What will yours be?

Controlling DC Brush Motor using MD10B or MD30B. Version 1.2. Aug Cytron Technologies Sdn. Bhd.

Hardware and software resources on the AVR family for the microcontroller project

URM37 V3.2 Ultrasonic Sensor (SKU:SEN0001)

Servo Sweep. Learn to make a regular Servo move in a sweeping motion.

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

APDS-9960 RGB and Gesture Sensor Hookup Guide

ME 461 Laboratory #5 Characterization and Control of PMDC Motors

LAB 1 AN EXAMPLE MECHATRONIC SYSTEM: THE FURBY

EEL5666C IMDL Spring 2006 Student: Andrew Joseph. *Alarm-o-bot*

Introduction to the Arduino Kit

PART 1: DESCRIPTION OF THE DIGITAL CONTROL SYSTEM

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

.:Twisting:..:Potentiometers:.

Sweep / Function Generator User Guide

SGD 70-A 7 PanelPilotACE Compatible Display

Available online Journal of Scientific and Engineering Research, 2018, 5(4): Research Article

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

Module: Arduino as Signal Generator

Motor Control Development Kit

Analog Feedback Servos

Embedded Systems & Robotics (Winter Training Program) 6 Weeks/45 Days

La Malinette is an open source project by Reso-nance Numérique Programming Interactivity Kit

Figure 1. Digilent DC Motor

Analog Servo Drive 20A20

3.3V regulator. JA H-bridge. Doc: page 1 of 7

Prelab: Introduction and Greenhouse Construction

InnobotTM User s Manual

ARDUINO / GENUINO. start as professional

CONSTRUCTION GUIDE Capacitor, Transistor & Motorbike. Robobox. Level VII

Professional Development Board (#28138)

TWEAK THE ARDUINO LOGO

Microcontrollers and Interfacing

Touch Potentiometer Hookup Guide

Servo click. PID: MIKROE 3133 Weight: 32 g

SGD 70-A 7 PanelPilotACE Compatible Display

RX23T inverter ref. kit

PLAN DE FORMACIÓN EN LENGUAS EXTRANJERAS IN-57 Technology for ESO: Contents and Strategies

Design with Microprocessors Year III Computer Science 1-st Semester

Transcription:

HAW-Arduino Sensors and Arduino 14.10.2010 F. Schubert HAW - Arduino 1

Content of the USB-Stick PDF-File of this script Arduino-software Source-codes Helpful links 14.10.2010 HAW - Arduino 2

Report for the Tasks Description Datasheets Schematics Calculations Source-codes with comments Documentation of the results 14.10.2010 HAW - Arduino 3

First Steps Introduction Hardware and software Installation of the environment The first Arduino-program Inputs and outputs Voltmeter Thermometer Piezo sensor Servo-motor 14.10.2010 HAW - Arduino 4

The Hardware HAW-Arduino USB-Board Breadboard small Breadboard big USB cable Piezo-buzzer Potentiometer Switches LEDs Transistor Resistors Photoresistor Photodiode LCD-module NTC Operational amplifier Comparator Wires Cables Soldering equipment Socket strips Connectors Experimentation board Relay IR-transmitter 14.10.2010 HAW - Arduino 5

What means Arduino? Hardware Programming-software Community 14.10.2010 HAW - Arduino 6

Hardware Cheap, fast and open AVR ATmega 168 (328) Microcontroller C-Programming Programming via USB Power supply via USB or external 14.10.2010 HAW - Arduino 7

Arduino Characteristics 16 kbyte EEPROM 1 kbyte RAM 16 MHz Clock Inputs and Outputs 14 digital Inputs/Outputs 6 analog Inputs 6 PWM-Outputs I 2 C-Bus, serial Bus (TX/RX) 14.10.2010 HAW - Arduino 8

Arduino Duemilanove Board LED at Pin 13 Digital Inputs and Outputs USB Connector TX / RX LEDs Reset Button Power LED Microcontroller External Power Supply Analog Inputs 14.10.2010 HAW - Arduino 9

Arduino Duemilanove Schematic 14.10.2010 HAW - Arduino 10

Arduino-Software Verify (Compile) Stop New Serial Monitor ON Upload to I/O Board Open Save Status Field Status Messages 14.10.2010 HAW - Arduino 11

Installation Unzip of the Arduino-software Connection of the Arduino-board Installation of the drivers (administrator rights needed) Reboot the computer Run the Arduino-software Go on.. 14.10.2010 HAW - Arduino 12

Unzip the Arduino-Softwae 14.10.2010 HAW - Arduino 13

Connection of the Arduino-Board LED at Pin 13 blinks Power LED is on 14.10.2010 HAW - Arduino 14

Driver Installation 14.10.2010 HAW - Arduino 15

Selecting the COM-Port 14.10.2010 HAW - Arduino 16

Selecting the Board 14.10.2010 HAW - Arduino 17

Status-Messages Upload done Wrong serial port Wrong board 14.10.2010 HAW - Arduino 18

Troubleshooting Press the reset-button on Arduino and try again Check the serial port (Connection and number) Read the red text (Debugging output) at the bottom to determine the problem The status area shows what is wrong 14.10.2010 HAW - Arduino 19

Cycle of Development EDIT UPLOAD COMPILE UPLOAD COMPILE YES ERROR? UPLOAD YES ERROR? YES ERROR? RUN 14.10.2010 HAW - Arduino 20

Declaration of variables Program-Structure int ledpin = 13; // LED connected to digital pin 13 Initialization setup( ) Set the inputs and outputs void setup() { pinmode(ledpin, OUTPUT); } Main program loop( ) Loop without end // run once, when the sketch starts // sets the digital pin as output void loop() { digitalwrite(ledpin, HIGH); delay(1000); digitalwrite(ledpin, LOW); delay(1000); } // run over and over again // sets the LED on // waits for a second // sets the LED off // waits for a second 14.10.2010 HAW - Arduino 21

The blinking LED 14.10.2010 HAW - Arduino 22

Program Examples 14.10.2010 HAW - Arduino 23

Hardware HAW-Arduino Small Breadboard Big Breadboard 14.10.2010 HAW - Arduino 24

Solderless Breadboard Not connected All connected All connected Group of 5 connected HAW - Arduino 14.10.2010 HAW - Arduino 25

Preparing special pins Turn pin by 90!!! 14.10.2010 HAW - Arduino 26

Hardware-Box Cables Wires LEDs IR-Transmit. IR-Receiver Switches Pots Relay BD139 LM311 TL072 1N4001 Buzzer Piezo-Ele. Photo-Res. NTC Resistors DC-Motor Battery Battery-Clip 14.10.2010 HAW - Arduino 27

Hardware 14.10.2010 HAW - Arduino 28

Hardware 14.10.2010 HAW - Arduino 29

Power Supply From USB (Current is limited to 500 ma) External power supply (Duemilanove switches automatically) (V IN and GND or power jack) SMPS Battery Diecimila Jumper to EXT 14.10.2010 HAW HAW --Arduino 30

Rules for the Development First draw the circuit Program the Arduino before you connect the inputs and outputs! If you have different power supplies connect the different GNDs if necessary Connect and test the circuit on the solderless board before you connect it to the Arduino Connect the power supplies when the circuit is complete and tested 14.10.2010 HAW - Arduino 31

Digital and Analog Input/Output Digital I/O pinmode(pin, mode) digitalwrite(pin, value) int digitalread(pin) Analog I/O analogreference(type) int analogread(pin) analogwrite(pin, value) - initialization - initialization - PWM HAW - Arduino 14.10.2010 32

Digital Output Make an external LED at pin 6 blinking V CC (from USB) Arduino Board Pin 6 220 Ω GND Write a program for a traffic light with 3 LEDs V CC (from USB) Arduino Board Pin 6 Pin 5 Pin 4 GND 14.10.2010 33 HAW - Arduino

Digital Input A digital input floats between 0 and 5 V, if it is not connected A resistor pulls an input to 5V (pull up) or to GND (pull down) Using a pullup-resistor the switch pushes the input to GND Using a pulldown-resistor the switch pushes the input to 5 V 14.10.2010 HAW - Arduino 34

Digital Input Pullup-resistor Pulldown-resistor V CC Arduino Board Digital Input V CC Arduino Board Digital Input GND GND 14.10.2010 HAW - Arduino 35

Tasks for Digital Input Connect a switch to pin 2 of the Arduino The switch controls the function of the traffic light: High: Low: Normal function Yellow light blinking 14.10.2010 HAW - Arduino 36

Digital Output expanded Maximum of an ATmega8 output: 5 V and 40 ma The output can be expanded by a relay or a transistor: Relay: Transistor: 5 V type Emitter to GND Base resistor 14.10.2010 HAW - Arduino 37

Tasks for Digital Output expanded Connect the 12 V motor to pin 6 of the Arduino first over a relay and then over a npn-transistor (BD 139). For the motor use an external supply voltage (don t forget to connect the different GNDs!). Switch the motor on and off by a switch at pin 11 of the Arduino. The base resistor of the transistor is 1 kω. Protect the Arduino and the transistor by a protective diode! 14.10.2010 HAW - Arduino 38

+12 V V CC (from USB) 1N4001 M 4,7 kω Arduino Board 5 V Pin 11 Pin 6 GND 14.10.2010 HAW - Arduino 39

+12 V V CC (from USB) M 1N4001 4,7 kω Arduino Board 5 V 1 kω Pin 6 BD139 Pin 11 GND 14.10.2010 HAW - Arduino 40

PWM Output Pulse Width Modulation Characteristics: Pulse width range Pulse period Voltage levels HIGH level LOW width period Average is like an analog voltage U AV U AV = width/period *(HIGH LOW) + LOW For PWM use the analogwrite() instruction HAW - Arduino 14.10.2010 41

Analog Input The ATmega 168 has 6 ADC inputs The maximum input range is from 0 V to 5 V The resolution is 10 bit (1024 values) The reference voltage is variable 14.10.2010 HAW - Arduino 42

The ADC of the Arduino Determine the function: SerialOut = f(u IN, U REF ) 0 U IN U REF U REF : 1.1 V, 3.3 V and 5 V analogreference(type) Description Configures the reference voltage used for analog input. The analogread() function will return 1023 for an input equal to the reference voltage. The options are: DEFAULT: the default analog reference of 5 volts. INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 and 2.56 volts on the ATmega8. EXTERNAL: the voltage applied to the AREF pin is used as the reference. Parameters type: which type of reference to use (DEFAULT, INTERNAL, or EXTERNAL). 14.10.2010 HAW - Arduino 43

External U REF 4,7 KΩ 3,3 V HAW - Arduino 14.10.2010 44

Characteristics of the Voltmeter High-impedance input Input-range: -5 V to + 5 V U REF = 5 V Output on LCD : + 2. 7 3 V - 8 7 6 m V 14.10.2010 HAW - Arduino 45

Blockdiagram of the Voltmeter U IN Pre-Amp Arduino LCD HAW - Arduino 14.10.2010 HAW - Arduino 46

Pre-Amplifier (Level-Shifter) 14.10.2010 HAW - Arduino 47

Calculation of the PreAmp 14.10.2010 HAW - Arduino 48

Pre-Amplifier (Level-Shifter) 14.10.2010 HAW - Arduino 49

Protection Circuit 5 V Arduino Board 1 KΩ BAT 85 Pin 2 U OUT BAT 85 470 nf 14.10.2010 HAW - Arduino 50

Connection of the LCD-Module 14.10.2010 HAW - Arduino 51

Pins of the Adaptor LCD-Module 24-Pin-Socket Description Symbol 1 12 GND VSS 2 24 + 5 V VDD 3 N.C. Contrast 0,3 1,2 V VEE 4 4 H = Data / L = Command RS 5 5 H = Read / L = Write R/W 6 6 Enable E 7 N.C. LSB (8 Bit) D0 8 N.C. D1 9 N.C. D2 10 N.C. D3 11 14 LSB (4 Bit) D4(D0) 12 15 D5(D1) 13 16 D6(D2) 14 17 MSB D7(D3) 14.10.2010 HAW - Arduino 52

Program Example for the LCD-Module LiquidCrystal Library This library allows an Arduino board to control LiquidCrystal displays (LCDs) based on the XXX chipset, which is found on most text-based LCDs. The library works with in either 4- or 8- bit mode (i.e. using 4 or 8 data lines in addition to the rs, rw, and enable control lines). Note: We use 4-bit mode. Function LiquidCrystal() clear() home() setcursor() write() print() 14.10.2010 HAW - Arduino 53

The Voltmeter Power Supply Input Voltage Generation of the Input Voltage Protection Circuit Pre-Amplifier Arduino and Display 14.10.2010 HAW - Arduino 54

14.10.2010 HAW - Arduino 55

Characteristics of the Thermometer NTC: Temperature / C Resistor / kω 0 27,25 50 4,162 100 0,949 Input-range: 0 C to 100 C Buzzer alarm, if temperature encreases 90 C Output on LCD : 4 2 C 1 0 8 F 14.10.2010 HAW - Arduino 56

Tasks for the Thermometer Download the datasheet of the NTC-resistor Linearize the characteristic of the NTC in the range from 0 C to 100 C by connecting a serial resistor R L = R 50 of the NTC. Develop the resulting characteristic Substitute the resulting characteristic by a straight line m T = f(θ) m L R Θ R Θ R L HAW - Arduino 14.10.2010 57

14.10.2010 HAW - Arduino 58

V CC (from USB) 5 V Arduino Board 7 LCD-Module R L Pin 2 NTC GND 14.10.2010 HAW - Arduino 59

Tasks for Analog Input and PWM Output Dimm an LED with a potentiometer Check the function of the multicolour LED Write a program for controlling the colour of the multicolour LED with a potentiometer Control the rpm of the DC-motor with a potentiometer Sense the dark with the photoresistor Write a program for the piezo buzzer to play a melody 14.10.2010 HAW - Arduino 60

Notes note frequency/hz period/μs c 261 3830 d 294 3400 e 329 3938 f 349 2864 g 392 2550 a 440 2272 b 493 2038 C 523 1912 14.10.2010 HAW - Arduino 61

+12 V V CC (from USB) M 1N4001 10 kω Arduino Board 5 V 1 kω Pin 6 BD139 Pin 2 GND 14.10.2010 HAW - Arduino 62

V CC (from USB) 5 V Arduino Board 220 Ω R L Pin 2 GND 14.10.2010 HAW - Arduino 63

Piezo Buzzer as Sensor Introduction Piezo buzzers exhibit the reverse piezoelectric effect. The normal piezoelectric effect is generating electricity from squeezing a crystal. Can get several thousand volts, makes a spark Piezo Knock Sensor To read a piezo you can connect it to an analog input, but: - You need to drain off any voltage with a resistor The protection diodes inside the AVR chip protect against the high voltage Tasks Piezo-sensor: input value -> serial out Piezo-sensor: input value -> buzzer frequency 14.10.2010 HAW - Arduino 64

V CC (from USB) 5 V Arduino Board Pin 2 1 MΩ GND 14.10.2010 HAW - Arduino 65

Servo Motor Servos are DC motors with built in gearing and feedback control loop circuitry. Servo Wiring All servos have three wires: Black or Brown is for ground. Red is for power (~4.8-6V). Yellow, Orange, or White is the signal wire (3-5V). Tasks Pot position 0 180 to servo position and LCD Railroad crossing barrier Railroad crossing sign (blinking, beep) 14.10.2010 HAW - Arduino 66

Library for the Servo Motor 1 Servo library This library allows an Arduino board to control RC servo motors. Servos have integrated gears and a shaft that can precisely controlled. Standard servos allow the shaft to be positioned at various angles, usually between 0 and 180 degrees. Continuous rotation servos allow the rotation of the shaft to be set to various speeds. As of Arduino 0017, the Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega. On boards other than the Mega, use of the library disables analogwrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. On the Mega, up to 12 servos can be used without interfering with PWM functionality; use of 12 to 23 motors will disable PWM on pins 11 and 12. In Arduino 0016 and earlier, the Servo library uses functionality built in to the hardware, and works only on pins 9 and 10 (and does not work on the Arduino Mega). In this case, if only one servo is used, the other pin cannot be used for normal PWM output with analogwrite(). For example, in Arduino 0016 and earlier, you can't have a servo on pin 9 and PWM output on pin 10. 14.10.2010 HAW - Arduino 67

Library for the Servo Motor 2 Circuit Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to 5V power supply. The ground wire is typically black or brown and should be connected to a ground pin. The signal pin is typically yellow, orange or white and should be connected to a digital pin on the Arduino board. Note servos draw considerable power, so if you need to drive more than one or two, you need a separate power supply (not the +5V pin on your Arduino!). Functions attach() write() read() attached() detach() 14.10.2010 HAW - Arduino 68

Program Example for the Servo Motor // Sweep // by BARRAGAN <http: //barraganstudio.com> #include <Servo.h> Servo myservo; int pos = 0; void setup() { myservo.attach(9); } // create servo object to control a servo // variable to store the servo position // attaches the servo on pin 9 to the servo object void loop() { for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees { myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } } 14.10.2010 HAW - Arduino 69

V CC (from USB) +5 V 10 kω Arduino Board 5 V Pin 6 orange Servo M red Pin 2 GND brown 14.10.2010 HAW - Arduino 70

The Axis-Counter Develop an axis-counter for the model train using: Infrared emitting LED TSHA 6203 Photodiode SFH203P Comparator LM311 14.10.2010 HAW - Arduino 71