Electronics 5: Arduino, PWM, Mosfetts and Motors



Similar documents
Experiment 8 : Pulse Width Modulation

Pulse Width Modulation (PWM) LED Dimmer Circuit. Using a 555 Timer Chip

1. Learn about the 555 timer integrated circuit and applications 2. Apply the 555 timer to build an infrared (IR) transmitter and receiver

Basic DC Motor Circuits. Living with the Lab Gerald Recktenwald Portland State University

Basic DC Motor Circuits

Arduino Lesson 13. DC Motors. Created by Simon Monk

CHAPTER 11: Flip Flops

Display Board Pulse Width Modulation (PWM) Power/Speed Controller Module

Your Multimeter. The Arduino Uno 10/1/2012. Using Your Arduino, Breadboard and Multimeter. EAS 199A Fall Work in teams of two!

Physics 120 Lab 6: Field Effect Transistors - Ohmic region

Copyright 2011 Linear Technology. All rights reserved.

Selecting and Implementing H-Bridges in DC Motor Control. Daniel Phan A

PHYS 2P32 Project: MIDI for Arduino/ 8 Note Keyboard

Theory of Operation. Figure 1 illustrates a fan motor circuit used in an automobile application. The TPIC kω AREF.

DC Motor with Shaft Encoder

Microcontroller-based experiments for a control systems course in electrical engineering technology

LAB 7 MOSFET CHARACTERISTICS AND APPLICATIONS

Using Arduino Microcontrollers to Sense DC Motor Speed and Position

More Op-Amp Circuits; Temperature Sensing

A Practical Guide to Free Energy Devices

Cornerstone Electronics Technology and Robotics I Week 15 Voltage Comparators Tutorial

Pulse Width Modulated (PWM) Controller for 12 Volt Motors

Current Loop Tuning Procedure. Servo Drive Current Loop Tuning Procedure (intended for Analog input PWM output servo drives) General Procedure AN-015

IR Communication a learn.sparkfun.com tutorial

Work with Arduino Hardware

Lab E1: Introduction to Circuits

EET272 Worksheet Week 9

Unit 7: Electrical devices LO2: Understand electrical sensors and actuators Sensors temperature the thermistor

RC Circuits and The Oscilloscope Physics Lab X

PLL frequency synthesizer

Electronics. Discrete assembly of an operational amplifier as a transistor circuit. LD Physics Leaflets P

A Digital Timer Implementation using 7 Segment Displays

Application Note AN- 1118

Basic Pulse Width Modulation

Design Project: Power inverter

See Horenstein 4.3 and 4.4

RC & RL Transient Response

DEPARTMENT OF ELECTRONICS ENGINEERING

LM 358 Op Amp. If you have small signals and need a more useful reading we could amplify it using the op amp, this is commonly used in sensors.

Analog Servo Drive 25A8

Lab Experiment 1: The LPC 2148 Education Board

3-Digit Counter and Display

Op-Amp Simulation EE/CS 5720/6720. Read Chapter 5 in Johns & Martin before you begin this assignment.

AUTOMATIC CALL RECORDER JAMECO PART NO

Arduino Lab 1 - The Voltage Divider

Constructing a precision SWR meter and antenna analyzer. Mike Brink HNF, Design Technologist.

ENGINEERING COMMITTEE Interface Practices Subcommittee AMERICAN NATIONAL STANDARD ANSI/SCTE Test Method for AC to DC Power Supplies

Sequential Logic: Clocks, Registers, etc.

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT BIT DIFFERENTIAL ADC WITH I2C LTC2485 DESCRIPTION

ECEN 1400, Introduction to Analog and Digital Electronics

Conversion Between Analog and Digital Signals

Chapter 4: Pulse Width Modulation

Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board

FREQUENCY RESPONSE OF AN AUDIO AMPLIFIER

Table 1 Comparison of DC, Uni-Polar and Bi-polar Stepper Motors

Lab 6 Introduction to Serial and Wireless Communication

Constant Current Electronic Power Supply Load By Jeff K. Steinkamp N7YG April 3, 2012

Design and Construction of Variable DC Source for Laboratory Using Solar Energy

AP-1 Application Note on Remote Control of UltraVolt HVPS

Electrical Resonance

Operational Amplifier - IC 741

Fox-2 MPPT Unit Testing

Micro-Step Driving for Stepper Motors: A Case Study

UPS PIco. to be used with. Raspberry Pi B+, A+, B, and A. HAT Compliant. Raspberry Pi is a trademark of the Raspberry Pi Foundation

Transistor Characteristics and Single Transistor Amplifier Sept. 8, 1997

LABORATORY 2 THE DIFFERENTIAL AMPLIFIER

Iowa State University Electrical and Computer Engineering. E E 452. Electric Machines and Power Electronic Drives. Laboratory #3 Figures of Merit

Robot Board Sub-System Testing. Abstract. Introduction and Theory. Equipment. Procedures. EE 101 Spring 2006 Date: Lab Section # Lab #6

Series AMLDL-Z Up to 1000mA LED Driver

Contents. Document information

Step Response of RC Circuits

SYSTEM 4C. C R H Electronics Design

Welcome to this presentation on LED System Design, part of OSRAM Opto Semiconductors LED 101 series.

Adding Heart to Your Technology

H-Bridge Motor Control

Bi-directional Power System for Laptop Computers

What Is Regeneration?

Electronic WorkBench tutorial

WA Manager Alarming System Management Software Windows 98, NT, XP, 2000 User Guide

AN2680 Application note

GLOLAB Two Wire Stepper Motor Positioner

HIGH VOLTAGE POWER SUPPLY FOR ELECTRO-OPTICS APPLICATIONS

Lab 3: Introduction to Data Acquisition Cards

Arduino Lesson 0. Getting Started

Switch Mode Power Supply Topologies

High voltage power supply (1 to 20 KV)

Kit Watt Audio Amplifier

7-41 POWER FACTOR CORRECTION

Arduino Motor Shield (L298) Manual

Lab 1: The Digital Oscilloscope

Implementing PID Temperature Control Using LabVIEW. Abstract. Introduction

EVAL-UFDC-1/UFDC-1M-16

ABB Drives. User s Manual HTL Encoder Interface FEN-31

Design and Test of Fast Laser Driver Circuits

Lab 7: Operational Amplifiers Part I

EXPERIMENT NUMBER 5 BASIC OSCILLOSCOPE OPERATIONS

Lab 1: Introduction to PSpice

FREQUENCY CONTROLLED AC MOTOR DRIVE

Fundamentals of Signature Analysis

Transcription:

BIOE 123 Module 6 Electronics 5: Arduino, PWM, Mosfetts and Motors Lecture (30 min) Date Learning Goals Learn about pulse width modulation (PWM) as a control technique Learn how to use a Mosfets to control high current drawing loads Learn how to drive basic DC motors and control their speed Learn how to program the arduino in Matlab Lean how to program a simple controller SUMMARY OF TOPICS (actual lecture notes attached as separate document) What is pulse width modulation (PWM)? o Theory o Applications o Why it is useful Generating a PWM signal o Need some circuit/device to generate the signal and vary the duty cycle o Analog options (555, Schmidt trigger ) o Or, use a microcontroller (Arduino has this built in) Driving a load with PWM o Most PWM generated signals can t directly power the load, use a Mosfet as a middle man o Mosfet ~ voltage controlled transistor, can source/sink lots of current o Pull up/pull down resistors and their importance o Demo of LED multi-color dimmer Driving inductive loads o Loads like motors/solenoids have lots of inductance: V = L(dI/dt) o Experience huge voltage spikes when switching rapidly o Use a shunting (kickback) diode to allow the voltage spike to dissipate Programing the Arduino in matlab o Loading the program in the IDE o Command list o Basic Event-Driven structure (while loop, events, services)

Lab Intro (~15 min) Date SUMMARY OF TOPICS Review of PWM signal generation and circuitry Proper circuit layout to avoid noise from high currents (avoiding ground loops) Review of Matlab environment o Commands o Event driven structure o Proportional controller (steady state error) o Bits

Electronics 5: Arduino, PWM, MOSFETs and Motors Problem Set 6 Due: Date at the end of lab. Text: Practical Electronics for Inventors, Scherz Estimated reading time: 0.25 hr for Core reading Learning Goals Learn about pulse width modulation (PWM) as a control technique Learn how to use a Mosfets to control high current drawing loads Lean how to program a simple controller CORE READING http://en.wikipedia.org/wiki/thermistor 4.3.4 Metal oxide semiconductor field-effect transistors (Scherz) 13.1 DC continuous motors (Scherz) 13.2 Speed control of DC motors (Scherz) 13.3 Directional control of DC motors (Scherz) PROBLEMS Problem 1: You want to control the speed of a DC motor with PWM using a function generator and a MOSFET circuit. Draw the basic circuit that will allow you to control the speed of the motor. Assume you have a N-type power MOSFET, a dc motor, any passive components you might need (i.e. resistors, capacitors, diodes etc.) and a working function generator with variable duty cycle. Describe in words how you can change the motor speed continuously. Note, you will only drive the motor in one direction. Problem 2: The motor you are using in problem 1 is a 12V dc motor with an armature resistance of 6Ω. What is the current drawn by the motor at stall? Look up the IRF520 N-channel MOSFET data sheet on coursework in the datasheets folder. Can safely use this MOSFET to control the motor? Problem 3: Now, you want to make a circuit that will allow you to measure temperature. You have a thermistor with a negative temperature coefficient and a resistance of 10k at room temperature. Design a simple voltage divider that will produce an output voltage that varies with the thermistor temperature, and produces 2.5V at room temperature. If you want the output

voltage to DECREASE when the thermistor temperature INCREASES, on which side of the divider should you place the thermistor? Problem 4: For fun, you decide to create a simple feedback controller by combining your motor speed circuit from problem 1 with the temperature sensor in problem 3. You place a propeller on the output shaft of the motor, and have it blow air on the thermistor from problem 3. Thus, as the motor speeds up, the temperature of the thermistor drops and the voltage from your temperature sensing circuit will rise. If on the other hand the motor slows down, the thermistor will heat back up and the output voltage will drop. Think of a way to control the motor speed such that the thermistor is held at a constant target temperature and can resist disturbances like your lab partner heating the thermistor with his/her breath. Draw a schematic of the controller. Write a pseudo code program to implement this controller using the Arduino microcontroller you used in the last lab.

Electronics 5: Arduino, PWM, MOSFETs and Motors Laboratory Instructions Date Location: Personal ( collaborators ): Work in pairs. Supervision by instructor and TAs. Objective Learn about pulse width modulation (PWM) as a control technique Learn how to use a MOSFETs to control high current drawing loads Learn how to drive basic DC motors and control their speed Learn how to program the arduino in Matlab Lean how to program a simple controller Background Today you will be building a simple controller with the arduino microcontroller and circuitry of your own design. Your task is to make a circuit with a motor driven cooling fan to keep the temperature of a thermistor nearly constant in the presence of external perturbations. Control circuitry is elemental to many real world systems, and it is useful to have some knowledge of how it works, and even how to make simple control systems. This lab simulates a real world experience where you would need to design and build some custom electronics for an experimental setup or testing equipment rapidly for prototyping purposes. Parts List/Materials Breadboard (Jameco Electronics) Oscilloscope (Tektronix TDS 1012C-EDU) Function generator (GW Instek GFG-8020H) Jumper wire (Jameco Electronics) Various resistors, potentiometers (Jameco Electronics ) Lab power supply (Mastech DC Power Supply HY3003D-3) LM324N op amps (Jameco Electronics) IRF520 N-channel mosfets (Jameco Electronics) N4935 Switching Diodes (Jameco Electronics) Motors (Jameco Electronics) 10K Thermistors (Jameco Electronics) Arduino Microcontroller

MATLAB Commands for Arduino a = arduino('port') where 'port' is the COM port to which the Arduino is connected to, e.g. 'COM5' or 'COM8' on Windows. This creates an object, a, that you can now apply the arduino commands to a.pinmode (pin, input ) or a.pinmode (pin, output ) to designate the pin mode a.digitalread(pin), reads the value of an analog pin. This is a 10 bit read so it varies between 0 and 1023. a.analogread(pin), reads the state of a digital pin, will be either 0 or 1 a.digitalwrite(pin,0) or a.digitalwrite(pin,1) to set a digital pin high or low a.analogwrite(pin, value), to set the value of an analog output pin. Value is an 8 bit number ranging from 0 to 255 that maps to a voltage of 0-5V. If the pin is one of the PWM designated pins, the output will be a PWM signal ranging from 0-5V with a duty cycle calculated by: 100*value/255, i.e. a 50% duty cycle is roughly 127 Finally, use a.delete to delete the arduino object, (and free up the serialport) when the session is over. Its nice to have this at the end of your m-file Other Useful Matlab Commands (type help command to see how to use them) Upon startup (i.e. at the beginning of your m-file) you should include the following commands to delete any lingering variables: o close all o clear o imtool close all o clc if, elseif, else for (needs an end ) while (needs an end ) plot save clc

Experiments/Tasks V + motor PWM (0 to V + ) G 10k D S IRF520 1N 493 5 GND Figure 1: Motor Drive MOTOR SPEED CONTROLLER Construct the motor speed circuit shown in Figure 1 using your breadboard and jumper wires. Use the alligator clips to connect the motor leads to the breadboard. Ensure that the kickback diode is in place and the cathode points to the high voltage power rail. Do all circuit construction without the power supply connected. Generate a PWM signal with the function generator. Use the oscilloscope to monitor the output of the generator, being sure to connect the grounds of the two probes to each other. Generate a square wave at 1kHz with a 50% duty cycle ranging from 0 to 5V. Use the cursors and/or quick measurements to verify the values in your input signal. Check to see that you can vary the duty cycle with the duty knob on the function generator. Connect the Function Generator output to the gate of the power mosfet in your circuit. Have a TA or instructor inspect your circuit before you power it up. You can use the 5V power supply to drive the motor circuit. Have a TA/Instructor verify that your circuit drives the motor, and that you can control the speed by changing the PWM duty cycle. TA check Clean up your circuit, trim resistors, and re-test to ensure that it works. Attach a small fan to the motor shaft by putting a strip of tape of the side similar to the tachometer setup you used in the past.

THERMISTOR TEMPERATURE SENSOR Build a temperature sensor by using the 10k thermistor as one half of a voltage divider. This circuit was one of your homework problems, so build it as you designed it in your homework so that it has the proper voltage output at room temp, and changes in the proper direction when the thermistor is heated or cooled. Monitor the output voltage with the oscilloscope to make sure your sensor works. *Make sure the power rails for the temperature sensing circuit and motor circuit are separate and connect only at the power supply. CONNECT THE ARDUINO TO MATLAB Begin by connecting your arduino to Matlab. If you have already connected your arduino to your computer, all you need is the matlab support package. You can find this at: http://www.mathworks.com/matlabcentral/fileexchange/32374 After downloading these files, you need to upload the srv.pde file to the arduino board. Upload the adiosrv.pde file to arduino This file acts as a server program to continuously communicate between matlab and the arduino. This communication takes place over the serial port. The downside is it slows the arduino down considerably. The upside is that you gain access to the versatility of math operations within matlab. From the Arduino IDE, go to File > Open, locate the file adiosrv.pde, (in the ArduinoIO/pde/adiosrv folder) and open it. If a dialog appears asking for the permission to create a sketck folder and move the file, press OK (this will create a adiosrv folder and move the adiosrv.pde file inside it). Connect the Arduino, make sure that the right board and serial port are selected in the IDE, (Tools/Board and Tool/Serial Port) then select File -> Upload to I/O Board and wait for the "Done Uploading" message. At this point the srv.pde file is uploaded and you can

close the IDE, which is not needed anymore for the purpose of this package. Actually closing the IDE is suggested, so you can be sure that the serial connection to the arduino board is not taken by the IDE when matlab needs to use it. Open matlab, and run the install_arduino m file to make matlab identify the appropriate path to connect to the arduino. Now you should be all set to program the arduino from within matlab. WRITE THE MOTOR SPEED CONTROL PROGRAM Begin by creating an m-file to run your code. You can find help on this in the matlab help menu if needed. You should put all your code in here rather than writing it in the command window. However, note that you can cut and paste multiple lines from an m- file into the command window if you want to test them out. Also, pressing f5 will run the m-file automatically. Within the m-file, write an event driven program that monitors the voltage from your temperature sensor, the voltage from a target reference (use a potentiometer to make this voltage) and multiplies the error by a fixed gain to calculate a new PWM duty cycle value to drive the motor. Begin by setting up all the pin types and directions, declaring any global variables, and then add a while loop inside which you constantly measure the temperature sensor voltage and update the PWM duty cycle sent to the motor. Make the while loop conditional dependent on the state of a tactile switch on one of the digital inputs. This gives you an easy way to stop the infinite loop at any time by pressing the button. Play with your temperature sensor by squeezing it with your fingers to see how much the voltage fluctuates. Estimate a reasonable gain value to stay within a reasonable error when the motor is running at steady state. Use the oscilloscope to test your code on the arduino. The PWM duty cycle should vary as you heat the thermistor with your hand or the laser pointer. Have a TA/instructor check your PWM output and make sure it seems to work. TA check CONNECT THE ARDUINO TO YOUR CIRCUIT AND TEST Connect the PWM output from your arduino to the gate of the mosfet on your motor controller. MAKE SURE TO CONNECT ONE OF THE GROUND PINS ON THE ARDUINO TO THE GROUND ON YOUR BREADBOARD Check to ensure that your motor circuit and sensing circuits do not share a ground loop, but rather connect to the power supply with two separate cables each.

Run your code, adjust the reference voltage such that the motor is off at room temperature, but begins to spin as you heat the thermistor. Adjust the gain so that the motor response is not too extreme. See if you can get the motor to run at a near steady state where the heat added to the thermistor is dissipated by the air the motor fans on it. Show the final result to one of the teaching staffs. TA check Summary results / error analysis: Not necessary for this module. Discussion: For your discussion think of a context in bioengineering where you could use the skills you practiced today. What properties would you want to improve, and how might you do that?