AN307 Si4712/13/20/21 R E CE I V E P O WE R S C A N P RI MER 1. Introduction This document provides an overview of receive power scan (RPS), provides two algorithms for selecting the optimal transmit frequency and details their implementation, and provides an algorithm test procedure and test data. The host controller uses the RPS feature of the Si4712/13/20/21 to select one or more optimal FM transmit frequencies. This feature can eliminate the need for user intervention in the selection process, greatly reduce time to select a transmit frequency, and select optimal frequencies because all channels in the band can be evaluated. The Si4712/13/20/21 incorporates a power scan measurement function that provides total power received at the antenna. This received power is referred to as the Receive Noise Level (RNL). 2. Algorithms for Selecting Candidate Channels There are two algorithms for selecting candidate transmit channels using RPS. The first algorithm finds the minimum noise level in a given band, and the second algorithm uses the minimum noise level averaged over several channels in a given band. By averaging the received noise level over several channels, the second algorithm will select candidate stations away from adjacent channels, which may improve performance in FM receivers with poor adjacent channel selectivity. While averaging requires slightly more complexity on the host, it is the recommended method. 2.1. Minimum Noise Level The noise floor of the received spectrum is typically shaped with frequency due to environmental noise. To reduce the effects of noise floor shaping, the algorithm divides the FM spectrum into several separate bands and finds the lowest power in each. This prevents environmental noise from dominating the station selection criteria and spreads the candidate stations throughout the FM band. Figure 1 shows an RPS spectrum along with the selected candidate stations using this method. . Figure 1. Selecting Stations Using Minimum Noise Level in Five FM Frequency Bands Rev. 0.2 3/08 Copyright © 2008 by Silicon Laboratories AN307 AN307 2.2. Minimum Averaged Noise Level By using the average of several frequency bins, the algorithm selects stations away from strong adjacent channels because certain receivers suffer from poor blocker performance. The noise is averaged over the current frequency ±1 channel to arrive at the measurement. To reduce the effects of noise floor shaping, the algorithm divides the FM spectrum into several separate bands and finds the lowest power in each (same as algorithm 1). Figure 2 illustrates an RPS spectrum (in red) along with the averaged noise level spectrum (in black). Figure 2. Selecting Stations Using Average Minimum Power in Five FM Frequency Bands Certain receivers may suffer from poor performance due to blockers at either adjacent (N±1) or alternate channels (N±2). As a further enhancement, the RPS scan algorithm can incorporate alternate channels by averaging over five channels (N–2, N–1, N, N+1, N+2). The averaging is weighted using the coefficients (1, 2, 6, 2, 1) and then normalized by the sum of the coefficients. The current channel (N) has the most effect on the averaged value (coefficient value 6), followed by the adjacent channels (coefficient value 2), and finally the alternate channels (coefficient value 1). This algorithm improves performance with receivers that are sensitive to alternate channel interference. 2 Rev. 0.2 AN307 3. RPS Algorithm Implementation This section provides pseudocode for the algorithms for implementing the RPS scan algorithms discussed previously. In order to determine the noise level at a given frequency the Si4712/13/20/21 function TX_TUNE_MEASURE is called with the desired frequency. The results are read using the TX_TUNE_STATUS command. The GET_INT_STATUS command must be performed between sending the TX_TUNE_MEASURE command and reading the TX_TUNE_STATUS to ensure that the measurement has completed. The measurement completion is indicated by the Seek Tune Complete (STCINT) bit. Pseudocode for this algorithm is shown below. TCL code that demonstrates scanning the entire US FM band is included as Appendix A. This code allows the number of filter taps and the number of bands to break the scan into to be set via variables. It is straightforward to modify this code to use a single RNL measurement when choosing the minimum noise level rather than the filtered (averaged) version. This algorithm requires the host to maintain 3 arrays: the filter values to average (e.g. 3, 5 or more consecutive measurements), the filter coefficients (3, 5, or more matching the filter width), and the list of minimal values found per FM frequency range. INIT FilterData to {0 0 0 0 0} //FilterData array holds the noise values of the current, adjacent, // alternate channels. The values are arranged in the array as: //{N+2, N-2, N-1, N, N+1} INIT FilterCoefficients to {1 1 2 6 2} //FilterCoefficients array holds the filter coefficients for weighing //the value of each channel in the average. INIT Minima to {0 0 0 0 0} //Minima array stores the frequency with the lowest averaged noise //level for each of the 5 bands. INIT ChannelsPerBand to ( number of channels in the FM band) / ( number of bands ) //ChannelsPerBand stores how many FM channels exist //in each of the bands FOR each i = ( number of channels in the FM band + ( FilterWidth / 2 ) ) //Scan the entire FM band SET CurrentChannel to ( StartingFreq + ( i * ChannelSpacing ) ) SET CurrentBand to ( i / ChannelsPerBand ) SET FilterPointer to ( i MODULUS ( FilterWidth ) ) //FilterPointer indicates the location in FilterData to fill //with the next noise level reading IF CurrentChannel > (top of the FM band) SET FilterData at FilterPointer to 0 ELSE //Tune and measure the noise level CALL TX_TUNE_MEASURE with CurrentChannel and 1 REPEAT CALL GET_INT_STATUS UNTIL SEEK TUNE COMPLETE SET MeasuredRNL to ( CALL TX_TUNE_STATUS with 0 ) SET FilterData at FilterPointer to (MeasuredRNL) IF i > ( FilterWidth / 2) Rev. 0.2 3 AN307 //If half of the filter has been filled with noise level values, //calculate the average noise level SET AverageFreq to ( StartingFreq + ( i - ( FilterWidth / 2 ) ) * ChannelSpacing ) SET NewAverage to 0 SET FilterWeighting to 12 //Multiply the noise levels by with filter weight coefficients FOR each j = 0 to FilterWidth SET Index to ( ( j + FilterPointer ) MODULUS FilterWidth ) SET NewAverage to ( NewAverage + ( FilterData at Index ) * ( FilterCoefficients at j ) ) IF ( FilterData at Index ) = 0 SET FilterWeighting to ( FilterWeighting - ( FilterCoefficients at j ) ) SET NewAverage to ( NewAverage / FilterWeighting ) IF NewAverage < ( Minima at CurrentBand ) SET ( Minima at CurrentBand ) to NewAverage //Record the lowest noise level in the current band 4 Rev. 0.2 AN307 4. Measuring RPS Algorithm Performance 4.1. Procedure In order to characterize the performance of the RPS algorithm at selecting good candidate stations, testing should be performed in several vehicles at different locations and with the transmitter at different locations inside the car. This testing uses a qualitative scale measurement of Good, Acceptable, and Poor to characterize the FM receiver performance. After the algorithm selects a candidate station, the car receiver is tuned to the station, the Si4712 is set to transmit on the station at 115 dBuV power and the subjective audio performance is recorded. In order to quantify the margin that the transmitter has on this particular station, the transmit power is reduced in 10 dB steps until the audio can no longer be received. This margin is defined as the amount of power reduction from 115 dBuV power that can be achieved while still maintaining a "Good" measurement. 4.2. Strong Signal Environment Figure 3 shows three RPS spectra measured with a Si4712 EVB with a 10 cm board stub antenna at a location with a direct line-of-sight view of several FM broadcast towers. This situation is representative of the strongest signal environment likely to be encountered. Using the minimum average RNL method with the filter size set to five channels to select candidate stations, four out of five showed good performance with the Si4712 positioned on the dashboard. Repeating the procedure with the Si4712 on the passenger seat yielded three out of five good candidate stations. Dashboard (Scan 1) Strong Signal Environm ent Good (Scan 1) Acceptable (Scan 1) Poor (Scan 1) Passenger Seat (Scan 2) Good (Scan 2) Acceptable (Scan 2) 70 Poor (Scan 2) 60 Search Band Boundary 50 40 30 20 10 0 8750 9250 9750 10250 10750 Figure 3. Si4712 RPS Station Scan Results in a Strong Signal Environment Rev. 0.2 5 AN307 4.3. Urban/Moderate Signal Environment Figure 4 shows three RPS spectra measured at an urban location with many potential sources of multipath reflections (large glass-covered buildings, landscape, etc.). With the Si4712 positioned on the dashboard, the RPS minimum average RNL algorithm with the filter size set to five channels selected three stations with good performance and two with acceptable performance. Using the passenger seat positioning, two stations showed good performance, and two showed acceptable performance. Dashboard (Scan 1) Urban/Moderate Signal Environm ent Good (Scan 1) Acceptable (Scan 1) Poor (Scan 1) Passenger Seat (Scan 2) Good (Scan 2) Acceptable (Scan 2) 70 Poor (Scan 2) 60 Search Band Boundary 50 40 30 20 10 0 8750 9250 9750 10250 10750 Figure 4. Si4712 RPS Station Scan Results in an Urban/Moderate Signal Environment 6 Rev. 0.2 AN307 4.4. Suburban/Weak Signal Environment Figure 5 shows three RPS spectra measured at a suburban location where many stations are attenuated by distance and landscape features. This location is much closer to the transmission source for 98.9 MHz. This situation is a good representation of a suburban area with mostly weak stations. Using the minimum average RNL method with the filter size set to five channels to select candidate stations, two out of five showed good performance with the Si4712 positioned on the dashboard, while the others were marginal. Even when manually searching for stations, no more than two candidates with good performance could be found. Repeating the procedure with the Si4712 on the passenger seat yielded three out of five good candidate stations and two acceptable. Dashboard (Scan 1) Suburban/Weak Signal Environm ent Good (Scan 1) Acceptable (Scan 1) Poor (Scan 1) Passenger Seat (Scan 2) Good (Scan 2) Acceptable (Scan 2) 70 Poor (Scan 2) 60 Search Band Boundary 50 40 30 20 10 0 8750 9250 9750 10250 10750 Figure 5. Si4712 RPS Station Scan Results in a Suburban/Weak Signal Environment Table 1. RPS Candidate Station Qualitative Performance Summary Signal Environment Si4712 Location RPS Selection Subjective Performance Good Acceptable Poor Dashboard 4 0 1 Passenger Seat 3 0 2 Dashboard 3 2 0 Passenger Seat 2 2 1 Dashboard 2 3 0 Passenger Seat 3 2 0 Strong Urban/Moderate Suburban/Weak Rev. 0.2 7 AN307 5. Conclusion The RPS algorithm provides a robust solution for selecting optimal FM transmit frequencies. Selection can be based upon minimum noise level or averaged minimum noise level. Dividing the FM band into smaller divisions prevents environmental noise from dominating the selection criteria. The RPS algorithm is easily implemented on the host and is flexible enough to accommodate memory-constrained applications. In strong, weak, and multipath signal environments, RPS consistently selects two to four stations that show good performance. By automating the frequency selection process, users can easily transmit on the optimal frequencies without any manual scanning. 8 Rev. 0.2 AN307 APPENDIX A: TCL IMPLEMENTATION OF RPS TCL code that demonstrates scanning the entire US FM band is show below. Refer to Section 3 of this document for more information. #This example will find the minimum power for a FM channel. #it will calculate the average power based on a weighted average spanning +/-N channels. # # Variables used to configure the operation of the scan # # These variables define the FM band characteristics # # startFreq - The lower end of the FM band (in 10kHz steps) # endFreq - The upper end of the FM band (in 10kHz steps) # spacing - channel spacing: 50kHz, 100kHz, 200kHz (in 10kHz steps) # # numBands - Breaks the FM band into a number of smaller bands. The min power is found # in each of these frequency bands. # # filterWidth - sets the width of the FIR filter in channels # filter - an array of filterWidth elements which is used to compute the average # coeff - an array of filter coefficients for weighing the value of each channel # in the average. The coefficients are listed in the following order # [N+max, N-max, N-max+1,.....]. For a 5-tap filter the ordering is # [N+2, N-2, N-1, N, N+1] # filterWeight- The scaling factor used to normalize the summed coefficient terms # This term is optional and is only required to normalize results between a single # RNL measurement and the averaged RNL measurements. # # Calculating the filter in place with the proper weighting is done as follows: # # filterPtr is the location where the next sample is placed in the FIR array and is calculated by # taking the current loop number modulo the filterWidth. The channel whose average power is being # calculated is located at a frequency filterMid steps lower than the current frequency. To ensure # that the measured RNL is averaged with the proper coefficients consider the following case: # # freq array A B C D E # # ^ ^ # fltPtr chan N # # N+2 N-2 N-1 N N+1 # coeff 1 1 2 6 2 # # filterPtr always points to N+2 so when weighting the filter values with the coefficients, we can # pull the N+2 coefficient from the coefficient array location 0, and start pulling measurements # from the filter at the filterPtr location. By incrementing filter pointer and taking the modulo we # ensure that we always pull the filter elements in the order that the coefficents are stored in the # coeff array. # set startFreq 8750 set endFreq 10790 Rev. 0.2 9 AN307 set set set set set set set spacing 20; #channel spacing numBands 5; # number of bands to find best channel filterWidth 5; # number of channels to average numChans [expr ($endFreq - $startFreq) / $spacing] chanBand [expr $numChans / $numBands + 1] filterMid [expr $filterWidth / 2]; #offset from current freq to middle of filter minAvg 100 array 0 1 2 3 4 } set filter { 0 0 0 0 0 array 0 1 2 3 4 } set bandMin { {0 1000} {0 1000} {0 1000} {0 1000} {0 1000} #FIR Filter coefficients array set coeff { 0 1 1 1 2 2 3 6 4 2 } set filterWeight 12 ;#Normalization number is 1+1+2+6+2 = 12 #Add an additional 1/2 filter bins to the upper end to make #averaging easier for {set i 0} {$i <= $numChans + $filterMid} {incr i 1} { set currentFreq [expr $startFreq + $i * $spacing] set freqBand [expr $i / $chanBand] set filterPtr [expr $i % $filterWidth] #Handle the top of the band by filling extra array locations with 0 if {$i > $numChans} { set filter($filterPtr) 0 ;#pack upper 1/2 of filter with 0 at top of band } else { txTuneMeasure $currentFreq 0 while {![expr [getIntStatus] & 0x1]} { after 1 } array set measure [d::txTuneStatus 1] set filter($filterPtr) $measure(rnl) } #Don't calculate average for lower channels until 1/2 of filter is full if {$i >= $filterMid} { set avgFreq [expr ($startFreq + ($i - $filterMid) * $spacing)] set newAvg 0 set filterWeight 12 10 Rev. 0.2 AN307 for {set j 0} {$j < $filterWidth} {incr j} { set index [expr (($j + $filterPtr) % 5)] set newAvg [expr $newAvg + $filter($index) * $coeff($j)] #Adjust filter weight for empty taps if { $filter($index) == 0 } { incr filterWeight [expr $coeff($j) * -1] } } set newAvg [expr $newAvg / $filterWeight] if {$newAvg <= [lindex $bandMin($freqBand) 1]} { set bandMin($freqBand) [list $avgFreq $newAvg] } } } Rev. 0.2 11 AN307 APPENDIX B: FREQUENTLY ASKED QUESTIONS Q: Why does RPS performance vary between some vehicles? A: The amount of FM signal attenuation can vary between vehicles depending on the chassis, construction materials, FM receiver antenna placement, and Si4712/13/20/21 placement. For vehicles that show high chassis attenuation, placing the Si4712/13/20/21 closer to the FM receiver antenna (such as on the dashboard) may improve performance. Q: Can the RPS algorithm identify more or fewer candidate frequencies? A: The variable numBands determines how many bands the FM spectrum will be divided into. The default value is 5, but it may be increased or decreased. Q: How can the amount of memory required to implement RPS on the host be reduced? A: The algorithm is already optimized to use the least amount of memory possible and maximize performance. The filter size (filterWidth) may be reduced to three so that the averaging includes only ±1 channels. For further memory reduction, the averaging can be omitted such that the algorithm selects the minimum noise level in each band. Reducing or removing the averaging may reduce performance with receivers that suffer from poor performance due to blockers at either adjacent (N±1) or alternate channels (N±2). Q: What is the benefit of using filter weighting? Can the filter weighting coefficients all be 1? A: Filter weighting extends the RPS algorithm to consider both adjacent (N±1) and alternate channels (N±2), in addition to the current channel (N). The noise level of the current channel will have the most effect on performance, so it is scaled by 6. The adjacent channel noise levels will have a smaller effect, so they are scaled by 2. Alternate channels will have even less effect, so they are scaled by 1. If the Minimum Averaged Noise Level RPS algorithm is used, it is important to use the correct filter weighting coefficients. Since the current, adjacent, and alternate channels have different effects on performance, the coefficients should vary. 12 Rev. 0.2 AN307 DOCUMENT CHANGE LIST Revision 0.1 to Revision 0.2 Updated title. Rev. 0.2 13 Smart. Connected. Energy-Friendly Products Quality Support and Community www.silabs.com/products www.silabs.com/quality community.silabs.com Disclaimer Silicon Laboratories intends to provide customers with the latest, accurate, and in-depth documentation of all peripherals and modules available for system and software implementers using or intending to use the Silicon Laboratories products. Characterization data, available modules and peripherals, memory sizes and memory addresses refer to each specific device, and "Typical" parameters provided can and do vary in different applications. Application examples described herein are for illustrative purposes only. Silicon Laboratories reserves the right to make changes without further notice and limitation to product information, specifications, and descriptions herein, and does not give warranties as to the accuracy or completeness of the included information. Silicon Laboratories shall have no liability for the consequences of use of the information supplied herein. This document does not imply or express copyright licenses granted hereunder to design or fabricate any integrated circuits. The products must not be used within any Life Support System without the specific written consent of Silicon Laboratories. A "Life Support System" is any product or system intended to support or sustain life and/or health, which, if it fails, can be reasonably expected to result in significant personal injury or death. Silicon Laboratories products are generally not intended for military applications. Silicon Laboratories products shall under no circumstances be used in weapons of mass destruction including (but not limited to) nuclear, biological or chemical weapons, or missiles capable of delivering such weapons. Trademark Information Silicon Laboratories Inc., Silicon Laboratories, Silicon Labs, SiLabs and the Silicon Labs logo, CMEMS®, EFM, EFM32, EFR, Energy Micro, Energy Micro logo and combinations thereof, "the world’s most energy friendly microcontrollers", Ember®, EZLink®, EZMac®, EZRadio®, EZRadioPRO®, DSPLL®, ISOmodem ®, Precision32®, ProSLIC®, SiPHY®, USBXpress® and others are trademarks or registered trademarks of Silicon Laboratories Inc. ARM, CORTEX, Cortex-M3 and THUMB are trademarks or registered trademarks of ARM Holdings. Keil is a registered trademark of ARM Limited. All other products or brand names mentioned herein are trademarks of their respective holders. Silicon Laboratories Inc. 400 West Cesar Chavez Austin, TX 78701 USA http://www.silabs.com