Embedded Hardware Design Lab4

Similar documents
L13: (25%), (20%), (5%) ECTE333

Crayfish Stretch Receptor Stimulator

Module 13: Interfacing ADC. Introduction ADC Programming DAC Programming Sensor Interfacing

Counter/Timers in the Mega8

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

Department of Mechanical and Aerospace Engineering ME106 Fundamentals of Mechatronics Andrew Nguyen Ryan Nunn-Gage Amir Sepahmansour Maryam Sotoodeh

Application Note: Using the Motor Driver on the 3pi Robot and Orangutan Robot Controllers

EE-318 Electronic Design Lab (EDL) Project Report Remote Controlled Smart Mote

Analogue to Digital Conversion on an ATmega168

Timer/Counter with PWM

ECED3204: Microprocessor Part IV--Timer Function

DASL 120 Introduction to Microcontrollers

Inductor saturation tester

Inductor saturation tester

CSCI1600 Lab 4: Sound

uc Crash Course Whats is covered in this lecture Joshua Childs Joshua Hartman A. A. Arroyo 9/7/10

University of California, Berkeley EE128, Fall Lab 7 A Microcontroller Based Position/Speed Controller

ATmega16A Microcontroller

AVR PWM 11 Aug In the table below you have symbols used in the text. The meaning of symbols is the same in the entire guide.

Microcontroller Based Inductance Meter. David Nguyen

EE 308: Microcontrollers

CHAPTER-5 DESIGN OF DIRECT TORQUE CONTROLLED INDUCTION MOTOR DRIVE

The Interface Communicate to DC motor control. Iu Retuerta Cornet

EE 109 Midterm Review

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

Microcontroller Systems. ELET 3232 Topic 21: ADC Basics

Embedded Systems and Software. Analog to Digital Conversion

3DoT C++ Timer/Counter 4 with PWM

A MORON'S GUIDE TO TIMER/COUNTERS v2.2. by

Microprocessors & Interfacing

Serial communication inverter. Lab bench scenario. Inverter Board, A/D, D/A, PWM, Filters, Encoders. Inverter board. and Dimmer introduction

Ch 5 Hardware Components for Automation

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

Analog Input and Output. Lecturer: Sri Parameswaran Notes by: Annie Guo

Arduino based pulse width modulated output voltage control of a dc-dc boost converter using Proportional, Integral and Derivative control strategy

FABO ACADEMY X ELECTRONIC DESIGN

Building Interactive Devices and Objects. Prof. Dr. Michael Rohs, Dipl.-Inform. Sven Kratz MHCI Lab, LMU München

Implementation of Multiquadrant D.C. Drive Using Microcontroller

FRIDAY, 18 MAY 1.00 PM 4.00 PM. Where appropriate, you may use sketches to illustrate your answer.

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

EARTH PEOPLE TECHNOLOGY, Inc. FAST ARDUINO OSCILLOSCOPE PROJECT User Manual

DC motor control using arduino

ESE 350 Microcontroller Laboratory Lab 5: Sensor-Actuator Lab

Microwave click PID: MIKROE Weight: 30 g

Lab 13: Microcontrollers II

Interfacing to Analog World Sensor Interfacing

Timer 0 Modes of Operation. Normal Mode Clear Timer on Compare Match (CTC) Fast PWM Mode Phase Corrected PWM Mode

Hello, and welcome to this presentation of the FlexTimer or FTM module for Kinetis K series MCUs. In this session, you ll learn about the FTM, its

Peripheral Link Driver for ADSP In Embedded Control Application

Embedded Control. Week 3 (7/13/11)

νµθωερτψυιοπασδφγηϕκλζξχϖβνµθωερτ ψυιοπασδφγηϕκλζξχϖβνµθωερτψυιοπα σδφγηϕκλζξχϖβνµθωερτψυιοπασδφγηϕκ χϖβνµθωερτψυιοπασδφγηϕκλζξχϖβνµθ

MicroToys Guide: Motors A. Danowitz, A. Adibi December A rotary shaft encoder is an electromechanical device that can be used to

Analog I/O. ECE 153B Sensor & Peripheral Interface Design Winter 2016

CHAPTER 4 HARDWARE DEVELOPMENT OF STATCOM

Four Quadrant Speed Control of DC Motor with the Help of AT89S52 Microcontroller

Activity 4: Due before the lab during the week of Feb

Exercise 5: PWM and Control Theory

Roland Kammerer. 13. October 2010

Hello, and welcome to this presentation of the STM32L4 comparators. It covers the main features of the ultra-lowpower comparators and some

EE445L Spring 2017 Final Page 1 of 7

A Beginners Guide to AVR

Lab 2: Blinkie Lab. Objectives. Materials. Theory

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

Lab 5: Control and Feedback. Lab 5: Controls and feedback. Lab 5: Controls and Feedback

Ocean Controls KT-5198 Dual Bidirectional DC Motor Speed Controller

Training Schedule. Robotic System Design using Arduino Platform

ARDUINO BASED DC MOTOR SPEED CONTROL

Design with Microprocessors

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

Myoelectric Interface

USB4. Encoder Data Acquisition USB Device Page 1 of 8. Description. Features

MICROPROCESSORS A (17.383) Fall Lecture Outline

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

EXPERIMENT 6: Advanced I/O Programming

Microcontroller Based Closed Loop Speed and Position Control of DC Motor

Hardware Platforms and Sensors

EE445L Fall 2015 Final Version B Page 1 of 7

Figure 1: Motor model

LAB 1 AN EXAMPLE MECHATRONIC SYSTEM: THE FURBY

Sensors and Sensing Motors, Encoders and Motor Control

GSM BASED PATIENT MONITORING SYSTEM

ARDUINO / GENUINO. start as professional. short course in a book. faculty of engineering technology

1. Introduction to Analog I/O

P a g e 1. Introduction

The Allen-Bradley Servo Interface Module (Cat. No SF1) when used with the Micro Controller (Cat. No UC1) can control single axis

Module: Arduino as Signal Generator

The Solarbotics SUMOVORE

Project Proposal. Low-Cost Motor Speed Controller for Bradley ECE Department Robots L.C.M.S.C. By Ben Lorentzen

ME 461 Laboratory #5 Characterization and Control of PMDC Motors

APPENDIX 1 FEATURES OF MICROCONTROLLER 89C51

Quantizer step: volts Input Voltage [V]

Embedded Controls Final Project. Tom Hall EE /07/2011

Design of double loop-locked system for brush-less DC motor based on DSP

EE445L Fall 2014 Quiz 2A Page 1 of 5

CQM1H-MAB42 Analog I/O Board Connector CN1: Analog inputs 1 to 4. Name Specifications Model number Slot 1 (left slot) High-speed Counter Board

The University of Texas at Arlington Lecture 10 ADC and DAC

Lab 5: Inverted Pendulum PID Control

Analog to Digital Conversion

Programming and Interfacing

MD04-24Volt 20Amp H Bridge Motor Drive

Transcription:

Embedded Hardware Design Lab4 Objective: Controlling the speed of dc motor using light sensor (LDR). In this lab, we would want to control the speed of a DC motor with the help of light sensor. This would allow us to learn basic sensing and control mechanism. To control the speed of DC motor, we will use Pulse Width Modulation, abbreviated as PWM. PWM is a method of transmitting information on a series of pulses. The data that is being transmitted is encoded on the width of these pulses to control the amount of power being sent to a load. PWM is very handy tool, you can use it for power delivery, voltage regulation and amplification and audio effects. In the previous lab you have gone through the basic understanding of PWM, register configuration for different modes of PWM in atmega32. Analog voltage and current can be used to control devices directly like speed of a fan. In a simple analog controller, a knob is connected to a variable resistor. As you turn the knob, the resistance goes up or down. As that happens, the current flowing through the resistor increases or decreases. As intuitive and simple as analog control may seem, it is not always economically attractive or otherwise practical. Analog circuits can get very hot; the power dissipated is proportional to the voltage across the active elements multiplied by the current through them. Analog circuitry can also be sensitive to noise. By controlling analog circuits digitally, system costs and power consumption can be drastically reduced. What's more, many microcontrollers already include on-chip PWM controllers, making implementation easy, for an example atmega32 comes with 3 timers all can be configured to used for PWM. On Off a. 10% Duty Cycle b. 50% Duty Cycle c. 90% Duty Cycle Figure 1

Figure 1 shows three different PWM signals. Figure 1a shows a PWM output at a 10% duty cycle. That is, the signal is on for 10% of the period and off the other 90%. Figures 1b and 1c show PWM outputs at 50% and 90% duty cycles, respectively. These three PWM outputs encode three different analog signal values, at 10%, 50%, and 90% of the full strength. If, for example, the supply is 5V and the duty cycle is 10%, a 0.5V analog signal results pwm Explanation: In the previous lab2 you have done pwm program which generates the square pulse on pin pd- 4/pd-5. Library Files: avr/io.h avr/interrupt.h avr/signal.h inttypes.h Library Functions: sei Functions: pwm1a_init() pwm1a_setdutycycle() Registers: DDRD DDRB PORTB OCR1AL TCCR1A TCCR1B ADCSRA ADC (ADCH,ADCL) Local Variables: int i,j

ADC For ADC: Do refer Features and operation of ADC: Page. 199 onwards Registers: Page. 212 onwards An analog-to-digital converter (abbreviated ADC, A/D or A to D) is a device that converts a continuous quantity to a discrete time digital representation. An ADC may also provide an isolated measurement. The reverse operation is performed by a digital-to-analog converter (DAC). Typically, an ADC is an electronic device that converts an input analog voltage or current to a digital number proportional to the magnitude of the voltage or current. However, some non-electronic or only partially electronic devices, such as rotary encoders, can also be considered ADCs. The digital output may use different coding schemes. Typically the digital output will be a two's complement binary number that is proportional to the input, but there are other possibilities. An encoder, for example, might output a Gray code. Example 1, Reading ADC with 500 msec delay #include<avr/io.h> #include <avr/interrupt.h> #include <inttypes.h> SIGNAL (SIG_ADC) PORTB = ADCH; insert a For loop of 500 msec delay. ADCSRA = ADCSRA 0x40; // start the next conversion void main(void) DDRB = 0xFF; // least signficant 3 bits for output ADMUX = ( 1<< ADLAR); ADCSRA = ( 1 << ADEN ) (1 << ADIE) ( 1 <<ADPS2); sei (); while (1);

Program that generates the square pulse using the timer1: #include <avr/io.h> #include <avr/delay.h> #include <avr/interrupt.h> #include <avr/signal.h> #define F_CPU 1000000UL void pwm1a_init(); void pwm1a_setdutycycle(uint8_t dc); void pwm1a_init(void) DDRD = DDRD (1 << PD5) ( 1 << PD4); OCR1AL = 0x00; TCCR1A = TCCR1A (1 << WGM10) (1 << WGM11) (1 << COM1A1); TCCR1B = TCCR1B (1 << CS10) (1<<CS12); return; void pwm1a_setdutycycle(uint8_t dc) OCR1AL = dc; return; int main(void) DDRB = 0xFF; DDRD =0x00; PORTB=0xFF; uint8_t i=0; uint16_t j=0,k=0; pwm1a_init(); pwm1a_setdutycycle(125); sei(); while (1) for(i=0;i<255;i=i+5) //pwm1a_setdutycycle(125); for(j=0;j<50000;j++); for(k=0;k<=50000;k++); PORTB=~PORTB;

Circuit-Kit Setup: To connect circuit-kit for above experiment we need 4 cables. (1) Serial cable to connect serial port of computer to programmable serial port of kit. (2) 8-wire cable to connect port-b to LEDs of kit. (3) Cable to select target microcontroller slot to program. (4) 2-wire cable to connect port-d (pd4 or pd5) to analog input from light sensor. (5) For motor and LDR connection follow figure 2 and 3 respectively. You may be able to use MOSFET for driving Motors also. Compile the program and burn on the kit. Expected Output: On proper cable connection and program upload you can see square pulse of configured duty cycle on pd4/pd5 pin. Now you change the duty cycle in program and again check the duty cycle changes. As of that you can see the change on the pin (connect them to port-b). Your task: 1) In this lab manual you have been given a program that generates the square pulse using the timer1. Now as told previously, Atmega32 provides various modes to generate different waveforms. Using various setting of WGM1-0:3, try to explore different waveforms [minimum 4, CTC-page 96, Fast PWM-page 97, Phase Correct PWM-page 99, Phase and Frequency Correct PWM-page 101]. For each waveform you need to calculate the PWM frequency. You can get the required register setting for the above mode from page 107, Table-47. 2) In this lab your task is to control the speed of the motor based on the light intensity given by LDR. Connect Motor and LDR to microcontroller as per circuit given in figure 2 and 3. Write code which reads the LDR, light intensity and based on that light intensity it rotates the motor very fast, fast, slow or very slow.