1 Lab 5: Controls and feedback. 2 Lab 5: Control and Feedback This embedded system uses the Photo sensor to detect the light intensity of the environment.

Slides:



Advertisements
Similar presentations
Interrupts, Low Power Modes and Timer A (Chapters 6 & 8)
Advertisements

Lab7: Introduction to Arduino
Sistemi Elettronici Programmabili13-1 MULTI OSC + CLOCK FILTER LVD POWER SUPPLY CONTROL 8 BIT CORE ALU PROGRAM MEMORY RAM I2CI2C PORT A SPI PORT B 16-BIT.
Proximity Sensor Theremin Khoa Nguyen Walter Hudson Dennis Gilbert G. Hewage Thushara.
Potentiometer Electric circuit Cell or Battery Resistor Switch Bulb Earth/Ground LED.
1 Lab2: A/D Converter. 2 This circuit connects a variable voltage to an A/D port on the AVR mcu. Your software running on the AVR mcu will read the digital.
Introduction of Holtek HT-46 series MCU
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or the.
ATtiny2313 Timers/Counters CS-423 Dick Steflik. What Do You Use Timers For? Timing of events (internal or external)‏ Scheduling Events Measuring the width.
Design of a Control Workstation for Controller Algorithm Testing Aaron Mahaffey Dave Tastsides Dr. Dempsey.
Solar Tracking Project Team Members: –Cristian Ruvalcaba –Ken Seal –David Clark –Mark McKinley –Richard DeJarnatt.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Pulse Width Modulation modes
Digital to Analog Converters
 Main Components:  Sensors  Micro controller  Motor drivers  Chasis.
Engineering 1040: Mechanisms & Electric Circuits Fall 2011 Introduction to Embedded Systems.
Timers and Interrupts Shivendu Bhushan Sonu Agarwal.
ARM Timers.
1 4-Integrating Peripherals in Embedded Systems. 2 Introduction Single-purpose processors  Performs specific computation task  Custom single-purpose.
A Few Words From Dilbert
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
Page 1 D&C EBV Seminar June 2003 Motor Demo C868 Chevillot/Jansen June 2003 N e v e r s t o p t h i n k i n g. Infineon C868 Hands On Training CAPCOM6.
RS232 #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7
1 Lab 1: Introduction. 2 Configure ATMEL AVR Starter Kit 500 (STK500), a prototyping/development board for Lab1. ATmega16 ( V) is the chip used.
(More) Interfacing concepts. Introduction Overview of I/O operations Programmed I/O – Standard I/O – Memory Mapped I/O Device synchronization Readings:
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.
By: Khalid Hawari Muath Nijim Thaer shaikh Ibrahim Supervisor: Dr. Jamal Kharousheh Dr. Nasser Hamad 27 December 2010.
Autonomous Helicopter James LydenEE 496Harris Okazaki.
By: Eric Backman Advisor: Dr. Malinowski.  Introduction  Goals  Project Overview and Changes  Work Completed  Updated Schedule.
1 Lecture on Lab 6 Lab 7 Lab 8. 2 Lab 6: Open Loop Controller As you learned in lab 5, there are two kinds of control systems: open loop and closed loop.
CCP MODULES  The CCP module (Capture/Compare/PWM) is a peripheral which allows the user to time and control different events.  Capture Mode provides.
By Tony Hoff ECE 4220 – Real Time Embedded Computing University of Missouri - Columbia Course Instructor: Dr. Guiherme DeSouza.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals.
Josh Lawson ECE Overview Project Description Schematic Hardware Involved Features of ATMEGA16/STK500 Involved System Features Testing Method.
Digital Control CSE 421.
Microprocessors A practical approach Lesson 2 Hardware description and Delays.
1 4-Integrating Peripherals in Embedded Systems (cont.)
PULSE WIDITH MODULATION EE 587 Presented by Viswanadha Kakarlapudi.
Timer 1 and 2 operation, PWM Principles. Timer 1 Operation.
SGDRS Software System Design Justin A. King WWU EET Senior project 2013.
Ambient Feedback Control System Jonathan Uht.  Description of Ambient Feedback Control System  Block Diagram of Ambient Feedback Control System  Hardware.
Ambient Feedback Control System Jonathan Uht.  Recap  System Block Diagram  Hardware Implementation  Software Implementation  Results  Work Not.
Seth Schwiethale James Crosetto James Ellison.  square pulse of ms, repeats every 20 ms  It is the same for both steering and acceleration 
Closed Loop Temperature Control Circuit with LCD Display Mike Wooldridge ECE 4330 Embedded Systems.
Josh Lawson ECE 4330 Dec 8. Overview Project Description Schematic Hardware Involved System Features Results.
Sensing Algorithm using IR Sensor and ADC Soong-sil University. Robotics 기 정 두 원.
1 Lab 4: D/A Converter Lab 4: D/A Converter This is a simple resistive network for a D/A converter Port 1, Port 0 are digital inputs ==> 00 (minimum),
Microcontroller basics Embedded systems for mortals.
Microprocessors A practical approach..
1. PIC ADC  PIC18F877 has 8 analog input channels i.e. port A pins(RA0 to RA5) and port E pins(RE1 and RE2). These pins are used as Analog input pins.
1 4-Integrating Peripherals in Embedded Systems. 2 Introduction Single-purpose processors  Performs specific computation task  Custom single-purpose.
Application Case Study Christmas Lights Controller
Why are Timer Functions Important?
Application Case Study Security Camera Controller
Timers and Event Counters
Microcontroller Applications
4-Integrating Peripherals in Embedded Systems
BITS EDU. CAMPUS , VARNAMA
Prepared by: Ibrahim Yasin Ibrahim Abdulhaq
4-Integrating Peripherals in Embedded Systems
AVR Addressing Modes Subject: Microcontoller & Interfacing
Pulse Width Modulation (PWM) Motor Feedback - Shaft Encoder
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or the.
Arduino Week 2 Lab ECE 1020 Prof. Ahmadi.
Lesson 1: Overview of Sequential Control and Data Acquisition
Microcontroller Labs Lab 1 – The LED Test Mode Dr. Gregg Chapman
UNIT 19 PWM 로봇 SW 교육원 조용수.
Prof. Chung-Ta King Department of Computer Science
Presentation transcript:

1 Lab 5: Controls and feedback

2 Lab 5: Control and Feedback This embedded system uses the Photo sensor to detect the light intensity of the environment and adjusts the light emitted by the LED to maintain a constant light intensity environment. You may need a resistor other than exactly 2K for better sensitivity 22K 2K

3

4 Lab 5: Controls and Feedback PID control –P: Proportional The error signal (error = desired – current) multiplied by a constant and fed out to the drive. (proportional = gain * error). –I: Integral The integral term is the sum of past errors, so adding the past errors will eventually drive the output closer to the desired output –D: Derivative Differentiator uses the derivative (rate of change) to predict the future behavior.

5 Lab 5: Controls and Feedback In this lab, the plant’s function is to generate a desired level of ambient light. The sensor measures ambient light with a Cadmium Sulfide (CdS) photocell. The sensor measures the plant’s performance.

6 Lab 5: Controls and Feedback The choice of a controller depends on the application’s requirements. This lab builds an application that uses the duty cycle of the PWM signal to dynamically adjust ambient light levels. The controller increases the duty cycle of the PWM in order to apply more power to the LED and thereby increase its intensity. The PWM is the control, u(t), that is fed into the plant (that is, LED).

7 Lab 5: Controls and Feedback Changes to the LED’s intensity can occur as fast as the mcu computes and updates the PWM duty cycle register (OCR2). For this application one updates every 100 milliseconds is more than sufficient. One milli-second is very slow compared to how fast ambient light fills a room. At speeds of human perception 100 milliseconds is fast but detectable. These timing considerations drive the requirement for only needing to use a proportional controller. Hint: A maximum change of 2% to 4% to the duty cycle every ms implements a nice smooth transition of the LED’s intensity

8 Lab 5: Controls and Feedback

9 SW0-SW4 are used to set the target level for the control loop. LED0-LED4 are used to indicate to the user which switch has been pressed. The percentage of the LED intensity is sent to the computer terminal through the serial port. SwitchTarget Level SW0 (100%)Full LED intensity SW1 (75%)no_LED +((full_LED - no_LED)*3/4) SW2 (50%)no_LED +((full_LED - no_LED)/2) SW3 (25%)no_LED +((full_LED - no_LED)*1/4) SW4 (0%)No LED intensity

10 Lab 5: Controls and Feedback Timer2(PWM) Timer2 is used to setup the Pulse Width Modulation (PWM) for the LED. A clock rate of 460KHz and a non-inverted PWM can be selected. The pulse width is determined by the 8-bit value in the OCR2 register. 0xFF is maximum pulse width and the initialization value of 0x80 has a pulse width of 1/2 cycle. You can choose any other values to suit your design.

11 Lab 5: Controls and Feedback Initialization code for Timer2: // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: kHz // Mode: Phase correct PWM top=FFh // OC2 output: Non-Inverted PWM TCCR2=0x62; ASSR=0x00; TCNT2=0x00; OCR2=0x80; The output for Timer2 PWM mode is PD7. Bit 7 of Port D is set up to be an output. Initialization code for Port D: // Port D initialization // Set up PD7 as the output driver to the external LED PORTD=0x00; DDRD=0x80;

12 Lab 5: Controls and Feedback Code to find the light with no LED and full LED intensity: // Find ambient light with no LED output. OCR2 = 0x00; delay_ms( 2000 ); no_LED = read_adc( 0x0 ); // Find ambient light with full LED output. OCR2 = 0xFF; delay_ms( 2000 ); full_LED = read_adc( 0x0 ); // Initialize variables for 50%. PORTC = 0x1B; //11011 turns on LED2 target_reading = no_LED +((full_LED - no_LED)/2);

13 Lab 5: Controls and Feedback #include // Standard Input/Output functions #include bit update = 0; // Update the duty cycle. // Timer 1 overflow interrupt service routine interrupt [TIM1_OVF] void timer1_ovf_isr(void) { // Reinitialize Timer 1 value // Update every 100ms. TCNT1H=0xE9; TCNT1L=0x8A; update = 1; }

14 Lab 5: Controls and Feedback if( update ) { // Read channel 0 adc. adc_input = read_adc( 0x0 ); // Print the adc value. // printf( "Target Reading = %X\r", target_reading ); // printf( "ADC Input = %X\r", adc_input ); // Find the difference between the adc input and // the sensor reading. error = adc_input - target_reading; ????/

15 Lab 5: Controls and Feedback

16 Lab 5: Controls and Feedback

17 Lab 5: Controls and Feedback

18 Lab 5: Controls and Feedback

19 Lab 5: Controls and Feedback If no switches are pushed, do the PID code. –Measure the LED intensity (iMeas) –Compare to commanded intensity (iCom) –Error = iCom – iMeas –Limit error to +/- 10 –New value of duty = old value of duty + error * 1.2. –Limit duty to range of 0 to 255 –Write duty to PWM register –Output iCom, iMeas and duty on UART –Wait 50 ms to give ~ 10 Hz control time If the switch is pushed, then change duty to new value as determined by switch number etc

20 Software minimum requirements: (1) SW0-SW4 are used to set the target level for the control loop. according to the following table (2) LED0-LED4 are used to indicate to the user which switch has been pressed. (3) The percentage of the LED intensity is sent to the computer terminal through the serial port. SwitchTarget Level SW0 (100%)Full LED intensity SW1 (75%)no_LED +((full_LED - no_LED)*3/4) SW2 (50%)no_LED +((full_LED - no_LED)/2) SW3 (25%)no_LED +((full_LED - no_LED)*1/4) SW4 (0%)No LED intensity