2011年6月14日 星期二

AVR PWM功能的數控恒流源

http://www.mcufan.com/article/hengliuyuan-avrpwm.htm   

      隨著電子技術的深入發展,各種智慧型儀器器越來越多,涉及領域越來越廣,而儀器對電源的要求也越來越高。現今,電源設備有朝著數位化方向發展的趨勢。然而絕大多數數控電源設計是通過高位數的A/DD/A晶片來實現的,這雖然能獲得較高的精度,但也使得成本大為增加。本文介紹一種基於AVR單片機PWM功能的低成本高精度數控恒流源,能夠精確實現02A 恒流。


系統框圖
      圖1為系統的總體框圖。本系統通過小鍵盤和LCD實現人機交流,小鍵盤負責接收要實現的電流值,LCD 12864負責顯示。AVR單片機根據輸入的電流值產生對應的PWM波,經過濾波和功放電路後對壓控恒流元件進行控制,產生電流,電流再經過採樣電阻到達負載。同時,對採樣電阻兩端信號進行差分和放大,送入ADC。單片機根據採集到的值調整PWM輸出,從而調整了輸出電流。如此反復,直到電流達到設定要求。
數控恒流源系統框圖

1
人機介面模組
本模組包括小鍵盤電路和液晶顯示電路。鍵盤設計為3×4鍵盤,由數位鍵09,功能鍵刪除確認組成,採用反轉法實現鍵值識別。顯示電路由帶中文字形檔的LCD 12864構成,該液晶可以每行8個漢字顯示4行。由於這部分電路比較簡單,在此不詳述。

2
核心控制模組
系統的核心控制模組為AVR單片機(ATMEGA 16L )。主要使用了AVRPWM功能和A/D功能。

AVR
單片機片內有一個具有16PWM功能的定時/計數器。在普通模式下,計數器不停地累加,計到最大值(TOP=0xffff)後溢出,返回到最小值0x0000重新開始。當啟用PWM功能即在單片機的快速PWM模式下,通過調整OCR 1A 的值可實現輸出PWM波的占空比變化。產生PWM波形的機理是:PWM引腳電平在發生匹配時(匹配值為00xffff之間的值,如圖2中的C),以及在計數器清零(從MAX變為BOTTOM)的那一個計時器時鐘週期內發生跳變,具體實現過程如圖2所示。
2  PWM波產生過程

2中的CFOCR 1A 匹配值。從圖中可見,波形在每個匹配值處以及計數清零時輸出發生變化,從而實現了PWM波。由於OCR 1A 的值可以從0x00000xffff,共有65535個值,因此PWM波的最大解析度為1/65535,滿足系統解析度設計要求。PWM波的頻率為:
         1
其中,fclk_I/O為系統時鐘頻率   7.3728MHz),N為分頻係數(取18642561024)。在N1時,根據式(1)得PWM波的最大頻率為7.3728MHz;當N1024時,PWM波的最小頻率為  7.2kHz。本系統N256PWM波頻率為28.8kHz


單片機內部有110位的逐次逼近型ADC,當使用片內VCC作為參考電壓Vref,其解析度為:
        2

若使用片內的2.56V基準源作為參考電壓,依據式(2)可得到其解析度為0.003V

當系統需要更高的解析度時,可以通過軟體補償的方法來實現。具體實現方法可參考相關資料。

3 濾波和功放模組

二階RC低通濾波電路

PWM波產生後不能直接用於控制MOSFET,需把其變成能隨占空比變化而變化的直流電壓。在此,我們選用二階RC低通無源濾波器,並取得了很好的效果。
二階RC低通無源濾波器的系統函數為:
          3

其中,A為通帶增益,Q為品質因素,  ω0為截止頻率。根據式(1)算出PWM波的頻率,取截止頻率為30kHz,由式(3)可確定對應的電阻、電容值。

由於無源濾波器的負載能力差,信號經過二階無源濾波網路後衰減比較厲害,需要增加一級功率放大電路。功放電路比較簡單,也有經典電路,限於篇幅不再贅述。

4 恒流源模組

恒流源採用的是壓控恒流元件IRF540,它的VGS20VID33A 。截止時,最大漏電流為1μA,導通電阻僅有0.04Ω,圖4IRF540的特性曲線。


4  IRF540特性曲線

由圖4可知,當VGS5V時,可輸出電流就可達到30A 左右,完全能實現小電壓控制大電流的目的。具體應用電路如圖5所示。

5  恆流電路
IRF540G極接PWM波轉換後的直流電壓,D極接能提供15V/ 5A 電流的電源(可採用開關電源),S極用來接採樣電阻和負載。採樣電阻應採用溫漂係數低、阻值為10mΩ、精度為1%的大功率錳銅絲電阻。當對採樣電阻兩端信號進行差分後,可得到採樣電阻兩端的電壓值U,而在已知採樣電阻阻值情況下,很容易得到流經採樣電阻的電流,即I=U/R。由於負載與採樣電阻在同一條支路,故流經負載的電流也為I。差分放大電路的放大倍數可根據採樣電阻阻值以及ADC的參考電壓來選擇,圖5中要求R1=R3R2=R4,放大倍數為R4/R3。需要注意的是該電路應該具有很高的輸入阻抗,以減少對負載電路的影響。差分信號經ADC口送入單片機進行處理。

軟體設計
由圖6可知,整個系統是一個動態的閉環系統。由於PWM初始匹配值設置的大小不同,電流值在開始時可能會跟設定值有較大偏差。隨著閉環系統的自我調整,逐漸使輸出穩定在設定值上下。系統達到穩定狀態的時間以及穩定後電流值波動的幅度,可根據設計要求由軟體來調整。



http://www.ladyada.net/library/diyboostcalc.html (可以進去玩玩,專講DC/DC Boost calc )

DC/DC Boost calc 
boostboost!
For many small projects, its cheaper and easier to DIY a boost converter than to buy a specialty chip. DIY converters are usually not as efficient but they're quick & cheap!

The above schematic section shows how I designed a 30-60V vacuum fluorescent tube display driven from a microcontroller pin.

Tubes such as VFDs, Nixies, Decatrons, etc require high voltage to light the gas in the tube. In order to reduce cost, we use a microconrtoller to make a boost converter and avoid paying $5 for a seperate chip. We can do this because we don't need a precision output and the current draw is mostly constant. The boost regulator is run open-loop there is no feedback resistor divider as it isn't necessary as long as the input voltage is within a reasonable range

The microcontroller runs at 8MHz so the 8-bit PWM output is 31250 Hz. The inductor and output capacitor is calculated below. The diode is a standard Schottkey type, but make sure you specify one that can handle the full voltage difference and peak current. The switch just has to be able to handle the max voltage plus some for safety. Note that this design is meant for 'static' output currents, not for variable current draw designs. There is no feedback and its very approximate! This is not for precision electronics!

The boost circuit works by connecting the power inductor L1 to ground that current can flow through it by turning on Q2. After a little bit of time, we disconnect the from ground (by turning off Q2) this means that there is no longer a path for the current in L1 to flow to ground. When this happens, the voltage across the inductor increases (this is the electric property of inductors) and charges up C6 . When the voltage increases to the level we want it to be (30V+) we turn on Q2 again which allows the current in L1 to flow back to ground. If we do this fast enough, and C6 large enough, the voltage on C6 is smoothed out and we get a nice steady high voltage

The timing of turning off/on Q2 allows us to modify the output voltage. Normally there is a feedback resistor to the microcontroller but it is not here because we are running it open-loop. To drive Q2 we use the PWM output from the microcontroller and adjust the duty cycle to vary brightness.

These sorts of designs can be easily made with a 555, once you have the PWM output, connect it up to Q2!

For this simple calculator, enter in the freqency, voltage ranges and current ranges and the duty cycle, inductor and current requirements will be displayed!

The calculator
Frequency
Hz
This is the boost converter frequency. For microcontrollers its often the CPU clock / 256
Min Vin
V
The lowest expected input voltage
Max Vin
V
The highest expected input voltage
Min Vout
V
The lowest desired output voltage
Max Vout
V
The highest desired output voltage
Iout
Amps
Output current draw
Vripple
V
Maximum allowable voltage ripple

Dmin = 1 - (Vimax/Vomin)
%
Dmax = 1 - (Vimin/Vomax)
%
L > D * Vin * (1-D) / (freq * 2 * Iout )
uH
Ipk = (Vinmax * D)/(f * L)
A
Cap > Iout / (Vripple * freq)
uF
Minimum Schottky diodeVbreakdown >= Voutmax & Idiode >=Ipk
V A

Don't forget that Duty cycle is the amount of time the switch is off / output is low. Be sure to measure the output voltages before connecting up anything important!

We like the J&W Miller / Bourns RLB9012 inductors and other thru-hole from the same company

http://en.wikipedia.org/wiki/Boost_converter
警示圖示 Converts 12 volts to ~180 volts, up to about .1 amp. I will be building this to hopefully design line-voltage switching power supplies. Note that the zener is meant to approximate two neon bulbs in series. Created with the circuit simulator at http://www.falstad.com/circuit/
Warning: This circuit produces line voltages at significant current.
In the end, I used a TL494-based boost converter, and was only able to output about 15 watts using the inductors I had on hand.

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。