星期六, 2月 06, 2010

Control a Servo by a Mouse via python and arduino

After I watched this interesting movie, I tried to do it by using python. However, I am a novel of python and arduino, so I spent lots of time to find the reference.



In python, I need:
1. win32gui module: to get the mouse position
2. pySerial module: to send the data to arduino

##CONTINUE##
Here is my python code


import win32gui
import time
import serial

ser = serial.Serial(4)

while (True):
x,y = win32gui.GetCursorPos()
time.sleep(0.2)
pos=int(179*x/1599)
ser.write(chr(pos))
print x,y



And my code in arduino


#include

Servo myservo;
int val;

void setup(){
myservo.attach(9);
Serial.begin(9600);
}

void loop(){
if(Serial.available()){
val=Serial.read();
myservo.write(val);
delay(15);
}
}

星期四, 1月 21, 2010

My New Toy


Recently,I bought the other kind of microcontroller called Arduino. Before this one, I've played Basic Stamp in my lab, but just know a little simple concept. Because Arduino is cheaper than Basic stamp, I bought it for myself and hope I can learn some knowledge about electricity or autocontrol. However, although I have great interest of it, I suppose to study my TOEFL test first because the test date is coming~~~~ T.T

星期四, 1月 14, 2010

Get the signal when pressing mouse left key



A Few weeks ago, I had a project which I need to synchronize two data acquisition system. One is recording force, the other is EMG data. Originally, I hope the force acquisition system can send the analog output to the EMG system, so I can record both data on EMG system. However, the force recording system is too difficult to send the analog output because the manufacture close all the lines in the box.

##CONTINUE##

Another way coming in my mind is to use a analog signal sending to both system. However, as I mentioned before, the force recording system closes all the lines in the box and I can't open it. I was forced to think another solution. Finally, I come up with sending a signal by the mouse when pressing the start of the force recording system so my EMG system can record the time of the beginning of force recording.

However, I know nothing about printed circuit board. I relied on the spirit of try and error to find the two position which can generate 5 voltage when pressing the mouse left key and then wield it.


I know it is nothing for many people, but for me, it's a good experience to do the thing that I have never done before although I accomplished it by try and error.

星期四, 12月 10, 2009

Is CPU with high temperature??!!

Recently, my notebook always shuts down when pressing power. Even the system does not enter bios, the computer shuts down automatically. I tried to find some information today, and one possibility is the self-protection mechanism of CPU.





##CONTINUE##
So, I tried to dismantle the fan and turn on my computer. Then, I found out that the temperature of CPU is so hot and my computer shut down immediately. I observed the fan carefully and found out that there is a big dirty .... cotton??(I don't know how to call it.) You can see in the picture. I know it's very disgusting. However, the problem still exists after I clean the fan.... but the times which the computer shuts down when turning on are less than before and the system seems quicker and more stable. Maybe I will buy a thermal compound and see whether the situation gets better or not.

星期三, 12月 02, 2009

茅場町GRE之戰

次花大錢來日本機考(順便觀光?!),終於有點收穫了,這次總共報名了11/30和12/2號兩場考試,本來想說如果第一天考到500以上,第二天就取消不考,不過事實證明,第一天果來是去模擬考!

##CONTINUE##
  話說PP3真的是歡樂光碟,我考試前做了一回verbal有620,但是我知道,那些題目沒有什麼鑑別度,因為都被背到爛了!這兩天考試的成績分別為
11/30:V 450 Q 800
12/02:V 550 Q 760(第二次V都沒有好好驗算,就直接按確定)

  前面十題真的很重要,填充題不要怕,我第二天考第一題就是填充題,不過說真的,看電腦螢幕上面的題目跟直接在書上看截然不同,其實我在寫PP3的時候就有感覺,那時候原本想把PP3裡面的填充好好練習,不過無奈偷懶沒有去看,第一天考試看到填充真的是心煩意亂,無法靜下心來思考,所以真的建議機考的人,填充一定要練習在螢幕上看,而且就像老方說的,機考沒辦法作記號,選項常常會不小心又重複看,一定要小心。
  
  第一天考試,說真的第一題就遇到本月的機經題,本以為寫得很順,但是大約第四題左右出現填充題,心煩沒有辦法思考,第六題左右又出現短閱,又開始煩悶結果都用猜的,所以最後成績不是很理想。而我女朋友更慘,他加上今天和PP3練習,第一題全部都是碰到填充題,而且今天第一題居然跟我一模一樣,第一天考試,他簡直完全爆炸,V只有慘不忍睹的360(比去年10G還低),所以昨天我跟他在starbucks苦讀韓國兩年,結果今天成績突飛猛進,一下多了210,比我還高!!

  準備方面,約兩個月的時間,雖然去年暑假補過老方,但是10G成績慘不忍睹,V只有370,後來就跑去準備托福,事實證明,不管是GRE或是托福,一次最好認真的準備一樣,不要跳來跳去會浪費很多時間,結果現在托福也還沒破百,準備又要力拼托福。

  準備教材,紅寶書加韓國兩年和陳聖元以及老方寄的11月機經,九月底決定要考GRE就按照17天的計畫,每天每天啃,雖然我的計畫不只17天,但是我依舊保持每天兩個新的Lists,然後加上複習,最多的一天有10Lists要念,由於我在當全職研究助理,所以有時候會調整一天一個新的Lists,但複習依舊,每天都要念到晚上12點到一點才唸完,在這裡真的很感謝我的老闆,因為我在決定要在考GRE的時候,把他交待我要分析的資料(10月份的工作),三天全部拼完,然後寫信跟他說我要考試,能否在工作之餘讓我唸書,他也許被我三天就把工作做完嚇到吧,結果居然答應,哈哈!所以每天除了最行政事物,會是突然有資料需要分析,剩下的時間,我全部拿來唸書。所以認真的在10/18號把紅寶書用17天的方法背完一次,但是依舊有很多字背得不熟,但是這個時候卻進入的唸書倦怠期,也許是之前唸得太拼,結果整整三個禮拜唸書有一搭沒一搭,三個禮拜才又複習一次,結果把原本要念舊CAT的計畫全部打亂,在此建議,CAT有時間就要早點念,結果我反義類比大概都只唸了四分之一,然後我又是個完美主義者,不把紅寶書全部背熟,心裡就覺得怪怪的,所以一直在背紅寶書,直到考試前三天才開始念韓國兩年,結果紅寶書被不起來的字還是背不起來(自認只背好八成)。

  韓國兩年真的不錯,強烈建議早點念,我女朋友跟我一樣拖拖拖,拖到第一天考爆,然後昨天我跟他在starbucks苦讀的時候他才把韓國兩年的反義K完,結果今天考得比我還高!話說我自認為紅寶背得比他還熟。

  填充的話,就像剛剛所說得,一定要在電腦螢幕上練習過,不然真的會心浮氣躁,今天比前天進步的主要原因,我想也是因為比較適應,也比較能靜下心來看題目,陳聖元的話,話說我真的很不認真,去年機考做到27,28回,這次大概做到45回,不過這次在練習的時候,大概是紅寶書單字背比較多了,題目看不懂的單字變少,剩下真的就是在解邏輯概念(還好還記得老方教得),所以後來練習大多是在6,7題的地方出錯,前五題至少都可以把握住。

  最後就是機考前十題真的很重要,一定要好好做,我一開始真的沒有很體認這個重要概念,第一天考得時候只想得要把題目做完,但是第二天真的是認真解,前十題我想我應該只有第九題不確定可能答錯,其他應該都還好,我11題出現短閱,眼看時間已經花了16分鐘,所以又開始心浮氣躁,看了文章雖然不難,但是卻選不出來,結果又開始猜,然後16題開始,長閱短閱連發,真的是,原本想說不想要連錯,但是又因為時間不夠,又開始全猜,後面的類反也因為時間不多就比較沒有時間好好思考,好在最後還是有500。而我女朋友也是,被我這麼一講(其實我是跟他說我第一天數學算很慢很保守,最後三題剩下一分半全部猜,結果還有800),所以他也很注意前十題。

  考到這個成績已經很滿意了,最後真的是可以說,馬的!GRE掰掰啦!