2013年8月30日 星期五

Interfacing microcontrollers to external devices

在microcontroller(MCU)中,來連接外部設備(device)時,一般的MCU可以直接連接TTL level的(eg. display,sound,motor,relay..)而對於其它(CMOS)的準備也可以接上IC來驅動(MX232)。但最主要的並不是其voltage(電壓)而是其電流(current)。(其MCU的驅動單位,功率 p=vi)

而在不同品牌MCU、不同類型(8x51,AVR,PCI及ARM)中,甚至不同port (pin)都有不同的驅動能力。

問題:

若在你需要連接10個LED,且每個都要20mA. 則你需要200mA.

A.

准雙向I/O埠/弱上拉(標
準8051輸出模式)、強推挽輸出/強上拉、僅為輸入(高阻)
或開漏輸出功能

image

image

image

image

image

A1.定其為標準的輸入/出 腳位

加上bjt amplifying transistor

image

其中R3為為限流電阻,其計算方法為粗約計算

設 diode requires Id=20mA, transistor Ic=100mA, VDD=5V.

R3=5/0.02=250K . 而R1及R2為voltage divider.

A2.

使用Darlington array driver(ULN2002)來代替個別的transistor,

每個腳位可提供100mA的驅動能力。

 

B.情況二,外接功率高的裝置(light bulb,110v)

B1.以relay 取代diode.

這時,你不能將relay直接接到MCU上,因為其relay switch時會damage port ping

It is important to add VD1 backward diode which protects transistor high voltage ‘spikes’ produced when the relay coil is switching

image

 

輸入時,

1.

image

有些MCU有內建其R(pull register),即只需接上switch即可。

image

image

image

image

image

image

image

image

image

image

2.

image

沒有留言:

張貼留言