Lecture 7 - Basic Mathematics Straight Line Equation and ...

24
HKUST Dual Program 2018 Level 1 (Engineering – Robotics) Basic Mathematics Straight Line Equation and its Applications Dr. Tim, Kam‐tim WOO ([email protected])

Transcript of Lecture 7 - Basic Mathematics Straight Line Equation and ...

Page 1: Lecture 7 - Basic Mathematics Straight Line Equation and ...

HKUST Dual Program 2018Level 1 (Engineering – Robotics)

Basic MathematicsStraight Line Equation and its ApplicationsDr. Tim, Kam‐tim WOO ([email protected])

Page 2: Lecture 7 - Basic Mathematics Straight Line Equation and ...

• Let’s start from a simple project idea:

2

Product

Components

SystemSensors 7-segement LED

Input signals Output signalsHow to receive signals?

Control the output device (7-segement LED) with different sensing information.

Our Ultimate goal : 

SliderTim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics)

Page 3: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Mixed Hardware / Software Co‐Development

3Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics)

Page 4: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Mixed Hardware / Software Co‐Development

4

• Take an example:

SystemCamera module

Save image into SD Card

System 1. Image Capture Routine

Camera module

Save the data into the SD card

Display the values of coloronto the PC console

System 2.Read/Write Routine

for SD Card

pre-defined texts and number in PC

Image Capture Routine and Read/Write Routine for SD Card

Co‐Development

Pure color images:R,G,B,K,W

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics)

Page 5: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Mixed Hardware / Software Co‐Development

5

• Take an example:

SystemSlider Light up LEDs

Data Collection Routine and LED Display Routine

Slider

Light up LEDs

Display the values(position of slider)

onto the PC console

pre-defined number in PC

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics)

Page 6: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Slider information

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 6

Analog signal

Digital signal

PC Console

Analog‐to‐Digital Routine

Serial Communication Routine

Page 7: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Understand the slide potentiometer (Slider)

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 7

• This is a variable resistor. It is called “slide potentiometer”.• Measure OTA and OTB when the slide potentiometer moves.

Electrical symbol

VCC / +5V

GND

OTA / OTB

Page 8: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Slide Potentiometer 

• Connect the wires between the slider and the daughter board

• Measure the voltage at OTA at different position of slider

8

Slider

OTA   ‐‐‐‐VCC   ‐‐‐‐GND  ‐‐‐‐

Arduino board

A0+5VGND

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics)

Page 9: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Slide Potentiometer

• In the Arduino board, we only handle digital signal• Converting Analog signal (voltage) into Digital signal.

• Analog‐to‐Digital Conversion (ADC) 

9

Analog signalRange 0 to 5 V

Digital signalRange : 0 to 1023

5V

0V

1023

0

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics)

Page 10: Lecture 7 - Basic Mathematics Straight Line Equation and ...

• Map analog inputs to a range of binary values• Consists of two buildings blocks : sampler and A/D converter

Background knowledge: Analog-to-Digital Conversion

A/D converter

Sample with analog amplitude

Digital sequence for the sample

Converting analog amplitude into a digital sequence

2.5V

5V

3.75V

1.25V

0

A/D Converter

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 10

Page 11: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Concept of Analog-to-Digital Conversion

• Map analog outputs to binary values ( linear quantization )

A/D conversion

D/A conversion

Mathematics can be involved.

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 11

Page 12: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Arduino Programming for Slide potentiometer

• Step 1: Connect the slide potentiometer with Arduino board

12

Slider

OTA   ‐‐‐‐VCC   ‐‐‐‐GND  ‐‐‐‐

Daughter board

A0+5VGND

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics)

Page 13: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Arduino Programming for Slide potentiometer

• Step 2: Open up an example AnalogReadSerial

• There is a function // read the analog in value:sensorValue = analogRead(analogInPin);

Analog‐to‐Digital Conversion

10‐bit dataDecimal vales : 0 ‐ 1023

Analog signal

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 13

Page 14: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Arduino Programming for Slide potentiometer

Serial Port Monitor

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 14

Page 15: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Challenge: How can we change the scale?

5V

0V

511

0

0

1023

y

x

y = m x + C

1023

0

511

0 yx

Alternative method

1023

511

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 15

Page 16: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Challenge: How can we change the scale?

• Open up another example : AnalogInOutSerial• There is a function 

// mapping of signals

y = map(x, 0, 1023, 0, 255);

Output signal

Input signal

Input range

Output range

Modify this in Arduino Programing to fit the requirement.

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 16

Page 17: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Sensitivity

• Sensitivity =  rate of change in output signal / rate of change in input signal

• Which output signal is more sensitive to the input signal?

// mapping of signals

y1 = map(x, 0, 1023, 0, 511);

y2 = map(x, 0, 1023, 100, 800);

Verify it through Arduino Programing

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 17

Page 18: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Can we use analytical analysis?

• Draw the graphs

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 18

0

1023

y

x

y1

1023

511

y2

Page 19: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 19

• Point – slope Form• It is given than a straight line L with slope m and passing through a point

• Slope – intercept Form• It is given than a straight line L with slope m and cutting the y‐axis (0, c)

Different forms of Straight Line Equation

11, yxA

11 xxmyy

cmxy

Page 20: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 20

• Two ‐ point Form • Given that two points                and              are on the straight line L  

• Intercept Form of L • Given that a straight line L cuts the x‐axis at (a, 0) and the y‐axis at (0, b), where a ≠ 0 and b ≠ 0

11, yxA 22 , yxB

12

12

1

1

xxyy

xxyy

1by

ax

Different forms of Straight Line Equation

Page 21: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 21

• General Form:                         , where A, B and C are constants, and A and B cannot be both zero.

• The slope of the line:

• y‐intercept of the line:

• x‐intercept of the line:

• If a straight line is parallel to the x‐axis, its equation is y = k                  • If a straight line is parallel to the y‐axis, its equation is x = k

General Form of Straight Line Equation

0 CByAx

BA

BC

AC

Which term can be regarded as “sensitivity”?

Page 22: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Analog signal

Digital signal(range: 0 to 1023)

PC Console

Motor Driver

Analog‐to‐Digital Routine

Serial Communication Routine

Digital signal(range: X to Y)

• Digital Signal from ADC  (Range: 0 – 1023)• Case 3:  y3: Digital Signal at PC Console (Range : 0 – 100)  (ascending order)• Case 4:  y4: Digital Signal at PC Console (Range : 300 – 50) (descending order)

Which one is more sensitive?

More exercises

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 22

Page 23: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 23

0

1000

y

x

1023

511

800100

More exercises• Digital Signal from ADC  (Range: 0 – 1023)

• Case 5:  y5: Digital Signal at PC Console with the following graph

Page 24: Lecture 7 - Basic Mathematics Straight Line Equation and ...

Exercises

• Find the line equation of • y1• y3• y4• y5

• Sketch the lines y1, y2, y3, y4, y5 on the same graph

Tim Woo HKUST Dual Program ‐ Level 1 (Engineering ‐ Robotics) 24