2011年8月30日 星期二

Crystal Oscillator 頻率量測

Crystal Oscillator 晶體震盪器
是一種壓變型的震盪器 利用電壓差於晶體的兩側 使其晶體產生形變
形變之後原先接觸於電極端的接觸點開路 開路之後再次產生形變回復成原先的形狀
原先的形狀會再與電極端接觸 再次產生形變
依此循環而產生波形頻率.
線路結構上會有XTAL_OUT, XTAL_IN

晶體的形變需要在線路的兩個極點增加對地電容
震盪出來的頻率才會穩定~
而傳統設計在對地電容會有3倍,3倍的設計上會使得震盪器較容易起震
現今的設計上較少使用到3倍電容值的設計.

其電性的等效參數 會考慮到IC內的電容、震盪器內部電容、外部對地電容
經過計算後會得到一個負性電阻~ 該負性電阻的阻值越高(指負的越多)
會讓晶體震盪得更穩定 對溫度的特性也會更好.

一般在量測上會有三種方式
1. Oscilloscope 示波器
2. Counter 計數器
3. Spectrum 頻譜分析儀

前兩種方式是使用探測棒(Probe)接觸 但是Probe本身大約會有50pF的容值存在
此會影響到整體震盪的等效電路電容值改變
有可能會使得原本不震而震 或是該震的而不震
也有可能造成量測的頻率與實際頻率有差異

第三種方式是將Probe放置在線路的防焊層上 較不易因為 Probe內電容造成參數的改變
但是Spectrum的價格上較高 使用上也較不簡便~



今天實驗了另一種方法
將原先震盪器的線路斷掉,改接一條較粗的漆包線…
並在漆包線外圍使用長度約10cm 較細的漆包線纏繞
利用電磁的特性去感應粗漆包線上因震盪而發散的磁場

使用Probe接觸細漆包線上的裸銅處,Probe的Ground接觸待測物的Ground。
用Scope或Counter量測頻率

此種方法不會因為探棒的電容特性而改變震盪線路的等效電容
在量測上較為客觀。

補參考連結
TXC 台灣晶技
這篇算是介紹得不錯

2011年3月16日 星期三

Visual 2008 C# SerialPort RX thread issue.

平台 Windows XP 32bit, Profilc PL2303
Language Visual 2008 C#

遇到的問題是Serial Port的接收使用Threading的方式作.

程式片段
static Thread comport_recv_thread;
static bool comport_recv_thread_flag;
void comport_open()
{
comport_recv_thread = new Thread(comport_recv);
....set com port...
comport_recv_thread_flag = true;
serialPort1.ReadTimeOut = 500;
serialPort1.Open();
comport_recv_thread.Start();
}

void comport_close()
{
comport_recv_thread_flag = false;

//while(serialPort1.IsAlive);
// Die

//while(true) if(serialPort1.IsAlive == false)
//comport_recv_thread.Join();
//Die

//comport_recv_thread.Join();
// Die

//timer1.Interval = 2000;
//timer1.Tick += new EventHandler(comport_close_by_timer);
//timer1.Start()
// Work but when open again, will error.

while(serialPort1.IsAlive) Application.DoEvents();
// Work.
serialPort1.Close();
}

private void comport_recv()
{
while(comport_thread_flag)
{
//Do something
try
{
//Read from serial port
}
catch(TimeoutException)
{ }
}
}

感覺問題是出在Read Time out 的時間點
只要還沒出現timeout的情形下使用Join()
程式就會卡死沒有反應

同時若是有一個空迴圈在跑也會影響到timeout.
目前是用Application.DoEvents();
不讓迴圈搶走太多資源 同時也讓timeout可以動作

2011年2月25日 星期五

Virtual Floppy Drive 2.1 for Windows 7 64 bit issue

VFD 2.1 is a Floppy Drive emulator with GNU/GPL License.

There are written "This is a virtual floppy drive for Windows NT / 2000 / XP / 2003 / Vista / Windows 7 (both 32-bit and 64-bit versions)" . But when launch it in Windows 7 64bit, it will show the following alert window.









I browse the bug tracker, and using google search.
There are many people had met this issue and not solve it yet.
But I am lucky that get one result can help me to solve this issue.

They provide patched source code and final binary.
Download the binary and overwrite the original file.
Try to launch it again and it is workable in Windows 7 64 bit.
But I am not checking it in 32 bit system.

The following link is original package and fixed package.
http://saren.twbbs.org/tools/v/VFD2.1%20x86.7z
http://saren.twbbs.org/tools/v/VFD2.1%20x86_64.7z

If it can't install, using Administrator to launch it.
If it can't start, stop WHQL when starting/rebooting Windows 7 and press F8 to disable WHQL.

Virtual Floppy Drive 2.1 for Windows 7 64 bit issue

Virtual Floppy Drive

這是一套在Windows下模擬磁碟機的虛擬驅動程式~
符合GNU/GPL Open Source的開放原始碼~

原始網頁上有註明「This is a virtual floppy drive for Windows NT / 2000 / XP / 2003 / Vista / Windows 7 (both 32-bit and 64-bit versions)」

而實際使用上若是在Windows 7 64bit下會秀出以下的錯誤訊息








搜尋VFD的Bug Tracker後確認不是個案
有一說法是在Windows 7 64bit下會發生 而32則是正常的

有幸搜尋到有人修改過原始碼 使得可以支援64bit

而在網頁上有提供修改過後的程式 只需要下載後覆蓋原始的檔案~
但是目前手邊沒有32bit的機器可以測試.

以下是包好的壓縮檔 有需要的可以自行下載
http://saren.twbbs.org/tools/v/VFD2.1%20x86.7z
http://saren.twbbs.org/tools/v/VFD2.1%20x86_64.7z

若是在Windows 7或Vista可能因為安全性而無法安裝
需先以系統管理者的權限啟動
同時Start時會因為WHQL認證而無法啟動
需重開機時按下F8停用WHQL認證