Title: CENG4480 Digital Systems Design
1CENG4480 Digital Systems Design
- Hardware project examples
2Overview
- Self balancing robot
- Music robot
- Vision robot
- FPGA projects
3Project 1 Self balance vehicle / robot
- Segway http//www.segway.com/
http//www.ebay.com/itm/Toy-Mechanical-Robot-Remot
e-Walking-Dual-Wheel-Balancing-Multiple-Modes-Kids
-Toy-/111728506257 http//news1.ghananation.com/la
test-news/300907-it-s-the-segway-section-chinese-c
ops-on-patrol-for-shoplifters-on-electric-scooters
.html
4Khw1404 FYP a self balanced robotby HA Ngo Lam,
LEE Yiu Hei supervised by Prof. KH Wong
5The basic idea
- Motion against the tilt angle, so it can stand
upright
6Exercise 5.1IMU board
Student ID __________________Name
______________________Date_______________
(Submit this at the end of the lecture.)
- Inertial Measurement Unit board
- Direction (electronic compass)
- What does it measure? _____________. Absolute or
relative? _____ - Position (accelerometer)
- What does it measure?_____________. Absolute or
relative? _____ - Angular velocity (gyroscope)
- What does it measure?_____________. Absolute or
relative? _____ - Pressure (Barometer)
- What does it measure?_____________ . Absolute or
relative? _____ - Temperature
- What does it measure?______________. Absolute or
relative? _____
7The algorithm is based on two Filter methods
- Kalman Filter
- Complementary Filter
8Algorithm - Kalman Filter
Prediction of New Data
Data Knowledge Base
New Measurement
Update New Data Using Weight Output Average
Output
9See how nosier can be removed by Kalman filter
10Kalman code (lab5 IMU)
- float kalmanCalculate(float newAngle, float
newRate,int looptime) - dt float(looptime)/1000
- x_angle dt (newRate - 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 newAngle - 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
- // 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
11Complementary filter to combine gyroscope and
accelerometer
- Algorithm-complimentary filter
12Complementary Filter to combine gyroscope and
accelerometer
- Combine two sensors for good measurement
- Gyroscope
- response faster but has drift over time
- Accelerometer
- response slower but no drift
- Positive
- If not moving, accelerometer will give accurate
reading of tilt angle - Negative
- Accelerometers are slower to respond than Gyro's
- Accelerometers are prone to vibration/noise
Demo https//www.youtube.com/watch?vjUxU7jsCa-U
Ref http//www.hobbytronics.co.uk/accelerometer-g
yro
13Complementary Filter codein CENG4480 lab 6
- Read_acc()
- Read_gyro()
- //compute interval since last sampling time in
millisecond - interval newMilli - lastMilli
- lastMilli newMilli // save for next loop,
please note interval - // will be
invalid in first sample but we don't use it - Ayzatan2(RwAcc1,RwAcc2)180/PI //angle
measured by accelerometer - Ayz-offset
//adjust to correct balance point - Angy 0.98(AngyGyroIN0interval/1000)0.02Ay
z //complement filter - kang kalmanCalculate(Angy, GyroIN0,interval)
//kalman filter - Serial.print(kang)
- LRspeed 0
14Exercise 5.2
- Explain the operation of the complementary filter
and why do we need to have this filter. - Answer
15A short introduction to digital filter
Gain G(f) in dB
- Analog filter
- Using capacitor resistors, inductors with op-amp
- Digital filter (using digital hardware or
software) - FIR ( Finite Impulse Response, non-iterative)
- IIR (Infinite impulse response, iterative)
3dB
Frequency
16Example Finite Impulse Response (FIR) Low pass
filter (LPF) (one pole)
Analog LPF
- Algorithm
- For an input of x(n)
- x(time 0), x(time 1),x(time2),
- Or X(n0), x(n1), x(n2)
- y(n)gx(n)ax(n-1), if g0.5,a0.5
- y(n)0.5(x(n)x(n-1)) //averaging filter,
- Only use previous signal samples
- Simple to implement (non-iterative) , and stable
Equivalent digital (FIR) LPF
http//soundlab.cs.princeton.edu/learning/tutorial
s/DSP/DSP.html
17Exercise 5.3
- 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
n1,2,3,4,5 if the filter (with g0.6, a0.4) is
y(n)gx(n)ax(n-1) - 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
18Algorithm - PID Control to stabilize robot
Proportional control Kp proportional term
Sum
Motor Speed
Derivative control Kd derivative term
Integral control Ki integral term
IMU Angle
Setpoint
19TUMBLER Version1
20TUMBLER 3
21TUMBLER Version3in action
22 Design
23Kalman code (lab5 IMU)
- float kalmanCalculate(float newAngle, float
newRate,int looptime) - dt float(looptime)/1000
- x_angle dt (newRate - 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 newAngle - 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
- // 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
24PID code in CENG4480lab6
- if ((abs(kang)gtminangle)(abs(kang)ltmaxangle))
- deltakang
- diff delta - last
- diff2 delta - last2
- diff constrain(diff,-maxdiff,maxdiff)
- diff2 constrain(diff2,-maxdiff,maxdiff)
- last2 last
- last delta
- LRspeed Pdelta Iaccuinterval0.001
D(diff100diff2100)/interval - accudelta
- accu constrain(accu,-maxaccu,maxaccu)
-
25Exercise 5.4
- Explain why we need to have PID control.
26Project 2 Chinese flute (Dizi) playing
robotprevious FYP (KHW1101) and MSc (Zhang Hao)
projects, CUHKSupervisor (Prof. KH Wong)
https//www.youtube.com/watch?vNJ7wv2z8Wgk
http//www.ebay.com/itm/Toy-Mechanical-Robot-Remot
e-Walking-Dual-Wheel-Balancing-Multiple-Modes-Kids
-Toy-/111728506257 http//news1.ghananation.com/la
test-news/300907-it-s-the-segway-section-chinese-c
ops-on-patrol-for-shoplifters-on-electric-scooters
.html
27The structure of the Chinese flute playing robot
The air jet head
28PID is used to adjust blowing angle
By a newly designed robots mouth, we aimed solve
this problem next semester.
29Fingering control schemes
30Use of servo motor (positional control motors)
- Servo motors can be controlled by Arduino
directly by open source library.
In CENG4480 Lab 4Self-balancing Tray Robot
Control https//www.youtube.com/watch?vdT56qAZt8h
I
31Exercise 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.
32Blowing mechanism
33Software for pitch adjustment and measurement to
maximum sound quality and volume
34Results
35Western Flute playing robot
- Flute playing by WF-4R II - Sexy Robots Videos
- Flute Robot WF-4RV passive duet performance
-
https//www.youtube.com/watch?vlYDW2A5-Cbw https
//www.youtube.com/watch?vacK_rZEDgLw
36Audio signal processing techniques
37Fourier Transform(use Fast Fourier Transform
--FFT library in embedded systems)
http//wiki.openmusiclabs.com/wiki/ArduinoFFT
Energy in dB
Xm (real2imginary2)
Signal voltage/ pressure level
single freq..
Fourier Transform
Time
S0,S1,S2,S3. SN-1
freq. (m)
Spectral envelop
38Fourier 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_transf
orm.html http//1.bp.blogspot.com/_iCUnH8P-OYo/S7Z
TAluquWI/AAAAAAAAAOM/y-G5aH_w248/s1600/2000px-Four
ier_Series.svg.png
39Example W3W1W2
W1(pure sine) W2(pure sine) W3(complex wave)
Fourier Transform will generate the two outputs
W1 and W2
http//www.slideshare.net/azizulhoque539/311-commu
nication-system-concepts
40Exercise 5.6
http//www.solar-energy-for-home.com/pure-sine-inv
erter.html
- Draw the wave when these two waves are added.
41Exercise 5.7
- Disuses a hardware project that you want to do.
42Project 3 Vision robot
- Based on opencv (http//opencv.org/)
- Demos
- Grand Canyon reconstruction-youtube
- Man Chuen Leung ,Kai Ki Lee, Kin Hong Wong,
Michael Chang, "A Projector-based Hand-held
Display System", CVPR2009 - Man following robot
- Tracking result videos by Zhe Zhang , KH wong
Sept 2014. - Viewing 3-D without spectacles.
43Face edges
http//www.youtube.com/watch?vCDlLe-53a0w
44Application of edges
http//www.youtube.com/watch?vAl4DnNkZUeAfeature
related
http//www.youtube.com/watch?v9F3_6xL8hEYfeature
related
45Rectangular object detection in video
- Stream using the Generalized Hough Transform
http//www.youtube.com/watch?v9r16YiKyaZQfeature
related
http//www.youtube.com/watch?vjPEfoi9g0Lwfeature
related
46Quadrangle detection application
- cvpr09 Projector based Hand Held Display System
http//www.youtube.com/watch?vYHhQSglmuqYfeature
channel_page
475) Mean shift (cam-shift)
http//www.youtube.com/watch?viBOlbs8i7Og
http//www.youtube.com/watch?vzjteYlhjm-sfeature
related
48Face tracking applications
http//www.youtube.com/watch?vi_bZNVmhJ2o
49Demo 3D 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?v2KLFRILlOjc
http//www.youtube.com/watch?vxgCnV--wf2k
http//www.youtube.com/watch?vONx4cyYYyrI
http//www.youtube.com/watch?v4h1pN2DIs6g
50Demo 5
- 3-D display without the use of spectacles.
http//www.youtube.com/watch?voyxR_RT4NNc
51Project 4
- FPGA vision systems
- Edge detection using FPGA
- https//www.youtube.com/watch?v6L_bPeTDHBsfeatur
eyoutu.be - Four point algorithm FPGAARM demo
- https//www.youtube.com/watch?vyDMdCoAg_20featur
eyoutu.be
52END