CENG 4480 Digital Systems Design Hardware project examples




















































- Slides: 52
CENG 4480 Digital Systems Design Hardware project examples (v. 5 d) 1
Overview 1) 2) 3) 4) Self balancing robot Music robot Vision robot FPGA projects Hardware project examples (v. 5 d) 2
Project 1: Self balance vehicle / robot § Segway http: //www. segway. com/ Hardware project examples (v. 5 d) http: //www. ebay. com/itm/Toy-Mechanical-Robot-Remote-Walking-Dual-Wheel-Balancing-Multiple-Modes-Kids-Toy-/111728506257 http: //news 1. ghananation. com/latest-news/300907 -it-s-the-segway-section-chinese-cops-on-patrol-for-shoplifters-on-electric-scooters. html 3
Khw 1404 FYP a self balanced robot by HA Ngo Lam, LEE Yiu Hei supervised by Prof. KH Wong § Hardware project examples (v. 5 d) 4
The basic idea § Motion against the tilt angle, so it can stand upright Hardware project examples (v. 5 d) 5
Exercise 5. 1 IMU board Student ID: _________ Name: ___________ Date: ________ (Submit this at the end of the lecture. ) § Inertial Measurement Unit board l Direction (electronic compass) • What does it measure? _______. Absolute or relative? _____ l Position (accelerometer) • What does it measure? _______. Absolute or relative? _____ l Angular velocity (gyroscope) • What does it measure? _______. Absolute or relative? _____ l Pressure (Barometer) • What does it measure? _______. Absolute or relative? _____ l Temperature • What does it measure? _______. Absolute or relative? _____ Hardware project examples (v. 5 d) 6
The algorithm is based on two Filter methods § Kalman Filter § Complementary Filter Hardware project examples (v. 5 d) 7
Algorithm - Kalman Filter § New Measurement Prediction of New Data Knowledge New Measurement Update New Data Using Weight Base Output Average Output Hardware project examples (v. 5 d) 8
See how nosier can be removed by Kalman filter § Hardware project examples (v. 5 d) 9
§ Kalman code (lab 5: IMU) § // Kalman filter module § § § float Q_angle = 0. 001; float Q_gyro = 0. 003; float R_angle = 0. 03; § § § float x_angle = 0; float x_bias = 0; float P_00 = 0, P_01 = 0, P_10 = 0, P_11 = 0; float dt, y, S; float K_0, K_1; § § Hardware project examples (v. 5 d) § § § § § float kalman. Calculate(float new. Angle, float new. Rate, int looptime) { dt = float(looptime)/1000; x_angle += dt * (new. Rate - x_bias); P_00 += - dt * (P_10 + P_01) + Q_angle * dt; P_01 += - dt * P_11; P_10 += - dt * P_11; P_11 += + Q_gyro * dt; y = new. Angle - x_angle; S = P_00 + R_angle; K_0 = P_00 / S; K_1 = P_10 / S; x_angle += K_0 * y; x_bias += K_1 * y; P_00 -= K_0 * P_00; P_01 -= K_0 * P_01; P_10 -= K_1 * P_00; P_11 -= K_1 * P_01; return x_angle; } 10
Complementary filter to combine gyroscope and accelerometer § Algorithm-complimentary filter Gyroscope Accelerometer Integration Complimentary Filter (weighted average) Angle output Kalman Filter Hardware project examples (v. 5 d) 11
Complementary Filter to combine gyroscope and accelerometer § Combine two sensors for good measurement: § Gyroscope l response faster but has drift over time § Accelerometer l l response slower but no drift Positive Demo https: //www. youtube. com/watch? v=j. Ux. U 7 js. Ca-U • If not moving, accelerometer will give accurate reading of tilt angle l Negative • Accelerometers are slower to respond than Gyro's • Accelerometers are prone to vibration/noise Ref: http: //www. hobbytronics. co. uk/accelerometer-gyro Hardware project examples (v. 5 d) 12
Complementary Filter code in CENG 4480: lab 6 § § § Read_acc(); Read_gyro(); //compute interval since last sampling time in millisecond interval = new. Milli - last. Milli; last. Milli = new. Milli; // save for next loop, please note interval // will be invalid in first sample but we don't use it Ayz=atan 2(Rw. Acc[1], Rw. Acc[2])*180/PI; //angle measured by accelerometer Ayz-=offset; //adjust to correct balance point Angy = 0. 98*(Angy+Gyro. IN[0]*interval/1000)+0. 02*Ayz; //complement filter kang = kalman. Calculate(Angy, Gyro. IN[0], interval); //kalman filter Serial. print(kang); LRspeed = 0; Hardware project examples (v. 5 d) 13
Exercise 5. 2 § Explain the operation of the complementary filter and why do we need to have this filter. § Answer: Hardware project examples (v. 5 d) 14
A short introduction to digital filter Gain G(f) in d. B § Analog filter l Using capacitor resistors, inductors with op-amp 3 d. B § Digital filter (using digital hardware or software) l l FIR ( Finite Impulse Response, non-iterative) IIR (Infinite impulse response, iterative) Hardware project examples (v. 5 d) Frequency 15
Example: Finite Impulse Response (FIR) Low pass filter (LPF) (one pole) § Algorithm § For an input of x(n): l l x(time =0), x(time =1), x(time=2), … Or X(n=0), x(n=1), x(n=2)… Analog LPF Equivalent digital (FIR) LPF § y(n)=g*x(n)+a*x(n-1), if g=0. 5, a=0. 5 § y(n)=0. 5(x(n)+x(n-1)) //=averaging filter, § Only use previous signal samples § Simple to implement (non-iterative) , and stable Hardware project examples (v. 5 d) http: //soundlab. cs. princeton. edu/learning/tutorials/DSP. 16
Exercise 5. 3 a) If you have a signal x(0), x(1), x(2), x(3), x(4), x(5). Write the filter output y(n) for time is n=1, 2, 3, 4, 5 if the filter (with g=0. 6, a=0. 4) is y(n)=g*x(n)+a*x(n-1) b) If x(0)=4, x(1)=3, x(2)=7, x(3)=5, x(4)=6. 2, x(5)=9, what is the value of y(5)? § Answers: Hardware project examples (v. 5 d) 17
Algorithm - PID Control to stabilize robot Setpoint Proportional control Kp * proportional term Sum Derivative control Integral control Ki * integral term Kd * derivative term Motor Speed IMU Angle Hardware project examples (v. 5 d) 18
TUMBLER Version 1 § Hardware project examples (v. 5 d) 19
TUMBLER 3 § Hardware project examples (v. 5 d) 20
TUMBLER Version 3 in action § Hardware project examples (v. 5 d) 21
Design § Hardware project examples (v. 5 d) 22
§ Kalman code (lab 5: IMU) § // Kalman filter module § § § float Q_angle = 0. 001; float Q_gyro = 0. 003; float R_angle = 0. 03; § § § float x_angle = 0; float x_bias = 0; float P_00 = 0, P_01 = 0, P_10 = 0, P_11 = 0; float dt, y, S; float K_0, K_1; Hardware project examples (v. 5 d) § § § § § float kalman. Calculate(float new. Angle, float new. Rate, int looptime) { dt = float(looptime)/1000; x_angle += dt * (new. Rate - x_bias); P_00 += - dt * (P_10 + P_01) + Q_angle * dt; P_01 += - dt * P_11; P_10 += - dt * P_11; P_11 += + Q_gyro * dt; y = new. Angle - x_angle; S = P_00 + R_angle; K_0 = P_00 / S; K_1 = P_10 / S; x_angle += K_0 * y; x_bias += K_1 * y; P_00 -= K_0 * P_00; P_01 -= K_0 * P_01; P_10 -= K_1 * P_00; P_11 -= K_1 * P_01; return x_angle; } 23
PID code in CENG 4480: lab 6 § § § if ((abs(kang)>=minangle)&&(abs(kang)<maxangle)){ delta=kang; diff = delta - last; diff 2 = delta - last 2; diff = constrain(diff, -maxdiff, maxdiff); diff 2 = constrain(diff 2, -maxdiff, maxdiff); last 2 = last; last = delta; LRspeed = P*delta + I*accu*interval*0. 001 + D*(diff*100+diff 2*100)/interval; accu+=delta; accu = constrain(accu, -maxaccu, maxaccu); } Hardware project examples (v. 5 d) 24
Exercise 5. 4 § Explain why we need to have PID control. Hardware project examples (v. 5 d) 25
Project 2: Chinese flute (Dizi) playing robot previous FYP (KHW 1101) and MSc (Zhang Hao) projects, CUHK Supervisor (Prof. KH Wong) https: //www. youtube. com/watch? v=NJ 7 wv 2 z 8 Wgk Hardware project examples (v. 5 d) http: //www. ebay. com/itm/Toy-Mechanical-Robot-Remote-Walking-Dual-Wheel-Balancing-Multiple-Modes-Kids-Toy-/111728506257 http: //news 1. ghananation. com/latest-news/300907 -it-s-the-segway-section-chinese-cops-on-patrol-for-shoplifters-on-electric-scooters. html 26
The structure of the Chinese flute playing robot § The air jet head Hardware project examples (v. 5 d) 27
PID is used to adjust blowing angle § By a newly designed robot’s mouth, we aimed solve this problem next semester. Hardware project examples (v. 5 d) 28
Fingering control schemes § Hardware project examples (v. 5 d) 29
Use of servo motor (positional control motors) § Servo motors can be controlled by Arduino directly by open source library. In CENG 4480 Lab 4: Self-balancing Tray Robot Control https: //www. youtube. com/watch? v=d. T 56 q. AZt 8 h. I Hardware project examples (v. 5 d) 30
Exercise 5. 5 § What is the difference between a DC motor and a servo motor? § Discuss how to control a servo motor by an embedded system. Hardware project examples (v. 5 d) 31
Blowing mechanism § Hardware project examples (v. 5 d) 32
Software for pitch adjustment and measurement to maximum sound quality and volume § Hardware project examples (v. 5 d) 33
Results § Hardware project examples (v. 5 d) 34
Western Flute playing robot § Flute playing by WF-4 R II - Sexy Robots Videos § Flute Robot WF-4 RV passive duet performance § https: //www. youtube. com/watch? v=l. YDW 2 A 5 -Cbw https: //www. youtube. com/watch? v=ac. K_r. ZEDg. Lw Hardware project examples (v. 5 d) 35
Audio signal processing techniques § Hardware project examples (v. 5 d) 36
Fourier Transform (use Fast Fourier Transform --FFT library in embedded systems) http: //wiki. openmusiclabs. com/wiki/Arduino. FFT § Energy in d. B |Xm|= (real 2+imginary 2) single freq. . Signal voltage/ pressure Fourier Transform level Time S 0, S 1, S 2, S 3. … SN-1 Spectral envelop Hardware project examples (v. 5 d) freq. (m) 37
Fourier Transform concept § Any signals can be decomposed into some pure sine and cosine wave components, each with a certain frequency and amplitude. § Fourier transform is a way to find the frequencies and amplitudes of these components Example: The square wave has all the frequencies inside http: //www. chemicool. com/definition/fourier_transform. html http: //1. bp. blogspot. com/_i. CUn. H 8 P-OYo/S 7 ZTAluqu. WI/AAAAAOM/y. G 5 a. H_w 248/s 1600/2000 px-Fourier_Series. svg. png Hardware project examples (v. 5 d) 38
Example: W 3=W 1+W 2 § W 1(pure sine) W 2(pure sine) W 3(complex wave) Fourier Transform will generate the two outputs W 1 and W 2 http: //www. slideshare. net/azizulhoque 539/311 -communication-system-concepts Hardware project examples (v. 5 d) 39
http: //www. solar-energy-for-home. com/pure-sine-inverter. html Exercise 5. 6 § Draw the wave when these two waves are added. Hardware project examples (v. 5 d) 40
Exercise 5. 7 § Disuses a hardware project that you want to do. Hardware project examples (v. 5 d) 41
Project 3: Vision robot § Based on opencv (http: //opencv. org/) Feature SFM For 3 D display Structure from motion Or to control robot § Demos l l l Grand Canyon reconstruction-youtube Man Chuen Leung , Kai Ki Lee, Kin Hong Wong, Michael Chang, "A Projector-based Hand-held Display System", CVPR 2009 Man following robot Tracking result videos by Zhe Zhang , KH wong Sept 2014. Hardware project examples (v. 5 d) Viewing 3 -D without spectacles. 42
Face edges § Demo http: //www. youtube. com/watch? v=CDl. Le-53 a 0 w Hardware project examples (v. 5 d) 43
Application of edges § Lane detection http: //www. youtube. com/watch? v=Al 4 Dn. Nk. ZUe. A&feature=related http: //www. youtube. com/watch? v=9 F 3_6 x. L 8 h. EY&feature=related Hardware project examples (v. 5 d) 44
Rectangular object detection in video § Stream using the Generalized Hough Transform http: //www. youtube. com/watch? v=9 r 16 Yi. Kya. ZQ&feature=related http: //www. youtube. com/watch? v=j. PEfoi 9 g 0 Lw&feature=related Hardware project examples (v. 5 d) 45
Quadrangle detection application § cvpr 09 Projector based Hand Held Display System http: //www. youtube. com/watch? v=YHh. QSglmuq. Y&feature=channel_page Hardware project examples (v. 5 d) 46
5) Mean shift (cam-shift) http: //www. youtube. com/watch? v=i. BOlbs 8 i 7 Og http: //www. youtube. com/watch? v=zjte. Ylhjm-s&feature=related Hardware project examples (v. 5 d) 47
Face tracking applications § Face change http: //www. youtube. com/watch? v=i_b. ZNVmh. J 2 o Hardware project examples (v. 5 d) 48
Demo: 3 D reconstruction (see also http: //www. cse. cuhk. edu. hk/khwong/demo/index. html) (Click picture to see movie) § Grand Canyon Demo § Flask § Robot http: //www. youtube. com/watch? v=2 KLFRILl. Ojc http: //www. youtube. com/watch? v=xg. Cn. V--wf 2 k http: //www. youtube. com/watch? v=ONx 4 cy. YYyr. I http: //www. youtube. com/watch? v=4 h 1 p. N 2 DIs 6 g Hardware project examples (v. 5 d) 49
Demo 5 § 3 -D display without the use of spectacles. http: //www. youtube. com/watch? v=oyx. R_RT 4 NNc Hardware project examples (v. 5 d) 50
Project 4 § FPGA vision systems l Edge detection using FPGA l https: //www. youtube. com/watch? v=6 L_b. Pe. TDHBs&feature=youtu. be l l Four point algorithm FPGA+ARM demo https: //www. youtube. com/watch? v=y. DMd. Co. Ag_20&feature=youtu. be Hardware project examples (v. 5 d) 51
END Q & A Hardware project examples (v. 5 d) 52