Pulse-Width Modulation: Simulating variable DC output

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 8 Pulse Width Modulation (PWM)
Advertisements

Lab7: Introduction to Arduino
Intermediate Electronics and Lilypad Where Electronics Meet Textiles Workshop with Lynne Bruning and Troy Robert Nachtigall Sponsored by Spark Fun and.
Servo Background Servos provide control of rotary position Servos are used extensively in the remote control hobby world for: Aircraft (flaps, ailerons,
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
What is Arduino?  Arduino is a ATMEL 168 micro-controller kit designed specially for small projects  User friendly IDE(Integrated Development Environment)
Basic DC Motor Circuits
Re-programming the Simon Says with Arduino Linz Craig, Brian Huang.
Introduction to Arduino Programming January MER-421:Mechatronic System Design.
Intro to Arduino with LilyPad Make a MakerSpace, Artisan’s Asylum Linz Craig, Chris Taylor, Mike Hord & Joel Bartlett.
ELCT 201 week 13 Analog ON/OFF control system conversion to Digital ON/OFF control system.
Living with the Lab Using servos with an Arduino EAS 199A Fall 2011.
Secret Door Knock Detector
Digital I/O Connecting to the Outside World
Introduction.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
Lecture 9: Microcontrollers – part 1 BJ Furman 29OCT2012.
Microcontroller Hands-on Workshop #3 Ahmad Manshad New Mexico State University Institute of Electrical and Electronics Engineers November 7, 2009.
PWM Circuit Based on the 555 Timer. Introduction In applications LED Brightness Control we may want to vary voltage given to it. Most often we use a variable.
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.
BM-305 Mikrodenetleyiciler Güz 2015 (3. Sunu) (Yrd. Doç. Dr. Deniz Dal)
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.
Arduino Circuits and Code. int ledPin = 9; void setup() { pinMode(ledPin, OUTPUT); } void loop() { digitalWrite(ledPin, LOW); delay(1000); digitalWrite(ledPin,
Lecture 10: Peripherals Bryan Burlingame 04 November 2015.
Microcontroller Applications ELEC 421 Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
Rebecca Bruce and Susan Reiser, May 2015 Analog Input and Output.
Photoresistor resistance changes dramatically with light level living with the lab Using Photoresistors with an Arduino © 2011 LWTL faculty team.
PWM: Pulse Width Modulation © 2014 Project Lead The Way, Inc.Digital Electronics.
Analog Output Materials: animatronic head Processing Quiz HW: code links.
MICROCONTROLLER INTERFACING WITH STEPPER MOTOR MADE BY: Pruthvirajsinh Jadeja ( ) COLLEGE:DIET BRANCH:EC.
ME 120: User-defined functions: average analog input reading Arduino Programming – Part 5: User-defined functions ME 120 Mechanical and Materials Engineering.
Microcontroller basics Embedded systems for mortals.
Lecture 9: Introduction to Arduino Topics: Arduino Fundamentals, Bean Date: Mar 22, 2016.
ME 120: Arduino Programming Arduino Programming Part II ME 120 Mechanical and Materials Engineering Portland State University
Arduino + Bluetooth TYWu. Connection Arduino + Bluetooth Module.
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot simple example program to control a DC-Motor Next - Press the button (left)
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).
Intro to Arduino Basic Arduino John Wolf (WolfDenElectronics.com)
ME 120: Arduino PWM Breathing LED Code: Implementation on Arduino ME 120 Mechanical and Materials Engineering Portland State University
Microcontroller basics Embedded systems for mortals.
Pulse Width Modulation Instructor Dr Matthew Khi Yi Kyaw.
Arduino Application: Speed control of small DC Motors
ME 120: Photoresistors and Arduino Programming Arduino Programming Case Study: Photoresistor Measurements ME 120 Mechanical and Materials Engineering Portland.
1 Microcontrollers. 2 Programmers work in the virtual world Machinery works in the physical world Microcontrollers connect the virtual and physical world.
BM-305 Mikrodenetleyiciler Güz 2016 (3. Sunu)
simple example program to control a DC-Motor
Outline Introduction to digital-to-analog converter (DAC)
Scrolling LCD using Arduino.
CU ATLAS Practical electronics Motion and Servos
Microcontroller basics
Week 6: Style and Peripherals
Intro to the Arduino Created by
Microcontroller basics
Lab 1: Arduino Basics Topics: Arduino Fundamentals, First Circuit
Arduino Part 1 Topics: Microcontrollers Programming Basics
Въведение в Arduino.
Arduino - Introduction
Control the color and brightness of an RGB LED with a Potentiometer
Control a motors angular position with a flex sensor
‘SONAR’ using Arduino & ultrasonic distance sensor
Analog Input through POT
What is an Arduino ? Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Arduino Application: Speed control of small DC Motors
Arduino : Introduction & Programming
Sensors and actuators Sensors Resistive sensors
UNIT 11: RC-SERVOMOTOR CONTROL
UNIT 5 Analog signals.
Pulse-Width Modulation: Simulating variable DC output
Presentation transcript:

Pulse-Width Modulation: Simulating variable DC output ME 120 Mechanical and Materials Engineering Portland State University http://web.cecs.pdx.edu/~me120

Motivation Arduino Uno boards do not have arbitrary voltage output Pulse-Width Modulation (PWM) is a common technique for supplying variable power to “slow” electrical devices such as LEDs and DC motors PWM is easy to implement and greatly extends the range of control applications with microcontrollers in general and Arduinos in particular

PWM is a variable width pulse train The frequency of pulses is fixed The width of the pulse is variable The ratio 0/c is called the duty cycle

PWM can act as a variable voltage If a PWM signal is supplied to a “slow” device, the effective voltage is Examples of “slow” devices LED: because our eyes are slow DC motors: because of inertia and inductive energy storage “Slow” means that the frequency of the PWM pulse train is much faster than the response time of the device

Varying the duty cycle produces variable Veff

analogWrite(…) produces variable Veff http://arduino.cc/en/Reference/AnalogWrite http://arduino.cc/en/Tutorial/PWM

Arduino Uno Pins 3, 5, 6, 9, 10, 11 for PWM The ~ before the pin number indicates PWM capability http://arduino.cc/en/Reference/AnalogWrite http://arduino.cc/en/Tutorial/PWM

PWM output is analogWrite( pin, dutyCycle ) pin = one of 3, 5, 6, 9, 10, 11 dutyCycle is an unsigned 8-bit value 0 ≤ dutyCycle ≤ 255 int PWM_pin = 5; // Digital I/O pin must have PWM capability // Pins 3, 5, 6, 9, 10, 11 on Arduino Uno can do PWM void setup() { pinMode(PWM_pin, OUTPUT); // Configure I/O pin for high current output } void loop() { int duty = 127; // Duty cycle must be in range 0 <= duty <= 255 analogWrite(PWM_pin, duty); // Adjust duty cycle of output pin http://arduino.cc/en/Reference/AnalogWrite http://arduino.cc/en/Tutorial/PWM

Example: PWM control of LED brightness Connect a potentiometer to Analog Pin 1 Connect an LED circuit to Digital Pin 10

Arduino code // File: LED_dimmer.ino // // Use a potentiometer to control the brightness of an LED. // Voltage supplied to the LED is a PWM signal w/ variable duty cycle. int LED_pin = 10; // Digital I/O pin must have PWM capability // Pins 3, 5, 6, 9, 10, 11 on Arduino Uno can do PWM void setup() { pinMode(LED_pin, OUTPUT); // Configure I/O pin for high current output Serial.begin(9600); // Open serial monitor for diagnostic messages } void loop() { int duty, pot_reading, pot_pin=1; pot_reading = analogRead(pot_pin); // Get potentiometer setting duty = map(pot_reading, 0, 1023, 0, 255); // map 0-1023 to 0-255 duty = constrain(duty, 0, 255); // Make sure 0 <= duty <= 255 analogWrite(LED_pin, duty); // Adjust duty cycle of output pin // -- Print potentiometer reading and scaled delay as a diagnostic // Printing values does not affect operation of the code. Serial.print("Potentiometer = "); Serial.print(pot_reading); Serial.print(" Duty cycle = "); Serial.println(duty);