ENGR101 T Engineering Technology. Arthur Roberts. School of Engineering and Computer Science Victoria University of Wellington

Similar documents
21. PID control The theory of PID control

Congruence Arithmetic

introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion

ISY00245 Principles of Programming. Module 7

Stepwise Refinement. Lecture 12 COP 3014 Spring February 2, 2017

Note. The above image and many others are courtesy of - this is a wonderful resource for designing circuits.

Week - 04 Lecture - 01 Merge Sort. (Refer Slide Time: 00:02)

3.6 MONITORING AND CONTROL SYSTEMS

EEN118 LAB FOUR. h = v t ½ g t 2

2SKILL. Variables Lesson 6. Remembering numbers (and other stuff)...

Intro. Speed V Growth

(Refer Slide Time: 00:51)

EEN118 LAB FOUR. h = v t ½ g t 2

Introduction to Unix

Home Monitoring and Control service provided by Verizon Online LLC

Direct Variations DIRECT AND INVERSE VARIATIONS 19. Name

Mathematics. Name: Class: Transforming Life chances

Motors & Wheels. Wheels can be attached to the KIBO s motors to make them spin. The motors can be attached to the KIBO robot to make it move!

C - Colour Mixing. Let's use the Sparkle module and some switches to make a colour mixer! 2018 courses.techcamp.org.

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Week 02 Module 06 Lecture - 14 Merge Sort: Analysis

EEN118 LAB FOUR. h = v t - ½ g t 2

Basic Electricity 10 Hour - Part 1 Student Workbook Issue: US140/10/2a-IQ-0402A. Written by: LJ Technical Dept

Robolab. Table of Contents. St. Mary s School, Panama. Robotics. Ch. 5: Robolab, by: Ernesto E. Angulo J.

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Module 02 Lecture - 45 Memoization

EEN118 LAB FOUR. h = v t ½ g t 2

Functional Programming in Haskell Prof. Madhavan Mukund and S. P. Suresh Chennai Mathematical Institute

Operation 6035 ENGLISH PROG MENU

From lab to production, providing a window into the process. Dynisco's ATC990 and UPR900 Applications and Setup

Fundamentals of lambda tuning

NXT Programming for Beginners Project 9: Automatic Sensor Calibration

(Refer Slide Time: 00:26)

B - Broken Track Page 1 of 8

(Refer Slide Time: 01:25)

4. Write sets of directions for how to check for direct variation. How to check for direct variation by analyzing the graph :

Week - 01 Lecture - 03 Euclid's Algorithm for gcd. Let us continue with our running example of gcd to explore more issues involved with program.

Introduction to Unix

PID Controller application in robotics. Victor Abreu A /5/2013. Executive Summary:

OVEN INDUSTRIES, INC.

Rescuing Lost Files from CDs and DVDs

IVR: Open- and Closed-Loop Control. M. Herrmann

DMX-DALI-DMX interface

APCS-AB: Java. Recursion in Java December 12, week14 1

Lesson 2. Introducing Apps. In this lesson, you ll unlock the true power of your computer by learning to use apps!

ROBOLAB Reference Guide

Object-Oriented Analysis and Design Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology-Kharagpur

RIS shading Series #2 Meet The Plugins

+ power supply. - común. + to track

Section 0.3 The Order of Operations

Advanced Thermal Controller TEC Series

MAT 003 Brian Killough s Instructor Notes Saint Leo University

Topic 4 - Introduction to Metering on a DSLR

QUIZ Friends class Y;

Robot learning for ball bouncing

OP10. Pre-programmed, configurable controller for simple applications

LipStick. User Manual

MODELLING-Choosing a model

What is stored in the XIM?

MANAGING YOUR MAILBOX: TRIMMING AN OUT OF CONTROL MAILBOX

In the following chapter two most common WAFS architectures are presented and the most common and simple set of used techniques is shown.

HOW TO REGISTER FOR AND JOIN AN ASTTBC/BCIPI WEBINAR ( as painlessly as possible)

Intro. Scheme Basics. scm> 5 5. scm>

A fraction (from Latin: fractus, "broken") represents a part of a whole.

(Refer Slide Time: 1:40)

TB267 (Rev4) - CNC11 Yaskawa Sigma5 Precision Mode Setup

Physics 1230: Light and Color. Projects

Figure 1: A picture of a ruler inside a sheet protector. Figure 2: Example of measuring a water drop.

Example 1: Given below is the graph of the quadratic function f. Use the function and its graph to find the following: Outputs

The first program: Little Crab

ENGR 40M Project 3c: Switch debouncing

Arrays. myints = new int[15];

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Pre-Algebra Notes Unit 8: Graphs and Functions

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 24 Solid Modelling

MIPS Programming. A basic rule is: try to be mechanical (that is, don't be "tricky") when you translate high-level code into assembler code.

Linked lists Tutorial 5b

Classwork 7: Craps. N. Duong & R. Rodriguez, Java Crash Course January 6, 2015

Object 18 - PID. PID Summary

PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 03. REQUIREMENTS CHANGE. I Love You, You re Perfect... Now Change!

Chapter 1 Operations With Numbers

If Statements, For Loops, Functions

Slide Set 9. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between

TCP: Flow and Error Control

Module 1: Crash Prevention Lesson 3: Weather Information systems Programming Activity Using Arduino Teacher Resource Grade 6-8 Time Required

user guide AbiBird You will need The AbiBird Sensor and An iphone with ios 10+ OR A Smartphone with Android 5+

Operation Guide CT100

GAP CLOSING. Grade 9. Facilitator s Guide

5. Control Statements

EMO valve drive. 1. Function 1. Table of Contents. 2. Installation

CALCULUS LABORATORY ACTIVITY: Numerical Integration, Part 1

Advanced Debugging I. Equipment Required. Preliminary Discussion. Basic System Bring-up. Hardware Bring-up, Section Plan

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Grade 7/8 Math Circles Fall Nov.4/5 The Pythagorean Theorem

TNG-3B derives its operating power from the serial port. The DTR, RTS, and both data lines are all used, and must be properly connected.

MICROMOUSE ALGORITHMS. Navigation, Path finding, and Maze Encoding

Lecture Notes on Contracts

Lab 7: PID Control with Trajectory Following

Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides

Week - 01 Lecture - 04 Downloading and installing Python

A Simple First-Model Using the Berkeley-Madonna Program

Transcription:

ENGR101 T1 2017 Engineering Technology Arthur Roberts School of Engineering and Computer Science Victoria University of Wellington Arthur Roberts (ECS) ENGR101 1 / 32

Housekeeping Important ANNOUNCEMENT: CHOCOLATE is gone. Proof: Video New chocolate - reach same point but follow the line. Arthur Roberts (ECS) ENGR101 2 / 32

Lecture 26 Topic 1: Control algorithms Arthur Roberts (ECS) ENGR101 3 / 32

Reminder We talked a bit about control systems at last lecture. Summarizing: We want our system in certain state. But it is not. Difference is called error - and we want to keep it 0 If error is not 0 - we try to adjust Adjustment is constantly repeated For example, we want to keep landing plane in the middle of runway... https://www.youtube.com/watch?v=ook_dbldfa0 Arthur Roberts (ECS) ENGR101 4 / 32

Diagramatically... General Control System: Example of a closed loop system: a system that responds to its current state. All smarts are in controller - it decides what to do if there is an error. Arthur Roberts (ECS) ENGR101 5 / 32

Conditional Solution - simple and WRONG Easy, is it? What is the problem here? if left half of runway > full turn right; if right half of runway > full turn left; if middle > steady as we go. Arrgh, captain... For every complex problem there is an answer that is clear, simple, and wrong. H. L. Mencken Read more at: https://www.brainyquote.com Arthur Roberts (ECS) ENGR101 6 / 32

Thermostat Let s forget about robots and airplanes for a while and consider room heating (seems to be rather important subject now, does it?). Figure: Simple! If temperature is lower than comfortable - turn heater ON full blast If temperature is higher than comfortable - turn heater OFF Arthur Roberts (ECS) ENGR101 7 / 32

What happens? 20-5 air temperature We want that A B C D E heater ON time A - too cold, turn it ON A->B - good now, turn it OFF B - heater is OFF but still hot. Temperature in the room keep rising (slower though) B->C - temperature of the heater becomes same as air temperature. Air temperature stops increasing. C - Heater is OFF, air temperature dropping Arthur Roberts (ECS) ENGR101 8 / 32

What happens? air temperature 20-5 We want that A B C D E heater ON time C->D - becoming too cold, turn it ON D - temperature of heater rising. But is not high enough to start heating the air So temperature never actually is what we want it to be but going around and around. Improve? Arthur Roberts (ECS) ENGR101 9 / 32

Response is proportional to error 20-5 air temperature error We want that A B C D E heater ON time Heater have temperature setting We measure how far air temperature is off desired value (error) and adjust heater setting accordingly error is big - heater is on HIGH error is small - heater is on LOW When time reaches point A->B heater was in LOW setting for a while already, so air temperature in B will not overshoot that much Arthur Roberts (ECS) ENGR101 10 / 32

We are not designing heating system, right? Our error is distance between middle of the image and white line position (last lecture) 240 320 ERROR We should adjust speed of left and right motor so that line stays in the middle In this case (line to the right) speed of left motor should go up and speed of right motor should go down - robot turns to the right. At the same time robot should keep going forward. How? Arthur Roberts (ECS) ENGR101 11 / 32

Speed proportional to error Declare unsigned char v_go - speed of going straight forward Declare unsigned char dv - difference in speed of left and right motors Now: Speed of right motor: v r = v_go + dv (set_motor(..,v_l)) Speed of left motor: v l = v_go dv(set_motor(..,v_r)) dv is proportional to error (scaling, overflow, type conversions!!!). Symbolically, dv = error Kp Left, right, forward and backward are confusing things - they change when you connect wires differently. Arthur Roberts (ECS) ENGR101 12 / 32

Demo Python Demo purposes only - not real thing Track is blue Robot trajectory - orange Arthur Roberts (ECS) ENGR101 13 / 32

Question! What is robot doing if you set Kp = 0.0 and implement formulas: (pseudocode, not C) dv = error Kp v_left = v_go + dv v_right = v_go dv set_motor(..., v_left) set_motor(..., v_right) 1 Go straight 2 Follow the line 3 Stay still Arthur Roberts (ECS) ENGR101 14 / 32

Kp influence What happens as Kp increases? Demo (KP1.py): Kp = 0.0 kp = 0.005 kp = 0.05 - breakdown Kp goes up Kp=0 Bigger Kp results in robot reacting more (turning further) to same error. Eventually it becomes hysterical. So answer is - choose right value of Kp and it works. Arthur Roberts (ECS) ENGR101 15 / 32

ALL PROBLEMS SOLVED!! Yeah, right... But let us have a look at heating system again... air temperature air temperature 20 We want that 20 error We want that -5 A B C D E heater ON time -5 A B C D E heater ON time It takes longer with proportional. It is understandable - controller is not pushing to the limit - its slowing down to avoid the overshooting. Can we speed things up a bit? Arthur Roberts (ECS) ENGR101 16 / 32

Brakes... kp2>kp1 Slow down here Figure: time kp1 It would be good to keep K p high - faster regulation But we risk system becoming non-stable If we can apply brakes when system approaches desired state? How to detect that? It is going faster - rate of change Arthur Roberts (ECS) ENGR101 17 / 32

How detect rate of change? e1 e0 t0 t1 time We measure error e0 at moment of time t0. We measure error e1 at moment of time t1. Rate of change (derivative) is de dt = e1 e0 t1 t0 (1) Controller should remember last measurement to calculate rate of change. Arthur Roberts (ECS) ENGR101 18 / 32

Demo Kp = -0.005 0.05 - limit Kd = -0.05 This, actually, is almost perfect adjustment - fast without much overshooting. As an exercise - there is another way to detect rate of change for this robot. How? Arthur Roberts (ECS) ENGR101 19 / 32

Our program flow (pseudocode) repeat... error = line_off _centre() recall_previous_error_value de/dt =... dv = error Kp + de/dt Kd v_left = v_go + dv v_right = v_go dv set_motor(..., v_left) set_motor(..., v_right) More on programming later. How to get Kp and Kd values? Arthur Roberts (ECS) ENGR101 20 / 32

Have to keep trying... Set Kp and Kd both to 0. Robot should go straight(ish - motors are not identical) Increase Kp until robot follows the line - including curved parts. Increase Kp until robot starts swinging but still follows the line Start changing Kd until movement is smooth Arthur Roberts (ECS) ENGR101 21 / 32

Demo videos Arthur Roberts (ECS) ENGR101 22 / 32

PID controller - workhorse of automatic control PID stands for: P: Proportional - response to current error value. I: Integral - response to total (sum) error value over time. D: Derivative - response to rate of change of error value. The strength of each response is tuned by a constant of proportionality: k p, k i or k d respectively. Arthur Roberts (ECS) ENGR101 23 / 32

Back to our closed loop system General PID Control System: Example of a closed loop PID system. Note that all responses are summed back together before the output is determined. Arthur Roberts (ECS) ENGR101 24 / 32

Integral? + + + - - - time Both proportional and derivative terms are localized Sometimes there is some offset in the system which is so small that can properly measured only over long periods of time Integral accumulates error over time so offset can be eliminated Our time periods are too short for integral term to work Arthur Roberts (ECS) ENGR101 25 / 32

Lecture 26 Topic 2: Programming AVC hint Arthur Roberts (ECS) ENGR101 26 / 32

General comments It is logical to make program run forever as there is no need really to stop it when robot reaches finish line. int main() { while(1) { // miracle happens... } } Listing 1: Caption comes handy here. Algorithms for different quadrants are quite different - better to have some variable to store current quadrant, say quad Arthur Roberts (ECS) ENGR101 27 / 32

Programming it I To engage different functions you can use either if or switch operators. int main(){ int quad = 0; while(1) { if (quad == 0) { // do quadrant 0 } if (quad == 1) { // do quadrant 1 } //... etc }... return 0; } Listing 2: if version Arthur Roberts (ECS) ENGR101 28 / 32

Programming it - switch operator switch is like if with multiple choices. Listing 3: Caption int main() { int a = 10; switch(a){ case 0: printf("value is 0\n"); break; case 1: printf("value is 1\n"); break; default: printf("not listed\n"); break; } } if value is found in the list - everything between case value and break is executed - careful here. break jumps out of switch. if value is not found - default branch is executed. value not found and no default - nothing is executed Arthur Roberts (ECS) ENGR101 29 / 32

Programming it - switch operator Listing 4: Caption int main() { int a = 1; switch(a){ case 0: printf("value is 0\n"); break; case 1: printf("value is 1\n"); break; default: printf("not listed\n"); break; } } What is an output? 1 "value is 0" 2 "value is 1" 3 "Not listed" Arthur Roberts (ECS) ENGR101 30 / 32

Programming it - switch operator Listing 5: Caption int main() { int a = 0; switch(a){ case 0: printf("value is 0\n"); case 1: printf("value is 1\n"); default: printf("not listed\n"); } } What is an output? 1 value is 0 2 value is 0 value is 1 Not listed 3 Nothing Arthur Roberts (ECS) ENGR101 31 / 32

Programming it - tricky function in Quadrant 2 There is possibly tricky function in Quadrant 2: wiggly line following. it would be good to have the function which returns error - estimation of how far from the center of camera image. Something like... 240 320 ERROR Listing 6: Caption int estim_error() { // miracle happens here return error; } would be lovely, thank you. Problem is, may be we lost white line altogether. How to make function to return this information? Right now function returns int. Arthur Roberts (ECS) ENGR101 32 / 32