Arduino Week 2 Lab ECE 1020 Prof. Ahmadi.

Slides:



Advertisements
Similar presentations
Sensing and Control.
Advertisements

EMS1EP Lecture 8 Pulse Width Modulation (PWM)
Lab7: Introduction to Arduino
Servo Background Servos provide control of rotary position Servos are used extensively in the remote control hobby world for: Aircraft (flaps, ailerons,
Servos The material presented is taken from a variety of sources including:
Servos The material presented is taken from a variety of sources including:
Living with the Lab Using servos with an Arduino EAS 199A Fall 2011.
Secret Door Knock Detector
Working with Arduino: Lesson #2: Variable, Photo, and Force Sensitive Resistors EGN1007.
Introduction.
Introduction to Arduino Prepared by R. Lamond.  “Arduino is an open-source electronics prototyping platform based on flexible, easy- to-use hardware.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
1 Servo Motor. 2 Overview A servo motor is a motor that is only capable of rotating 180 degrees A servo motor is controlled by giving it an angle to proceed.
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
Basic Circuits – Lab 2 Arduino and Sensors
Dean Brock, Rebecca Bruce and Susan Reiser, CCSC SE 2009 Using Arduino Material taken from Todbot blog Bionic Arduino Todbot blog Bionic ArduinoTodbot.
PING))) Ultrasonic Distance Sensor living with the lab ultrasonic pressure waves from PING))) speaker The PING))) sensor emits short bursts of sound and.
ProtoSnap Introduction to Arduino Casey Haskell, Pete Lewis, David Stillman, Jim Lindblom, Pete Dokter, Lindsay Levkoff, Trevor Zylstra.
10/10/ Controlling YOUR ROBOT. 10/10/2015 Basic Stamp  Basic Stamp Input - output pins Interpreter Chip Power supply: 5 Volts voltage Memory: EEPROM.
Arduino Week 2 Lab ECE 1020 Prof. Ahmadi. Objectives 1. Control the rotation of standard servo motor  A standard servo motor is limited in its rotation.
Pulse Width Modulation (PWM). 100% Pulse Width Modulation (PWM) 0% On the chipKIT there are 490 periods per second. Use analogWrite(pin, value) to control.
Servos The material presented is taken from a variety of sources including:
Microprocessors Tutorial 2: Arduino Robotics. Agenda 1. Robot Anatomy 2. Sensor Review 3. PWM 4. MAKE: Fade 5. Motors 6. H Bridge 7. Robot Control library.
ARDUINO 1. Basics  Comments  /* * Blink * * The basic Arduino example. Turns on an LED on for one second, * then off for one second, and so on... We.
Line following tips photoresistors positioned near floor photoresistor circuits © 2011 LWTL faculty team living with the lab.
ME 120: User-defined functions: average analog input reading Arduino Programming – Part 5: User-defined functions ME 120 Mechanical and Materials Engineering.
1 Introduction to Haptics Introduction to the Hapkit board Allison M. Okamura Stanford University.
Istituto Tecnico Industriale A.Monaco EURLAB Control a Servo Motor If you want to swing an robot arm or … steer a robot you need a special motor (Servo).
Pulse-Width Modulation: Simulating variable DC output
Pulse Width Modulation Instructor Dr Matthew Khi Yi Kyaw.
Harpeth Hall Jan 2016 Introduction to Arduino Prepared for Harpeth Hall Winterim January 2016.
Microcontrollers & Electronics Basics OR…
Introduction to Motors, servos and steppers
Controlling Servos with the Arduino
Outline Introduction to digital-to-analog converter (DAC)
Microcontroller basics
If you want to swing an robot arm or …
Week 6: Style and Peripherals
Introduction to Servos
Arduino Programming Part II
UCD ElecSoc Robotics Club 2017/2018
Servos The material presented is taken from a variety of sources including:
Arduino Part 1 Topics: Microcontrollers Programming Basics
INC 161 , CPE 100 Computer Programming
Arduino - Introduction
Arduino Uno and sensors
Control a motors angular position with a flex sensor
‘SONAR’ using Arduino & ultrasonic distance sensor
Servos The material presented is taken from a variety of sources including:
Analog Input through POT
Roller Coaster Design Project
Servos The material presented is taken from a variety of sources including:
Controlling YOUR ROBOT
CS4101 Introduction to Embedded Systems Lab 8: Arduino DAC and PWM
Secret Door Knock Detector
EET 2261 Unit 12 Controlling Stepper Motors and Servos
Arduino : Introduction & Programming
Programming 2: The Arduino IDE & First Sketches
Arduino Practice: Photoresistors, PWM, Potentiometers, Motors
Assist. Prof. Rassim Suliyev - SDU 2018
Sensors and actuators Sensors Resistive sensors
CTY SAR FCPS Shawn Lupoli, Elliot Tan
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Arduino 7 Segment Display Lab
UNIT 11: RC-SERVOMOTOR CONTROL
Announcements Bring two motors to lab this week.
UNIT 5 Analog signals.
Introduction to Arduinos
Pulse-Width Modulation: Simulating variable DC output
Servo Motor.
Presentation transcript:

Arduino Week 2 Lab ECE 1020 Prof. Ahmadi

Objectives Control the rotation of standard servo motor A standard servo motor is limited in its rotation between 0 and 180 degrees Control the speed of a continuous rotation servo motor based on the light intensity A continuous rotation servo motor can rotate freely without restriction

Introduction to Servos A servo is a small, electrically-driven motor that provides rotary actuation Servos are controlled by using Pulse-Width Modulation (PWM) The duration of a voltage pulse determines how far the shaft will turn (i.e. the angle) Servos will not hold their position indefinitely, so the position pulse must be sent repeatedly The holding force of a servo is determined by it’s torque rating

PWM Generation There are 2 different ways in which you can generate a PWM signal Use the built-in PWM pins on the Arduino where you only need to set the duty cycle Manually generate one by alternating voltage HIGH and LOW with specified delays We will use the manual method since the built-in PWM frequency does not match the servo’s expected pulse timing

Part 1 – Controlling Servo Rotation (Manual PWM) int servoPin = 4; //variable to store the servo pin number int pulse = 700; //variable to store the pulse duration void setup() { pinMode(servoPin, OUTPUT); //set the servo pin as an output Serial.begin(9600); //set serial data transfer rate } void loop() digitalWrite(servoPin, HIGH); //send 5V to the servo delayMicroseconds(pulse); //for pulse microseconds digitalWrite(servoPin, LOW); //send 0V to the servo delay(20); //for 20 milliseconds You can change the duration of the pulse to vary the servo’s rotation angle.

Part 1 Schematic (Manual PWM) Standard servo

Part 1 Board Layout Servo motor Pin 4 5V Servo connector Ground

How to read a light sensor [What is a light sensor?] The light sensor we are using is the same one we used when working with the Lego Botball robotics kit. Light sensor is a photoresistor, also known as a light dependent resistor. A photoresistor is a sensor whose resistance varies with light intensity. Most decrease in resistance as the light intensity increases.

How to read a light sensor [How to connect it?] The sensor is connected in series with a resistor Both of which are between the +5V terminal of the Arduino and the Ground terminal They form a Voltage Ladder The data we want comes from the voltage at the point of connection between the sensor and resistor [This is what will change in response to light]

Reading the Light Sensor int sensorPin = A0; //variable to set the sensor input pin int sensorValue = 0; void setup() { Serial.begin(9600); //set serial data transfer rate } void loop() sensorValue = analogRead(sensorPin); //read the value from the light sensor Serial.print ("Sensor value = "); //print the sensor value to the computer screen Serial.print(sensorValue); Serial.println(";"); //"printLN" creates a new line On your keyboard, press “Ctrl+Shift+M” after uploading your program to open the serial communication dialog.

Light Sensor Schematic

Board Layout 5V Pin A0 Light sensor Light sensor connector Resistor Ground

Now let’s combine the light sensor with a servo motor to build a light-sensitive servo that rotates at speeds proportional to the light intensity.

Part 2 – Controlling Servo Rotation Speed as a Function of Light Intensity (1) int sensorPin = A0; //variable to set the sensor input pin int outPin = 5; //variable to store the output pin int sensorValue = 0; //variable to store the value coming from the sensor int m = 0; //variable to store the motor signal (i.e. the voltage) //voltage controls the speed of a continuous servo void setup() { Serial.begin(9600); //set serial data transfer rate pinMode(outPin, OUTPUT); //set the output pin as an output } Continued on next slide…

Part 2 – Controlling Servo Rotation Speed as a Function of Light Intensity (2) void loop() { sensorValue = analogRead(sensorPin); //read the value from the light sensor Serial.print ("Sensor value = "); //print the sensor value to the computer screen Serial.print(sensorValue); Serial.print(";"); analogWrite(outPin, 50); //send pulse to servo delay(200); //constant high pulse duration analogWrite(outPin, 0); delay(sensorValue); //low pulse duration changes according to sensor reading }

Part 2 Schematic Continuous rotation servo

Part 2 Board Layout Light sensor connector Light sensor Pin A0 5V Servo connector Resistor Servo motor Pin 5 Ground

Command Reference pinMode(pin,mode) – configures the pin to behave either as an input or an output Serial.begin(speed) – sets the data transfer rate for serial communication digitalWrite(pin,value) – sets the specified pin’s voltage to HIGH (5V) or LOW (0V) delay(ms) – pauses the program for the specified amount of time in milliseconds analogRead(pin) – reads the value from the specified pin; maps voltage from 0V to 5V into integer values between 0 and 1023 map(value, fromLow, fromHigh, toLow, toHigh) – maps the values in the from range to the to range Serial.print() – writes data to the computer in ASCII text format http://arduino.cc/en/Reference/HomePage