Community College of Allegheny County Unit 4 Page #1. Timers and PWM Motor Control

Similar documents
Community College of Allegheny County Unit 7 Page #1. Analog to Digital

t w = Continue to the next page, where you will draw a diagram of your design.

Module: Arduino as Signal Generator

To design/build monostable multivibrators using 555 IC and verify their operation using measurements by observing waveforms.

Multivibrators. Department of Electrical & Electronics Engineering, Amrita School of Engineering

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

FACTFILE: GCSE Technology and Design

Police Siren Circuit using NE555 Timer

OBJECTIVE The purpose of this exercise is to design and build a pulse generator.

EE283 Electrical Measurement Laboratory Laboratory Exercise #7: Digital Counter

FACTFILE: GCSE Technology and Design

555 Timer and Its Application

Class #6: Experiment The 555-Timer & Pulse Width Modulation

Lab 2 Revisited Exercise

HIGH LOW Astable multivibrators HIGH LOW 1:1

PreLab 6 PWM Design for H-bridge Driver (due Oct 23)

Lab 2: Blinkie Lab. Objectives. Materials. Theory

2.017 DESIGN OF ELECTROMECHANICAL ROBOTIC SYSTEMS Fall 2009 Lab 4: Motor Control. October 5, 2009 Dr. Harrison H. Chin

Pulse Width Modulation and

Written by Hans Summers Wednesday, 15 November :53 - Last Updated Wednesday, 15 November :07

B.E. SEMESTER III (ELECTRICAL) SUBJECT CODE: X30902 Subject Name: Analog & Digital Electronics

CHAPTER 4: 555 TIMER. Dr. Wan Mahani Hafizah binti Wan Mahmud

The Motor sketch. One Direction ON-OFF DC Motor

DEPARTMENT OF ELECTRICAL ENGINEERING LAB WORK EE301 ELECTRONIC CIRCUITS

Application Note AN 102: Arduino I2C Interface to K 30 Sensor

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Lab Timer: Blinking LED Lights and Pulse Generator

Experiment EB2: IC Multivibrator Circuits

EE 3101 ELECTRONICS I LABORATORY EXPERIMENT 9 LAB MANUAL APPLICATIONS OF IC BUILDING BLOCKS

FABO ACADEMY X ELECTRONIC DESIGN

PWM CONTROL USING ARDUINO. Learn to Control DC Motor Speed and LED Brightness

Coding with Arduino to operate the prosthetic arm

PreLab 7: LED Blinker (Due Oct 30)

SCHOOL OF TECHNOLOGY AND PUBLIC MANAGEMENT ENGINEERING TECHNOLOGY DEPARTMENT

PRESENTATION ON 555 TIMER A Practical Approach

Tektronix Courseware. Academic Labs. Sample Labs from Popular Electrical and Electronics Engineering Curriculum

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

ASTABLE MULTIVIBRATOR

Draw in the space below a possible arrangement for the resistor and capacitor. encapsulated components

LM555 and LM556 Timer Circuits

PHYS225 Lecture 18. Electronic Circuits

Operating Manual Ver.1.1

EG572EX: ELECTRONIC CIRCUITS I 555 TIMERS

Government Polytechnic Muzaffarpur Name of the Lab: Applied Electronics Lab

Laboratory Final Design Project. PWM DC Motor Speed Control

Introduction to IC-555. Compiled By: Chanakya Bhatt EE, IT-NU

Analog Electronic Circuits Lab-manual

ZSCT1555 PRECISION SINGLE CELL TIMER ISSUE 2 - MAY 1998 DEVICE DESCRIPTION FEATURES APPLICATIONS SCHEMATIC DIAGRAM

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Touchless Control: Hand Motion Triggered Light Timer

Getting to know the 555

Monitoring Temperature using LM35 and Arduino UNO

Lab 12: Timing sequencer (Version 1.3)

Electronic Instrumentation

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

Ocean Controls KT-5198 Dual Bidirectional DC Motor Speed Controller

Adafruit 16-Channel Servo Driver with Arduino

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

ELEXBO A-Car-Engineering

Comparators, positive feedback, and relaxation oscillators

Arduino Lesson 1. Blink. Created by Simon Monk

ELEC2 (JUN15ELEC201) General Certificate of Education Advanced Subsidiary Examination June Further Electronics TOTAL. Time allowed 1 hour

INTRODUCTION to MICRO-CONTROLLERS

Community College of Allegheny County Unit 8 Page #1. Op-Amps

). The THRESHOLD works in exactly the opposite way; whenever the THRESHOLD input is above 2/3V CC

OSCILLOSCOPES, MULTIMETERS, & STRAIN GAGES

User Guide for the e NABLE Hand Test Rig

transformer rectifiers

Experiment 1.A. Working with Lab Equipment. ECEN 2270 Electronics Design Laboratory 1

Lesson 3: Arduino. Goals

ARDUINO / GENUINO. start as professional

Lab Experiments. Boost converter (Experiment 2) Control circuit (Experiment 1) Power diode. + V g. C Power MOSFET. Load.

T6+ Analog I/O Section. Installation booklet for part numbers: 5/4-80A-115 5/4-90A-115 5/4-80A /4-90A-1224

Welcome to Arduino Day 2016

1. LINEAR WAVE SHAPING

Rodni What will yours be?

02 Digital Input and Output

System Board 6219 MAXREFDES89#: MAX14871 Full-Bridge DC Motor Driver MBED Shield

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

Sten-Bot Robot Kit Stensat Group LLC, Copyright 2013

AN2129 APPLICATION NOTE

40 Amp Digital Bidirectional PWM Motor Controller with Regenerative Braking BIDIR-340-DR

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

Comparators, positive feedback, and relaxation oscillators

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

Experiment No. 2 Half Wave Rectifier using RC-Triggering

Dev Bhoomi Institute Of Technology Department of Electronics and Communication Engineering PRACTICAL INSTRUCTION SHEET REV. NO. : REV.

EE 368 Electronics Lab. Experiment 10 Operational Amplifier Applications (2)

EE 308 Spring S12 SUBSYSTEMS: PULSE WIDTH MODULATION, A/D CONVERTER, AND SYNCHRONOUS SERIAN INTERFACE

Diodes This week, we look at switching diodes, LEDs, and diode rectification. Be sure to bring a flash drive for recording oscilloscope traces.

EE 110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Lab 0: Course Introduction

Embedded Hardware Design Lab4

MODULE TITLE : OPERATIONAL AMPLIFIERS TOPIC TITLE : OSCILLATORS LESSON 2 : RELAXATION OSCILLATORS

Comparators, positive feedback, and relaxation oscillators

Appendix D2 Experiment EB2: IC Multivibrator Circuits. Lab Report (Submit your report on the same day immediately after the experiment)

MD04-24Volt 20Amp H Bridge Motor Drive

Touch Potentiometer Hookup Guide

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

Lab 2.4 Arduinos, Resistors, and Circuits

Transcription:

Community College of Allegheny County Unit 4 Page #1 Timers and PWM Motor Control Revised: Dan Wolf, 3/1/2018

Community College of Allegheny County Unit 4 Page #2 OBJECTIVES: Timers: Astable and Mono-Stable 555 Timers Pulse Width Modulation for Motor Control DELIVERABLES THAT YOU MUST SUBMIT 1. Graphs #1 and #2, Tables #1 and #2 2. Practice Problems On-Line Reading Material: Required: a) http://www.engin.swarthmore.edu/~ejaoudi1/datasheets/555 b) http://www.ocfreaks.com/pulse-width-modulation-pwmtutorial/ Optional: a) How to Build a 555 Timer Mono-stable Circuit: http://www.learningaboutelectronics.com/articles/555-timermonostable-circuit.php b) How to Build a 555 Timer Bi-stable Circuit: c) http://www.learningaboutelectronics.com/articles/555-timerbistable-circuit.php INTRODUCTION TO THE 555 TIMER: The IC 555 has three operating modes: a) Astable (free-running) mode: As per Figure #1, in this mode, the 555 operates as an electronic oscillator where the square wave output frequency is given by the equation: f = 1 0.693 C (R1 + 2R2) Where R1 and R2 are in ohms and C is the value of the capacitor in farads. The High time from each pulse is given by: high = 0.693 C (R1 + R2)

Community College of Allegheny County Unit 4 Page #3 And the Low time from each pulse is given by: low = 0.693 C R2 b) Monostable mode: As per Figure #2, in this mode, the 555 functions as a "one-shot" pulse generator. Once the input on Pin 2 is triggered, the output on Pin 2 will go high for a period of time determined by R and C according to the equation: t = 1.1 RC Where R1 and R2 are in ohms and C is the value of the capacitor in farads. c) Bistable mode or Schmitt trigger: As per Figure #3, the 555 can operate as a flip-flop. Uses include bounce-free latched switches. INTRODUCTION TO PULSE-WIDTH MODULATION (PWM): Pulse-width modulation (PWM) uses digital pulses to generate an analog voltage. A digital output pin may be either high (+5 V) or low (0 V). But what if you switched the pin rapidly between high and low so that it was high half the time and low half the time? As per Figure #5, the average voltage over time would be halfway between 0 and 5 V (2.5 V). PWM emits a burst of ones and zeros whose ratio is proportional to the duty value you specify. The proportion of ones to zeros in PWM is called the duty cycle. The duty cycle controls the analog voltage in a very direct way; the higher the duty cycle the higher the voltage. Duty Cycle is the proportion of ones to zeros output by the PWM command. To determine the proportional PWM output voltage, use this formula: Duty Cycle = Time High per pulse cycle Time per pulse cycle Proportional (Average) Output Voltage = Duty Cycle 5Volts For example, if the duty cycle is 50%, 0.50 x 5V = 2.5V; the PWM will output a train of pulses whose average voltage is 2.5V.

Community College of Allegheny County Unit 4 Page #4 Although we could slow down a motor by wiring it in series to a variable resister using a constant power supply, this approach wastes the power being dropped across the resister. PWM has the advantage in that no power is being wasted across such a resister.

Community College of Allegheny County Unit 4 Page #5 Experiment #1 - Astable (free-running) Timer: 1. Figure #2 shows a typical 555 Astable circuit. EQUIPMENT REQUIRED: CCAC 555 Timer Lab box or the following: a. LED and 330Ω load resister b. R1 = 2000Ω (you may substitute a 10K pot) c. R2 = 2000Ω (you may substitute a 10K pot) d. C = 1uF e. 10nF capacitor f. +5 Volt power supply 2. Connect the circuit shown in Figure #2 and add the LED and 330Ω resister to the output on Pin 3. Calculate the expected frequency, period, time high and time low then update Table #1. Ask the instructor to check the circuit before you apply power! 3. Use the oscilloscope to monitor the output on Pin 3. Assuming that the oscilloscope confirms the expected frequency value, does the LED light? Explain? 4. Use Graph #1 to sketch this waveform and include the voltage level, period and frequency. Update Table #1 5. Calculate new values for R1, R2, and C which will allow you to see the LED blink (i.e. about once per second). Test with the new components and then update Table #1. R1 R2 Calculated 2K 2K 1uF Measured 2K 2K 1uF Calculated Measured Calculated Measured Table #1 C F Period Thigh Tlow Duty Cycle

Community College of Allegheny County Unit 4 Page #6 Experiment #2 - Monostable Timer: 1. Figure #3 shows a typical 555 Monostable circuit. EQUIPMENT REQUIRED: a. Misc. wire b. LED and 330Ω load resister c. R = 10000Ω (ok to substitute a 10K potentiometer) d. C = 100uF e. 10nF capacitor f. +5 Volt power supply 2. Connect the circuit shown in Figure #3. Add the LED and 330Ω resister to the output on Pin 3 and a switch to the trigger input on Pin 2. Calculate the expected pulse time and update Table #2. Ask the instructor to check the circuit before you apply power! 3. Use the oscilloscope to monitor the output on Pin 3 and update Table #2. 4. Use Graph #1 to sketch this waveform showing the voltage level and pulse period and then pdate Table #2. 5. Calculate new values for R and C for a different time period. Test with the new components and then update Table #2. Calculated 10K 100uF Measured 10K 100uF Calculated Measured Calculated Measured Table #2 R C Pulse Period

Community College of Allegheny County Unit 4 Page #7 Experiment #3 555 Pulse Width Modulation: 1. Figure #4 shows a 555 circuit that will generate a PWM duty cycle that will control the brightness of an LED or the speed of a small motor. Figure #5 shows the PWM waveforms that you would expect to see for different power levels. You will need the following parts: a) 555 timer IC b) R1 = 10K variable resistor c) C1 = 10nF capacitor d) C2 = 1uF capacitor e) LED and 330Ω load resister 2. Connect the circuit shown in Figure #4 and add an LED and 330Ω resister to the output on Pins 7 and 8. Ask the instructor to check the circuit before you apply power! 6. Test the circuit while changing the variable resister: use both an oscilloscope and a volt meter to monitor the PWM output to the LED. 7. Use Graph #2 to sketch at least two duty cycles (slow and fast) and include the peak voltage level, proportional PWM output voltage and duty cycle. 8. Figure #6 shows a modified 555 circuit which will drive a bigger motor. This is being shown for information only and you are not asked to build it. Peak Voltage Table #3 Duty Cycle Calculated PWM Voltage Measured PWM Voltage (Volt Meter) Slow Calculated n/a Slow Measured Fast Calculated n/a Fast Measured Calculated n/a Measured Experiment #4 Arduino Pulse Width Modulation:

Community College of Allegheny County Unit 4 Page #8 1. The 555 timer works fine but it requires the assembly of discrete components on a printed circuit board. Using today s technology, engineers would more likely use a microcontroller to perform PWM. In this experiment, you will see how easy it is to use the Arduino to generate a PWM motor signal. You will need the following parts: a. Arduino Uno microcontroller, power supply, cable, and USB Hub. b. AdaFruit Motor Shield v2.3 c. Small 12Volt Dc motor 2. Connect the circuit shown in Figure #7 and #8. Ask the instructor to check the circuit before you apply power! 3. Start the Arduino software: a) Start the Arduino interface by clicking on the file named: DCMotorTest_CCAC.ino b) Specify the correct Arduino serial port from the menu bar: Tools Port COMx (Arduino/Genuine Uno c) Start the serial monitor from the menu bar: Tools Serial Monitor d) Upload the load cell software to the Arduino using the menu bar: Sketch Upload e) Observe that the Serial Monitor window is displaying the startup message. 4. In Mode 1, the motor will ramp up and down in forward then again in reverse. You may change the mode by reassigning the value of intselect_mode which is located near the top of the software file (and then uploading). The other options are shown in the code. 5. Test the circuit while using an oscilloscope and volt meter to monitor the PWM output to the motor. 6. In this experiment, you have seen that PMW can be implemented rather quickly in software with a microcontroller which is also likely to be doing other tasks as well. If you are interested in software and want to explore in more detail, the Arduino supports the use of the AnalogWrite() function to do PWM and is explained here: https://www.arduino.cc/en/reference/analogwrite and https://www.arduino.cc/en/tutorial/secretsofarduinopwm Figure 1 The 555 Timer

Community College of Allegheny County Unit 4 Page #9 Figure 2 555 Astable (Free-running) Timer

Community College of Allegheny County Unit 4 Page #10 Figure 3 555 Monostable Timer +5V 1K ohm Figure 4 555 Timer PWM LED Brightness 555 10K +5V LED C1 C2

Community College of Allegheny County Unit 4 Page #11 Figure 5 PWM Waveforms Figure 6 555 Timer PWM Motor Control

Community College of Allegheny County Unit 4 Page #12 Figure 7 Arduino PWM Motor Control M1 Adafruit Motor Shield v2.3 M M1 Computer USB Arduino Uno External Power Supply Connect a DC motor to motor port 1 - it does not matter which wire goes into which terminal block as motors are bi-directional. Connect to the top two terminal ports, do not connect to the middle pin (GND) See the next photo for the red and blue wire example. Figure 8 Arduino Motor Shield Connections M1 Motor wires Monitor here for excessive heat.

Community College of Allegheny County Unit 4 Page #13 Figure #9 DCMotorTest_CCAC.ino - Arduino PWM Software #include <Mouse.h> /* This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2 It won't work with v1.x motor shields! Only for the v2's with built in PWM control For use with the Adafruit Motor Shield v2 ----> http://www.adafruit.com/products/1438 Requires the Adafruit Motor Library to be installed: Adafruit_Motor_Shield_V2_Librarymaster BE CAREFUL OF THE MOTOR CURRENT!! 3.0A MAX BUT 2.0A REQUIRES A HEATSINK ON THE ARDUINO MAX MOTOR CURRENT SHOULD BE 1.2A PER MOTOR OR LESS!! SMALL MOTORS CAN PULL QUITE HIGH CURRENT LEVELS, ESPECIALLY AT STALL. */ */ #include <Wire.h> #include <Adafruit_MotorShield.h> #include "utility/adafruit_ms_pwmservodriver.h" // Create the motor shield object with the default I2C address Adafruit_MotorShield AFMS = Adafruit_MotorShield(); // Or, create it with a different I2C address (say for stacking) // Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61); // Select which 'port' M1, M2, M3 or M4. In this case, M1 Adafruit_DCMotor *mymotor = AFMS.getMotor(1); // You can also make another motor on port M2 //Adafruit_DCMotor *myothermotor = AFMS.getMotor(2); // Pick one of these to set the mode int iselect_mode = 1; // Varying forward and reverse // int iselect_mode = 2; // forward slow // int iselect_mode = 3; // forward fast // int iselect_mode = 4; // reverse slow // int iselect_mode = 5; // reverse fast void setup() { Serial.begin(9600); // set up Serial library at 9600 bps Serial.println("\nAdafruit Motorshield v2 - DC Motor Test - vjan_12_2017"); Serial.println("High motor current will burn out the Arduino, "); Serial.println("even for small motors or at stall conditions! \n"); AFMS.begin(); // create with the default frequency 1.6KHz //AFMS.begin(1000); // OR with a different frequency, say 1KHz // Set the speed to start, from 0 (off) to 255 (max speed) mymotor->setspeed(150); mymotor->run(forward); // turn on motor mymotor->run(release); void loop() { uint8_t i; delay(2000); switch (iselect_mode) {

Community College of Allegheny County Unit 4 Page #14 case 1: { Serial.print("Forward "); mymotor->run(forward); for (i = 0; i < 255; i++) { mymotor->setspeed(i); delay(10); for (i = 255; i!= 0; i--) { mymotor->setspeed(i); delay(10); Serial.print("Backward "); mymotor->run(backward); for (i = 0; i < 255; i++) { mymotor->setspeed(i); delay(10); for (i = 255; i!= 0; i--) { mymotor->setspeed(i); delay(10); Serial.print("Release "); mymotor->run(release); delay(1000); break; case 2: { Serial.print("Run Forward Slow \n"); mymotor->run(forward); mymotor->setspeed(50); delay(10000); Serial.print("Release \n"); mymotor->run(release); delay(5000); break; case 3: { Serial.print("Run Forward Fast \n"); mymotor->run(forward); mymotor->setspeed(100); delay(10000); Serial.print("Release \n");

Community College of Allegheny County Unit 4 Page #15 mymotor->run(release); delay(5000); break; case 4: { Serial.print("Run Reverse Slow \n"); mymotor->run(backward); mymotor->setspeed(100); delay(10000); Serial.print("Release \n"); mymotor->run(release); delay(5000); break; case 5: { Serial.print("Run Reverse Fast \n"); mymotor->run(backward); mymotor->setspeed(100); delay(10000); Serial.print("Release \n"); mymotor->run(release); delay(5000); break; default: { Serial.print("Invalid Mode Selected - Defaulting to Mode 1 \n\n"); iselect_mode = 1; break;

Community College of Allegheny County Unit 4 Page #16 Graph#1 Astable and Monostable Waveforms

Community College of Allegheny County Unit 4 Page #17 Graph#2 PWM Waveforms

Community College of Allegheny County Unit 4 Page #18 PRACTICE PROBLEMS: 1. Design a 555 mono-stable circuit which provides a 750mS pulse when the input is triggered by a SPST switch. 2. Design a 555 Astable circuit which provides an output signal of 500Hz. 3. Design a 555 Astable circuit which will provide a PWM output voltage of 3.0volts. The entire circuit should be powered by +5volt. Specify the time high, time low, and duty cycle for the output. 4. Research the internet for equations to calculate the Thigh and Tlow for an Astable timer. Apply the equations to Table #1 and compare the results to the measured values. 5. Modify Figure #3 to use the trigger switch configuration shown below. Explain why it will not work. +5V 1K ohm