Wednesday, May 26, 2010

Google Pacman!!

Now you can play pacman in google!!

visit -->

Have Fun

Thursday, May 20, 2010

Cadence: .cdsinit file setup

Here provide some important setup in the .cdsinit cadence file

.cdsinit file

;To enable the bindkey in layout and schematic in Cadence
let( (bindKeyFileList file path saveSkillPath)
bindKeyFileList = '(

;My simulation environment setup
envSetVal("asimenv" "saveDir" 'string "./artist_states")
envSetVal("asimenv.startup" "projectDir" 'string "./simulation")
envSetVal("asimenv.startup" "cds_ade_wftool" 'string "awd")

;To make sure simulator does not save all nodes but selected nodes, otherwise the sim file size is big
envSetVal("spectre.outputs" "save" 'string "selected")

;First row: set the artist_states directory path
;Second row: set project directory path
;Third row: Set AWD as a default waveform viewer

Tuesday, May 18, 2010

MATLAB: Plot 2 Y-Axes

Here is the MATLAB tutorial about plotting a graph with two y axes.
Plotyy function is used to perform the task. Besides this, it also shows how to set/configure the 2 y-axes by using "set" function. In this example, it sets the Y limit range, auto Y tick, line style, marker, line width, title.

To retrieve data from a csv file, use the "load" function. It is easy to use however it is not allowed to have column header. Thus, column headers are required to be deleted manually.

clc %clear working screen
clear %clear all memory
close %close all figure

format short eng
%format short e %format short g
linewidth=1.5; %set line width of a plot

file = 'fixed_Iden_nonlinear1V_5mA_w10u_2.csv';
temp = load(file, '-ascii'); %load a file with data
%[row,col]=size(temp) ; %find row & col size

%retrieve data
ntime = temp(:, 1);
Iden = temp(:, 2);
Av = temp(:, 3);
BW = temp(:, 4);
GBW = temp(:, 5);
Vsw = temp(:, 6);

plotyy(ntime, Av, ntime, BW) %plot with two y axes

[AX,Y1,Y2]=plotyy(ntime, Av, ntime, BW,'plot') ;

%Property_AX=get(AX(1)) %to check property of AX
set(AX(1),'XMinorTick', 'on') %enable minor tick on x-axis
set(AX(1),'YLim',[1.55 1.65]) % Change Y1 axis limit range
set(AX(1),'YTickMode','auto') % Change YTick become auto
set(AX(2),'YTickMode','auto') % Change YTick become auto
set(Y1,'LineStyle','-', 'Marker','o', 'LineWidth', linewidth )
set(Y2,'LineStyle','-', 'Marker','x', 'LineWidth', linewidth )
%set(Y1,'LineStyle','-', 'Marker','o', 'Color','b', 'LineWidth', linewidth ) %set(Y2,'LineStyle','-', 'Marker','x', 'Color','g', 'LineWidth', linewidth )

title('Voltage Gain & Bandwith vs m Ratio');
set(get(AX(1),'Ylabel'),'String','Voltage Gain, A _V (V/V)')
set(get(AX(2),'Ylabel'),'String','Bandwidth, BW (Hz)')
xlabel('m Ratio');

legend( Y1,'A _V', 'Location','Best')
legend( Y2,'Bandwidth', 'Location','SouthEast')

plot(ntime, GBW,'-
%Plot property put after all plots

title('Gain Bandwidth Product vs m Ratio');
set(gca,'XMinorTick', 'on')
ylabel('Gain-Bandwidth Product (V/V Hz)');
xlabel('m Ratio');


Saturday, May 15, 2010

No Such Thing as ‘Straight’

(source from

The textbook definition of “straight” is something that has no bends, angles or curves. Can we apply that same definition to life? Heck no!

There really isn’t such thing as “straight” in the universe. At the core of everything—including us—is energy, and energy doesn’t travel straight. It travels in waves. Imagine throwing a pebble into a lake, watching the ripples gliding across the surface.

Right after you throw your pebble, someone else also tosses a pebble in the same lake, and now the ripples from that pebble collide with the ripples from yours. That’s how everything in this universe works.

People, events, actions and reactions are constantly colliding, creating new pathways, new situations, new circumstances and new actions. The chaos of life makes it almost impossible for anyone to always go “straight” to where they planned.

Some people thrive on chaos and change, but most people don’t. They get frustrated, down, and ready to throw in the towel because they usually have expectations, and these expectations are usually damn near impossible to meet.

We might as well just accept it: the road to success comes with twists, turns, ups, downs, stops and reverses. Once we really understand and accept this, we’re less likely to be deluded into having unrealistic expectations that there’s a straight line to the top. So when we come across bumps, flat tires, and raised bridges along the way, we won’t be so quick to get upset or give up. Getting off track is normal and therefore “perfect.”

You have to expect to spend a great deal of time making mistakes—or if it sounds better—“correcting yourself.” There’s a reason why perfectionists have a hard time being highly successful. Perfectionism is a form of fear, based on fear of failure or the fear of disapproval.

If perfectionists don’t get it exactly right, then they don’t have to finish, follow through, and move on. They get to stay stuck “until its right,” but of course it’ll never be right, so they never have to face the possibility of rejection or disappointment.

We need to consider mistakes—rather than something to be avoided at all costs—instead as “feedback.” Mistakes are our perfectly natural learning curve. They are the feedback we need to get ourselves back on track.

Then we can do the same thing we already know we need to do in order to keep moving forward: take action! Those actions will produce results, sometimes more mistakes. Then we just get that feedback, use it to correct our course again, and then take more action.

This is the non-linear cycle toward success. As long as you use this cycle—and persevere—it’s virtually impossible to fail.

Remember, we’re all ripples in the lake of the universe. You never know how a comment, observation, or minor detail can change the course of your life or another’s!

Now It’s Your Turn!

Wednesday, May 12, 2010


Our Birth is our Opening Balance!
Our Death is our Closing Balance!
Our Prejudiced Views are our Liabilities
Our Creative Ideas are our Assets

Heart is our Current Asset
Soul is our Fixed Asset
Brain is our Fixed Deposit
Thinking is our Current Account

Achievements are our Capital
Character & Morals, our Stock-in-Trade
Friends are our General Reserves
Values & Behaviour are our Goodwill

Patience is our Interest Earned
Love is our Dividend
Children are our Bonus Issues
Education is Brands / Patents

Knowledge is our Investment
Experience is our Premium Account
The Aim is to Tally the Balance Sheet Accurately.
The Goal is to get the Best Presented Accounts Award.


Some very Good and Very bad things …..

The most destructive habit.....................Worry
The greatest Joy......... ......................Giving
The greatest loss..................Loss of self-respect

The most satisfying work.................Helping others
The ugliest personality trait..............Selfishness
The most endangered species........Dedicated leaders
Our greatest natural resource..................Our youth

The greatest 'shot in the arm'.........Encouragement
The greatest problem to overcome...............Fear
The most effective sleeping pill.......Peace of mind
The most crippling failure disease.............Excuses

The most powerful force in life................... Love
The most dangerous act..............................A gossip
The world's most incredible computer.........The brain
The worst thing to be without..................... Hope

The deadliest weapon...... ........ .........The tongue
The two most power-filled words....... .... 'I Can'
The greatest asset....... .......... ......... ...........Faith
The most worthless emotion..................Self- pity

The most beautiful attire........................SMILE!
The most prized possession.................Integrity
The most powerful channel of communication. ……..Prayer
The most contagious spirit................Enthusiasm

Life ends; when you stop Dreaming,
Hope ends; when you stop Believing,
Love ends; when you stop Caring,
And Friendship ends; when you stop Sharing...!!!

Tuesday, May 11, 2010

What kind of sleeper are you?

(copy from

Ever wondered what your sleeping position says about the kind of person you are? A survey of 1,000 British reveals that the six most common sleeping patterns are indicative of personality types.

Six most common sleeping positions (Graphic from

Foetus position: A whopping 41% of participants sleep in this curled-up manner. Women are twice as likely to rest like this and it is listed as the most common position. These sleepers are said to have a tough exterior but are still sensitive and may appear to be shy but warm up quickly.

Log position – If you sleep on your side with both arms down, you are a social, easy-going person who is trusting, sometimes to the point of being gullible. The study showed 15% of people sleep like a log.

Yearner position - A close third is the side-lying position with both arms out in front of the body, with 13% of partipants sleeping like this. Yearners are noted to be open-minded and still cynical, suspicious, and stubborn about sticking to decisions once they are made.

Soldier position - These sleepers lie on their backs with arms down and kept close to the body. This 8% study is said to be reserved, quiet, without fuss, and hold themselves and others to a high standard. Soldier sleepers have a higher likelihood for snoring due to the flat-back position, which may not cause them to wake up often but may result in a less restful night’s sleep.

Freefall position - Those people who lie on their bellies with arms under or wrapped around a pillow with head turned to the side, make up 7% of the population studied. Freefallers are brash, outgoing, and are very uncomfortable with criticism.

Starfish position - Sleepers who lie on their backs with arms up near their head or the pillow account for 5% of participants. These people are good listeners, helpful, and are uncomfortable being the center of attention. People who sleep in starfish position are more likely to snore and to suffer from a poor night’s sleep more often.

Original article here:

Wednesday, May 05, 2010



梁繼璋先 生是香港一位名電臺節目主持人,也是一位兒童心理學導師。

這是梁繼 璋寫給兒子的信;但看後,我覺得不只給兒子,其實可以適合所有人看!


寫這備忘 錄給你,基於三個原則:

(一)人 生福禍無常,誰也不知可以活多久,有些事情還是早一點說好

(二)我 是你的父親,我不跟你說,沒有人會跟你說

(三)這 備忘錄裏記載的,都是我經過慘痛失敗得回來的體驗,可以為你的成長省回不
少冤枉 路。

以下,便 是你在人生中要好好記住的事:

1.對你 不好的人,你不要太介意:在你一生中,沒有人有義務要對你好,除了我和你媽
媽。至於 那些對你好的人,你除了要珍惜、感恩外,也請多防備一點,因為,每個
人做每件 事,總有一個原因,他對你好,未必真的是因為喜歡你,請你必須搞清楚,而
不必太快 將對方看作真朋友

2.沒有 人是不可代替,沒有東西是必須擁有:看透了這一點,將來你身邊的人不再要
你,或許 失去了世間上最愛的一切時,也應該明白,這並不是甚麼大不了的事

3.生命 是短暫的,今日你還在浪費著生命,明日會發覺生命已遠離你了:因此,愈早珍
惜生命, 你享受生命的日子也愈多,與其盼望長壽,倒不如早點享受 上並沒有最愛這回事:愛情只是一種霎時的感覺,而這感覺絕對會隨時日、心境
而改變。 如果你的所謂最愛離開你,請耐心地等候一下,讓時日慢慢沖洗,讓心靈
慢慢沉 澱,你的苦就會慢慢淡化。不要過分憧憬愛情的美,不要過分誇大失戀的悲

5.雖 然,很多有成就的人士都有受過很多教育,但並不等如不用功讀書,就一定可以成
:你學到的知識,就是 你擁有的武器!人,可以白手興家,但不可以手無寸鐵,緊

6.我不 會要求你供養我下半輩子,同樣地我也不會供養你的下半輩子,當你長大到可以
獨立的時 候,我的責任已經完結:以後,你要坐巴士還是Benz,吃魚翅還是粉
絲,都要 自己負責

7.你可 以要求自己守信,但不能要求別人守信,你可以要求自己對人好,但不能期待人
家對你好:你怎樣對人,並不代 表人家就會怎樣對你,如果看不透這一點,你只會
徒添不必 要的煩惱

8.我買 了十多二十年六合彩,還是一窮二白,連三獎也沒有中,這證明人要發達,還是
要努力工 作才可以,世界上並沒有免費午餐

9.親人 只有一次的緣份,無論這輩子我和你會相處多久,也請好好珍惜共聚的時光,下
輩子,無 論愛與不愛,都不會再見

你的爸爸 梁繼璋

這不就是 真實人生的寫照嗎?!真實不一定要現實!珍惜所擁有的!把握當下!~共勉

Sunday, May 02, 2010

Matlab: Control theory (transfer_function, bode,rootlocus

Here is a simple Matlab code for control theory like bode plot, root locus, and transfer function. You could either use symbolic method, which using 's' as Laplace symbol or directly key in into vector form (easier).


syms s %construct symbolic object




display('Inverse Laplace for F3(s):')

[num,den]=numden(F3); %extract symbolic numerator and denominator
num=sym2poly(num); %form vector for numerator
den=sym2poly(den); %form vector for denominator

Gtf=tf(num,den) %G(s) in polynomial form
Gzpk=zpk(Gtf) %convert G(s) to factored form

rlocus(Gzpk) %root locus plot
%sgrid %turn on grid for damping ratio

%bode(Gzpk) %bode plot
margin(Gzpk) %find and plot phase & gain margin


(20 s + 60) (s + 7)
(s + 5) (s + 2)


s + 8 s + 16


(20 s + 60) (s + 7)
2 2
(s + 5) (s + 2) (s + 8 s + 16)

Inverse Laplace for F3(s):

- 80/9 exp(-5 t) + (25/3 t - 10/9) exp(-2 t) + (-15 t + 10) exp(-4 t)

Transfer function:
20 s^2 + 200 s + 420
s^5 + 17 s^4 + 112 s^3 + 356 s^2 + 544 s + 320

20 (s+7) (s+3)
(s+5) (s+4)^2 (s+2)^2


the red color indicates display problem when posting them in html (displacement)

Here is the Matlab code for bode plot. It plots out both open loop & close loop response for comparison.

num=1.61e12*poly( -1.37e6);
den=poly([0 0 -2.6e6]);
G=tf(num,den) %open loop
T=feedback(G,1); %negative feedback 1 (close loop)

%grid on

%grid on

figure %create new figure
hold on %allow overlap
%grid on