fxotune
A utility for tuning the various settings on the fxo modules for analog cards.Supported by Digium TDM400P and clones, TDM800P, TDM2400P, Xorcom Astribank FXO modules and probably some others. Not supported by X100P cards and clones.
fxotune tunes the module to generate less echo in the first place.
Using Fxotune
You need to train fxotune once using fxotune -i, see more below about that. The training will create the file /etc/fxotune.conf . In order to apply the same tuning next time, you need to run:fxotune -s
after you have loaded the zaptel modules, but before you started Asterisk. Latest Zaptel init script should do that if /etc/fxotune.conf is present.
Fxotune Training
Zaptel 1.2
The version of fxotune included with zaptel 1.2 has a rather simple syntax. It is also slower and less effective than the version in 1.4.- Stop asterisk
- Run: fxotune -i 4
- Restart asterisk
Asterisk must be stopped or otherwise fxotune would consider the line as busy (in fact, you could instead destroy the relevant zaptel channels, and restart asterisk in the end of the tuninng).
Zaptel 1.4
The rest of the page applies to the version of fxotune from zaptel 1.4 or newer.From README.fxotune
Q. I have echo problems on my FXO modules and I've tried the different echo cancellation algorithms in zconfig.h, tried tweaking the gains, and still nothing works. What can I do?
A. Use the fxotune utility.
To use:
Just run the fxotune utility with the -i option. (`fxotune -i 4`) It should discover which zap channels are FXO modules and tune them accordingly. Be warned however, it takes a significant amount of time for EACH module to test, I would say somewhere around 2-3 minutes. But you only have to initialize it once for the line. It will write a configuration file to /etc/fxotune.conf. You will need to have your system run fxotune with the -s flag (`fxotune -s`) to set the module with the previously discovered values from fxotune.conf for it to take affect, so essentially if each time you reboot the machine you need to run `fxotune -s`. You might consider putting it in your startup scripts some time after the module loads and before asterisk runs.
NOTE: The digit after the -i option is the digit that will break dialtone on the line.
Matthew Fredrickson
Notes
Basically make sure asterisk isnt running and that zaptel and wctdm modules are loaded as fxotune needs direct access to the zap channel
In other words:
#amportal stop (Asterisk@Home)
or
CLI>stop now (just Asterisk)
followed by
#/usr/src/zaptel/fxotune -i 4
More info on fxotune:
fxotune optimizes the line characteristics of a TDM device to minimize the *source* of echo. This is generally referred to as 'balancing the hybrid' and is quite important in echo cancellation. Once the hybrid is properly balanced, software echo cancellers will work very nicely. To provide some hard numbers, the echo on lines at one site was about 15% with the default settings on the TDM. The software echo canceller actually did a fairly good job with this - but when we got the hybrid balanced properly, echo on the line dropped to 3%, and then the software echo canceller did a *fantastic* job. At another site, the echo on the line was 60% - this was well beyond what the software echo canceller could handle (it did work, but there was quite a bit of residual echo, etc...). Once we tuned the hybrid, echo dropped to 4%, and the echo canceller was able to work properly.
Note that fxotune does not do anything with the echo canceler algorithms themselves - instead, it optimizes the signal before it gets to the echo canceler, making it easier for the echo canceler to do it's work.
There are two types of tuning that can be performed on the TDM - adjusting line impedence, and adjusting echo coefficients in the digital filter that is part of the hybrid iteself. The current implementation of fxotune *only* balances the line impedence (which does not necessarily result in the best results).
Important Note: The current fxotune application in SVN has a bug that causes it to not properly clear the dialtone of the line during part of it's test. As a result, it measures the dialtone as part of the echo response, which can cause it to 'optimize' to the wrong line impedence.
There is a patch against fxotune that fixes the above bug, and revamps the calibration algorithm to optimize the echo coefficients in addition to the line impedence. It also adds tools for getting a numerical measure of the amount of echo on the line. We have seen echo levels of 60% after tuning only the line impedence, and 3% after doing the full opimization. In addition, due to some frequency domain trickery, the full optimization test actually runs faster than the old one.
To get the echo level of line 3 using the patched fxotune, stop asterisk, then run:
./fxotune -d -b 3
This will return the ratio of echo to input signal (the closer this number is to 0.0 the better. Imperically, we've found that getting this number below 5% is important for proper operation of the software echo cancellers).
The -d option also dumps input and output waveform information to ./fxotune_dump.vals - plotting these in a graph can be very instructive. For example, here is the plot for one of our lines without any tuning at all obtained using the following command (-w 1004 makes the test operate at a single frequency of 1004 Hz instead of multiple frequencies in a single test):
./fxotune -d -b 3 -w 1004
The pink line is the driving signal, the blue line is the measured response reflecting back from the CO into the untuned hybrid.
We then optimize using the *old* fxotune calibration algorithm using the following command ('-t 1' forces fxotune to use the old calibration type 1):
./fxotune -i 5 -t 1
We then re-run ./fxotune -d -b 3 -w 1004, and the results are:
Things have improved, but we still have a bunch of echo - there is no way that the software echo cancellers can handle this.
Finally, we run fxotune using the new calibration:
./fxotune -i 5
The echo results are now:
At this point, the hybrid is pretty well tuned, and the software echo cancellers can get of any residual echo.
In summary, tuning with the patched fxotune is the same as before - if '5' is the keypress that will clear the dialtone, you'd run:
./fxotune -i 5
To set the calibration during boot, run:
./fxotune -s
If the new fxotune helps you out, please be sure to add your comments to the bug tracker!
Page Changes
could not fill input buffer
As I've always said, the guys that program this stuff are computer geniuses, but seem to lack the ability to document what they've done. It is Linux. It is free. You get what you pay for, so don't complain.
FXOTUNE: -i option
I'm from Portugal and I would like to know how can I break the tone? I've been pressing all buttons on the analogue telephone but the dialtone is only absent for 5 seconds and then returns. The calibration of the hybrid takes about 3 minutes and I think the calibration isn't accurate because I cannot break the dialtone successfully.
I have a lot of echo (33%) so there must be something wrong!!!
Please HELP!!!!!
Best Regards...
Marco Passarinho
FXOTUNE: -i option
I'm from Portugal and I would like to know how can I break the tone? I've been pressing all buttons on the analogue telephone but the dialtone is only absent for 5 seconds and then returns. The calibration of the hybrid takes about 3 minutes and I think the calibration isn't accurate because I cannot break the dialtone successfully.
I have a lot of echo (33%) so there must be something wrong!!!
Please HELP!!!!!
Best Regards...
Marco Passarinho
FXOTUNE: -i option
I'm from Portugal and I would like to know how can I break the tone? I've been pressing all buttons on the analogue telephone but the dialtone is only absent for 5 seconds and then returns. The calibration of the hybrid takes about 3 minutes and I think the calibration isn't accurate because I cannot break the dialtone successfully.
I have a lot of echo (33%) so there must be something wrong!!!
Please HELP!!!!!
Best Regards...
Marco Passarinho
FXOTUNE: -i option
I'm from Portugal and I would like to know how can I break the tone? I've been pressing all buttons on the analogue telephone but the dialtone is only absent for 5 seconds and then returns. The calibration of the hybrid takes about 3 minutes and I think the calibration isn't accurate because I cannot break the dialtone successfully.
I have a lot of echo (33%) so there must be something wrong!!!
Please HELP!!!!!
Best Regards...
Marco Passarinho
FXOTUNE: -i option
I'm from Portugal and I would like to know how can I break the tone? I've been pressing all buttons on the analogue telephone but the dialtone is only absent for 5 seconds and then returns. The calibration of the hybrid takes about 3 minutes and I think the calibration isn't accurate because I cannot break the dialtone successfully.
I have a lot of echo (33%) so there must be something wrong!!!
Please HELP!!!!!
Best Regards...
Marco Passarinho
Re: Options either aren't passing or aren't displayed
Re:
I have 3 FXO ports on a TDM400P. I have ran the FXOtune acording to the above, and here are my results. I can;t get the first 2 lines below 10 percent. I have tried every fxotune.patch. and I can;t get it below that. any ideas? I am runnign aggressive cancellation, and I am running MG2. I have applied the bug fix to the fxotune file that stays with the default settings instead of allowing you to change them, AND I AM STILL HAVING THAT BUG. I am running zaptel 1.2.7: HELP!!!!
Should I try calling the 5 second tone then silence number on my switch?
./fxotune -d -b <zapchannel> -w 1004
Results:
Dumping module /dev/zap/3
echo ratio = 0.1107 (514.3 / 4645.1)
Done!
root@asterisk1 zaptel# ./fxotune -d -b 2
Dumping module /dev/zap/2
echo ratio = 0.1104 (512.7 / 4645.1)
Done!
root@asterisk1 zaptel# ./fxotune -d -b 4
Dumping module /dev/zap/4
echo ratio = 0.3259 (1513.9 / 4645.1)
Done!
Then I ran ./fxotune -i 5 -t 1
Results:
Dumping module /dev/zap/2
echo ratio = 0.1066 (1212.3 / 11367.0)
Done!
root@asterisk1 zaptel# ./fxotune -d -b 3 -w 1004
Dumping module /dev/zap/3
echo ratio = 0.1075 (1221.6 / 11367.0)
Done!
root@asterisk1 zaptel# ./fxotune -d -b 4 -w 1004
Dumping module /dev/zap/4
echo ratio = 0.0902 (1025.2 / 11367.0)
Done!
Finally ran fxotune -i 5 and here are the results....
root@asterisk1 zaptel# ./fxotune -d -b 2
Dumping module /dev/zap/2
echo ratio = 0.1093 (507.7 / 4645.1)
Done!
root@asterisk1 zaptel# ./fxotune -d -b 3
Dumping module /dev/zap/3
echo ratio = 0.1110 (515.8 / 4645.1)
Done!
root@asterisk1 zaptel# ./fxotune -d -b 4
Dumping module /dev/zap/4
echo ratio = 0.0414 (192.3 / 4645.1)
Done!