www.久久久久|狼友网站av天堂|精品国产无码a片|一级av色欲av|91在线播放视频|亚洲无码主播在线|国产精品草久在线|明星AV网站在线|污污内射久久一区|婷婷综合视频网站

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

有幾種方法解決這些問題。例如,可以使用16、32和64位數(shù)的操作,或可以縮放到更好的精度。這些和其他方法通常需要更多的存儲器,造成編程經(jīng)常不適于小型微處理器。文獻(xiàn)研究所示用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)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車的華為或?qū)⒋呱龈蟮莫毥谦F公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

加利福尼亞州圣克拉拉縣2024年8月30日 /美通社/ -- 數(shù)字化轉(zhuǎn)型技術(shù)解決方案公司Trianz今天宣布,該公司與Amazon Web Services (AWS)簽訂了...

關(guān)鍵字: AWS AN BSP 數(shù)字化

倫敦2024年8月29日 /美通社/ -- 英國汽車技術(shù)公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車工程師從創(chuàng)意到認(rèn)證的所有需求的工具,可用于創(chuàng)建軟件定義汽車。 SODA V工具的開發(fā)耗時1.5...

關(guān)鍵字: 汽車 人工智能 智能驅(qū)動 BSP

北京2024年8月28日 /美通社/ -- 越來越多用戶希望企業(yè)業(yè)務(wù)能7×24不間斷運行,同時企業(yè)卻面臨越來越多業(yè)務(wù)中斷的風(fēng)險,如企業(yè)系統(tǒng)復(fù)雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務(wù)連續(xù)性,提升韌性,成...

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報道,騰訊和網(wǎng)易近期正在縮減他們對日本游戲市場的投資。

關(guān)鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會開幕式在貴陽舉行,華為董事、質(zhì)量流程IT總裁陶景文發(fā)表了演講。

關(guān)鍵字: 華為 12nm EDA 半導(dǎo)體

8月28日消息,在2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會上,華為常務(wù)董事、華為云CEO張平安發(fā)表演講稱,數(shù)字世界的話語權(quán)最終是由生態(tài)的繁榮決定的。

關(guān)鍵字: 華為 12nm 手機(jī) 衛(wèi)星通信

要點: 有效應(yīng)對環(huán)境變化,經(jīng)營業(yè)績穩(wěn)中有升 落實提質(zhì)增效舉措,毛利潤率延續(xù)升勢 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務(wù)引領(lǐng)增長 以科技創(chuàng)新為引領(lǐng),提升企業(yè)核心競爭力 堅持高質(zhì)量發(fā)展策略,塑強(qiáng)核心競爭優(yōu)勢...

關(guān)鍵字: 通信 BSP 電信運營商 數(shù)字經(jīng)濟(jì)

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺與中國電影電視技術(shù)學(xué)會聯(lián)合牽頭組建的NVI技術(shù)創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會上宣布正式成立。 活動現(xiàn)場 NVI技術(shù)創(chuàng)新聯(lián)...

關(guān)鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會上,軟通動力信息技術(shù)(集團(tuán))股份有限公司(以下簡稱"軟通動力")與長三角投資(上海)有限...

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉