日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 嵌入式 > 嵌入式硬件
[導(dǎo)讀]濾波常發(fā)生在模擬世界。不幸的是,在數(shù)字領(lǐng)域,工程師通常主要使用DSP(數(shù)字信號處理器),而不是8位單片機實現(xiàn)濾波。這個情形的發(fā)生,是因為濾波器設(shè)計的算法比大多數(shù)工程師樂于處理的算法更復(fù)雜。而且,數(shù)字濾波需要計算整形數(shù),而不是浮點數(shù)。這引發(fā)了兩個問題。第一,有限位的舍入誤差降低了濾波器響應(yīng),甚至使它不穩(wěn)定。第二,必須用整數(shù)算法處理小數(shù)值。

一個簡單的匯編程序適合于微處理器實現(xiàn)數(shù)字低通濾波器。
濾波常發(fā)生在模擬世界。不幸的是,在數(shù)字領(lǐng)域,工程師通常主要使用DSP(數(shù)字信號處理器),而不是8位單片機實現(xiàn)濾波。這個情形的發(fā)生,是因為濾波器設(shè)計的算法比大多數(shù)工程師樂于處理的算法更復(fù)雜。而且,數(shù)字濾波需要計算整形數(shù),而不是浮點數(shù)。這引發(fā)了兩個問題。第一,有限位的舍入誤差降低了濾波器響應(yīng),甚至使它不穩(wěn)定。第二,必須用整數(shù)算法處理小數(shù)值。

有幾種方法解決這些問題。例如,可以使用16、32和64位數(shù)的操作,或可以縮放到更好的精度。這些和其他方法通常需要更多的存儲器,造成編程經(jīng)常不適于小型微處理器。文獻研究所示用C語言編寫的數(shù)字濾波固件,與用匯編語言編寫需要更多的存儲器。這個情形對存儲器資源有限的小型微處理器來講,常常是不可接受的。

列表1(程序見英文原文)列出了一個用8位微處理器設(shè)計單極低通數(shù)字濾波器固件的簡單方法。Freescale公司的低端MC68HC908QT2使用匯編編程器,但可以將本設(shè)計方案用于任一型號微處理器,只要其使用的也是標(biāo)準(zhǔn)匯編指令。

將基于廣義Z
變換算法的復(fù)雜設(shè)計方案放在一邊,本方案使用了一種基于遞歸方程的解決辦法。計算每個輸出信號采樣,作為輸入信號和前一個輸出信號帶相關(guān)系數(shù)的總和。遞歸方程定義一個單極低通濾波器為:Y[n]=X[n]×a0+Y[n–1]×b1,在這里X[n]和Y[n]為采樣[n]的輸入輸出值,Y[n–1]為前一采樣[n–1]的輸出值,a0和b1為減少δ控制的權(quán)重系數(shù)。系數(shù)為0<δ<1的值,a0=1–δ且b1=δ。理論上,δ為輸入信號從高電平降到低電平時,鄰近的輸出采樣之間的衰減量??梢灾苯又付?delta;值或找到濾波器所需的時間常數(shù)d,其為采樣數(shù)上升到低通濾波器穩(wěn)態(tài)63.2%時的輸出。D和δ之間存在確定的關(guān)系:δ=e–1/d,在這里e為自然對數(shù)基底。前面的公式服從Y[n]=Y[n–1]+(1–δ)×(X[n]–Y[n–1])。

為取代小數(shù)相乘,1–δ對匯編程序而言,用除以倒數(shù)為整數(shù)的方法更方便,F(xiàn)=1/(1–δ): Y[n]=Y[n–1]+(X[n]–Y[n–1])/F。因此,可以按照下面的步驟確定數(shù)字濾波器參數(shù):

1、選擇參數(shù)F。對匯編程序而言,便于用右移實現(xiàn)除法運算。右移就是F值應(yīng)該為2S,在此S為偏移數(shù)。讓F為8,相當(dāng)于右移三位。

2、計算衰減:δ=1–1/F=1–1/8=0.875。

3、計算時間常數(shù)d=–1/lnδ=–1/ln0.875=7.49采樣。

公式Y(jié)[n]=Y[n–1]+(X[n]–Y[n–1])/F決定濾波器的微處理器算法設(shè)計。算法需要三個寄存器:輸入X[n]、輸出Y[n]和一個遞增寄存器保存(X[n]–Y[n–1])/F的值。三個寄存器的大小取決于輸入。應(yīng)用中,內(nèi)置的8位ADC輸出范圍從00到$FF的信號,必須經(jīng)歷低通濾波器。所以輸入和輸出寄存器均為1個字節(jié)。為增加除法精度,增加一半除數(shù)到被除數(shù)。這個處理將遞增寄存器增加到2個字節(jié)。

用數(shù)字方法實現(xiàn)濾波功能提供了一致性的好處,因為器件誤差、溫度漂移和老化不會影響濾波器算法。用微處理器實現(xiàn)數(shù)字濾波器,增加了可調(diào)整濾波器參數(shù)的靈活性優(yōu)勢,因為這個靈活性僅取決于固件。

英文原文:

8-bit microcontroller implements digital lowpass filter

A simple assembler routine fits a digital lowpass filter into a microcontroller.

Abel Raynus, Armatron International, Malden, MA; Edited by Charles H Small and Fran Granville -- EDN, 1/24/2008

Filtering occurs frequently in the analog world. Unfortunately, in the digital world, engineers apply it mainly to the DSPs (digital-signal processors) and not to the small 8-bit microcontrollers that designers commonly use. This situation occurs because the math for the filter design is more complicated than most engineers are willing to deal with. Moreover, digital filtering requires calculations on integers instead of on floating-point numbers. This scenario causes two problems. First, the rounding-off error from the limited number of bits can degrade the filter response or even make it unstable. Second, you must handle the fractional values with integer math.

Several ways exist to solve these issues. For example, you can use operations with 16-, 32-, and 64-bit numbers, or you can scale for better accuracy. These and other methods usually require more memory, and, as a result, the program often does not fit into a small microcontroller. A literature search shows that published digital-filter firmware is written in C. Programs in C need more memory than those written in assembler. This situation often makes them unacceptable for small microcontrollers with limited memory resources.

Listing 1 shows a simple engineering method to design single-pole, lowpass-digital-filter firmware for 8-bit microcontrollers. The low-end Freescale MC68HC908QT2 is the target of the assembler program, but you can apply this Design Idea to any type of microcontroller because it uses only standard assembler instructions.

Leaving aside the sophisticated design methods based on Z transformation with its extensive math, this idea uses another approach based on a recursive equation. You calculate each output-signal sample as the sum of the input signal and the previous output signal with corresponding coefficients. A recursive equation defines a single-pole lowpass filter as: Y[n]=X[n]×a0+Y[n–1]×b1, where X[n] and Y[n] are input and output values of sample [n], Y[n–1] is an output value of the previous sample [n–1], and a0 and b1 are weight coefficients that decrement δ controls. The coefficients have the value of 0<δ<1, a0=1–δ, and b1=δ. Physically, δ is the amount of decay between adjacent output samples when the input signal drops from a high level to a low level. You can directly specify the value of δ or find it from the desired time constant of the filter, d, which is the number of samples it takes the output to rise to 63.2% of the steady-state level for a lowpass filter. A fixed relationship exists between d and δ: δ=e–1/d, where e is the base of natural logarithms. The preceding equations yield Y[n]=Y[n–1]+(1–δ)×(X[n]–Y[n–1]).


Instead of multiplying a decimal-point number, 1–δ, it is more convenient for assembler programming to divide by the reciprocal integer, F="1/"(1–δ): Y[n]=Y[n–1]+(
X[n]–Y[n–1])/F. Thus, you can determine the digital filter’s parameters using the following steps:

Choose the parameter F. For assembler, it is convenient to perform division as right shifts. For right shifts, the value of F should be 2S, where S is the number of shifts. Let F equal 8, which you reach after three right shifts.

Calculate the decrement: δ=1–1/F=1–1/8=0.875.

Calculate the time constant as d=–1/lnδ=–1/ln0.875=7.49 samples.

The equation Y[n]=Y[n–1]+(X[n]–Y[n–1])/F determines the design of the microcontroller’s algorithm for the filter. The algorithm needs three registers: input for X[n], output for Y[n], and an increment register to keep the (X[n]–Y[n–1])/F term. The size of these registers depends on the inputs. In this application, the signals from the built-in 8-bit ADC range from 00 to $FF and must go through the lowpass filter. So, the input and the output registers are 1 byte in size. To increase the accuracy of division, add half the divisor to the dividend. This action increases the increment register to 2 bytes.

Numerically performing the filtering function provides the benefit of consistency because component tolerances, temperature drift, and aging do not affect the filter’s algorithm. The implementation of the digital filter in the microcontroller gives the additional benefit of flexibility to adjust the filter’s parameters, because this flexibility depends only on the firmware.

本站聲明: 本文章由作者或相關(guān)機構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

LED驅(qū)動電源的輸入包括高壓工頻交流(即市電)、低壓直流、高壓直流、低壓高頻交流(如電子變壓器的輸出)等。

關(guān)鍵字: 驅(qū)動電源

在工業(yè)自動化蓬勃發(fā)展的當(dāng)下,工業(yè)電機作為核心動力設(shè)備,其驅(qū)動電源的性能直接關(guān)系到整個系統(tǒng)的穩(wěn)定性和可靠性。其中,反電動勢抑制與過流保護是驅(qū)動電源設(shè)計中至關(guān)重要的兩個環(huán)節(jié),集成化方案的設(shè)計成為提升電機驅(qū)動性能的關(guān)鍵。

關(guān)鍵字: 工業(yè)電機 驅(qū)動電源

LED 驅(qū)動電源作為 LED 照明系統(tǒng)的 “心臟”,其穩(wěn)定性直接決定了整個照明設(shè)備的使用壽命。然而,在實際應(yīng)用中,LED 驅(qū)動電源易損壞的問題卻十分常見,不僅增加了維護成本,還影響了用戶體驗。要解決這一問題,需從設(shè)計、生...

關(guān)鍵字: 驅(qū)動電源 照明系統(tǒng) 散熱

根據(jù)LED驅(qū)動電源的公式,電感內(nèi)電流波動大小和電感值成反比,輸出紋波和輸出電容值成反比。所以加大電感值和輸出電容值可以減小紋波。

關(guān)鍵字: LED 設(shè)計 驅(qū)動電源

電動汽車(EV)作為新能源汽車的重要代表,正逐漸成為全球汽車產(chǎn)業(yè)的重要發(fā)展方向。電動汽車的核心技術(shù)之一是電機驅(qū)動控制系統(tǒng),而絕緣柵雙極型晶體管(IGBT)作為電機驅(qū)動系統(tǒng)中的關(guān)鍵元件,其性能直接影響到電動汽車的動力性能和...

關(guān)鍵字: 電動汽車 新能源 驅(qū)動電源

在現(xiàn)代城市建設(shè)中,街道及停車場照明作為基礎(chǔ)設(shè)施的重要組成部分,其質(zhì)量和效率直接關(guān)系到城市的公共安全、居民生活質(zhì)量和能源利用效率。隨著科技的進步,高亮度白光發(fā)光二極管(LED)因其獨特的優(yōu)勢逐漸取代傳統(tǒng)光源,成為大功率區(qū)域...

關(guān)鍵字: 發(fā)光二極管 驅(qū)動電源 LED

LED通用照明設(shè)計工程師會遇到許多挑戰(zhàn),如功率密度、功率因數(shù)校正(PFC)、空間受限和可靠性等。

關(guān)鍵字: LED 驅(qū)動電源 功率因數(shù)校正

在LED照明技術(shù)日益普及的今天,LED驅(qū)動電源的電磁干擾(EMI)問題成為了一個不可忽視的挑戰(zhàn)。電磁干擾不僅會影響LED燈具的正常工作,還可能對周圍電子設(shè)備造成不利影響,甚至引發(fā)系統(tǒng)故障。因此,采取有效的硬件措施來解決L...

關(guān)鍵字: LED照明技術(shù) 電磁干擾 驅(qū)動電源

開關(guān)電源具有效率高的特性,而且開關(guān)電源的變壓器體積比串聯(lián)穩(wěn)壓型電源的要小得多,電源電路比較整潔,整機重量也有所下降,所以,現(xiàn)在的LED驅(qū)動電源

關(guān)鍵字: LED 驅(qū)動電源 開關(guān)電源

LED驅(qū)動電源是把電源供應(yīng)轉(zhuǎn)換為特定的電壓電流以驅(qū)動LED發(fā)光的電壓轉(zhuǎn)換器,通常情況下:LED驅(qū)動電源的輸入包括高壓工頻交流(即市電)、低壓直流、高壓直流、低壓高頻交流(如電子變壓器的輸出)等。

關(guān)鍵字: LED 隧道燈 驅(qū)動電源
關(guān)閉