hamlib/src
Dieter Röver 1a272f5b0e Fix bug in vfo_comp calculation in Hamlib
I tried to control my "FUNcube Dongle Pro" SDR with Hamlib. At first it
worked fine, but when I tried to correct the frequency divergence with
the vfo_comp parameter, I found a bug in the software.

Example:
$ ./rigctl -m 2513 -C vfo_comp=0.01
  Rig command: F 100000000
  Rig command: f
  Frequency: 102010000

The correction must toke place when setting the frequency and when it
is read back. But one time the correction must work in on direction,
the other time quite opposite.

I found the code in the file rig.c and could see, that both times the
same calculation is used.

The simplest way to correct this is to go to the “rig_get_freq(“
subroutine and change it in the line 1188 from “+=” to “-=” , even that
is mathematically not correct.

Result:
$ ./rigctl -m 2513 -C vfo_comp=0.01
  Rig command: F 100000000
  Rig command: f
  Frequency: 99990000

$ ./rigctl -m 2513 -C vfo_comp=0.000022
  Rig command: F 100000000
  Rig command: f
  Frequency: 99999999

You can see, that the result is quite good for small divergences of
some ppm, but there is still an error for bigger divergences. So I
changed the line 1188 to the form I hope it is the mathematically
correct one:

*freq = (freq_t)(*freq/(1.0+(double)rig->state.vfo_comp));

Result:
$ ./rigctl -m 2513 -C vfo_comp=0.01
  Rig command: F 100000000
  Rig command: f
  Frequency: 100000000

$ ./rigctl -m 2513 -C vfo_comp=0.000022
  Rig command: F 100000000
  Rig command: f
  Frequency: 100000000

Now the result looks good for small and for bigger divergences.

Best regards
Dieter Röver (DK6OV)
2018-02-23 12:34:28 -06:00
..
Android.mk Android build updates for monolithic build 2013-09-19 07:25:08 -05:00
cal.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
cal.h Update LGPL header in src source files. 2011-08-22 21:38:37 -05:00
cm108.c Addition of support for CM108B PTT 2018-02-19 06:42:08 -06:00
cm108.h Reformatted src directory 2017-08-09 06:14:31 -05:00
conf.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
debug.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
event.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
event.h Update LGPL header in src source files. 2011-08-22 21:38:37 -05:00
ext.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
gpio.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
gpio.h Add support for GPIO PTT. 2016-05-28 16:00:03 +02:00
idx_builtin.h Reformatted src directory 2017-08-09 06:14:31 -05:00
iofunc.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
iofunc.h Reformatted src directory 2017-08-09 06:14:31 -05:00
locator.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
Makefile.am Microham support. Use "uh-rig" for rig_pathname to talk to the 2017-09-10 19:56:59 -05:00
mem.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
microham.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
microham.h Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
misc.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
misc.h Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
network.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
network.h Clears potential garbage data in read buffer prior to command being sent 2017-01-25 20:45:24 -06:00
par_nt.h Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
parallel.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
parallel.h Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
register.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
register.h Reformatted src directory 2017-08-09 06:14:31 -05:00
rig.c Fix bug in vfo_comp calculation in Hamlib 2018-02-23 12:34:28 -06:00
rot_conf.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
rot_conf.h Update LGPL header in src source files. 2011-08-22 21:38:37 -05:00
rot_reg.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
rotator.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
serial.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
serial.h Update LGPL header in src source files. 2011-08-22 21:38:37 -05:00
settings.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
token.h Reformatted src directory 2017-08-09 06:14:31 -05:00
tones.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
tones.h Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
usb_port.c Formatted src/ to final coding guidelines 2017-10-04 21:32:08 -05:00
usb_port.h Update LGPL header in src source files. 2011-08-22 21:38:37 -05:00