Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: Problem: FE_GET_FRONTEND frequency in alps_bsrv2.c



Wolfgang Thiel wrote:
As nobody replied to my first message, I'll try it again:

The code to retrieve the locked frequency in alps_bsrv2.c
is obviously wrong:

        case FE_GET_FRONTEND:
        {
                struct dvb_frontend_parameters *p = arg;
                s32 afc;
                afc = ((int)((char)(ves1893_readreg (i2c, 0x0a) << 1)))/2;
                afc = (afc * (int)(p->u.qpsk.symbol_rate/8))/16;

                p->frequency += afc;
that's just a straightforward implementation of the formula given in the ves1893 reference manual.


Below are some values for different symbolrates; I'm reporting the
value of afc = ((int)((char)(ves1893_readreg (i2c, 0x0a) << 1)))/2;

27.5 22.0 12.130 11.000 5.632
--------------------------------------------------
Freq -2000 kHz -9 -11 Freq -1750 kHz -8 -9 Freq -1500 kHz -7 -8 -16 Freq -1250 kHz -5 -6 -13 -15
Freq -1000 kHz -4 -5 -11 -12 Freq - 750 kHz -3 -4 -8 -9 -18
Freq - 500 kHz -2 -2 -6 -6 -12
Freq - 250 kHz -1 -1 -3 -3 -6
Freq +i 0 kHz 0 1 0 0 -1
Freq + 250 kHz 2 2 2 3 5
Freq + 500 kHz 3 4 5 6 11
Freq + 750 kHz 4 5 8 9 16
Freq +1000 kHz 5 7 10 14
Freq +1250 kHz 6 8 13
Freq +1500 kHz 7 10 16
Freq +1750 kHz 9 11 Freq +2000 kHz 10 12
...
[snip]
...
It will look something like this in the end:

        case FE_GET_FRONTEND:
        {
                struct dvb_frontend_parameters *p = arg;
                s32 afc, correction;
                afc = ((int)((char)(ves1893_readreg (i2c, 0x0a) << 1)))/2;

                correction = ((afc * X) / (p->u.qpsk.symbol_rate / Y)) * Z;

                p->frequency -= correction;


What are good values for X, Y, Z?
Since X, Y and Z are simple scaling factors for the fraction afc/symbol_rate you simplify your formula to:

correction = X * reg0x0a / p->u.qpsk.symbol_rate

so X is:

X = correction * p->u.qpsk.symbol_rate / reg0x0a

When you calculate X from the entries in your table above, you see that you get very different values for X so your formula is not consistent with your measurements.

If you try the original formula

correction = reg0x0a * p->u.qpsk.symbol_rate / X

you get:

X = (reg0x0a * p->u.qpsk.symbol_rate) / correction

which leads to more consistent values of X between 100 and 150 (close to the original value of 128). But you might be right that the way how this correction offset is scaled and added to the original frequency is not correct.

And you're perfectly right that this formula should get written down more clearly in the code...

Please let us know when you get an idea how this should get solved better.

Holger



--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index