Richard Cochran
2013-11-09 16:14:01 UTC
Although the phc2sys program can use three different methods of measuring
clock offset, all of them are based on what essentially boils down to
software time stamping. This patch configures the default constants to
something more appropriate for SW time stamping.
Signed-off-by: Richard Cochran <***@gmail.com>
---
phc2sys.8 | 28 ++++++++++++++++++++++++++--
phc2sys.c | 9 +++------
2 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/phc2sys.8 b/phc2sys.8
index 5fcd6f0..56d0adc 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -85,10 +85,34 @@ Specify the slave clock by device (e.g. /dev/ptp1) or interface (e.g. eth1) or
by name. The default is CLOCK_REALTIME (the system clock).
.TP
.BI \-P " kp"
-Specify the proportional constant of the PI controller. The default is 0.7.
+Specify the proportional constant of the PI controller.
+When set to 0.0, the proportional constant will be set by the
+following formula from the current synchronization interval.
+
+kp_scale = 0.1
+.br
+kp_exponent = -0.3
+.br
+kp_norm_max = 0.7
+.br
+kp = min(kp_scale * sync^kp_exponent, kp_norm_max / sync))
+
+The default is 0.0.
.TP
.BI \-I " ki"
-Specify the integral constant of the PI controller. The default is 0.3.
+Specify the integral constant of the PI controller.
+When set to 0.0, the integral constant will be set by the
+following formula from the current synchronization interval.
+
+ki_scale = 0.001
+.br
+ki_exponent = 0.4
+.br
+ki_norm_max = 0.3
+.br
+ki = min(ki_scale * sync^ki_exponent, ki_norm_max / sync)
+
+The default is 0.0.
.TP
.BI \-S " step"
Specify the step threshold of the PI controller. It is the maximum offset that
diff --git a/phc2sys.c b/phc2sys.c
index 2b8af49..bcbff90 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -561,8 +561,8 @@ static void usage(char *progname)
" -c [dev|name] slave clock (CLOCK_REALTIME)\n"
" -d [dev] master PPS device\n"
" -s [dev|name] master clock\n"
- " -P [kp] proportional constant (0.7)\n"
- " -I [ki] integration constant (0.3)\n"
+ " -P [kp] proportional constant (0.0 = automatic)\n"
+ " -I [ki] integration constant (0.0 = automatic)\n"
" -S [step] step threshold (disabled)\n"
" -F [step] step threshold only on start (0.0000001)\n"
" -R [rate] slave clock update rate in HZ (1.0)\n"
@@ -598,9 +598,6 @@ int main(int argc, char *argv[])
.kernel_leap = 1,
};
- configured_pi_kp = KP;
- configured_pi_ki = KI;
-
/* Process the command line arguments. */
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
@@ -794,7 +791,7 @@ int main(int argc, char *argv[])
}
}
- dst_clock.servo = servo_create(CLOCK_SERVO_PI, -ppb, max_ppb, 0);
+ dst_clock.servo = servo_create(CLOCK_SERVO_PI, -ppb, max_ppb, 1);
if (pps_fd >= 0) {
servo_sync_interval(dst_clock.servo, 1.0);
clock offset, all of them are based on what essentially boils down to
software time stamping. This patch configures the default constants to
something more appropriate for SW time stamping.
Signed-off-by: Richard Cochran <***@gmail.com>
---
phc2sys.8 | 28 ++++++++++++++++++++++++++--
phc2sys.c | 9 +++------
2 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/phc2sys.8 b/phc2sys.8
index 5fcd6f0..56d0adc 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -85,10 +85,34 @@ Specify the slave clock by device (e.g. /dev/ptp1) or interface (e.g. eth1) or
by name. The default is CLOCK_REALTIME (the system clock).
.TP
.BI \-P " kp"
-Specify the proportional constant of the PI controller. The default is 0.7.
+Specify the proportional constant of the PI controller.
+When set to 0.0, the proportional constant will be set by the
+following formula from the current synchronization interval.
+
+kp_scale = 0.1
+.br
+kp_exponent = -0.3
+.br
+kp_norm_max = 0.7
+.br
+kp = min(kp_scale * sync^kp_exponent, kp_norm_max / sync))
+
+The default is 0.0.
.TP
.BI \-I " ki"
-Specify the integral constant of the PI controller. The default is 0.3.
+Specify the integral constant of the PI controller.
+When set to 0.0, the integral constant will be set by the
+following formula from the current synchronization interval.
+
+ki_scale = 0.001
+.br
+ki_exponent = 0.4
+.br
+ki_norm_max = 0.3
+.br
+ki = min(ki_scale * sync^ki_exponent, ki_norm_max / sync)
+
+The default is 0.0.
.TP
.BI \-S " step"
Specify the step threshold of the PI controller. It is the maximum offset that
diff --git a/phc2sys.c b/phc2sys.c
index 2b8af49..bcbff90 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -561,8 +561,8 @@ static void usage(char *progname)
" -c [dev|name] slave clock (CLOCK_REALTIME)\n"
" -d [dev] master PPS device\n"
" -s [dev|name] master clock\n"
- " -P [kp] proportional constant (0.7)\n"
- " -I [ki] integration constant (0.3)\n"
+ " -P [kp] proportional constant (0.0 = automatic)\n"
+ " -I [ki] integration constant (0.0 = automatic)\n"
" -S [step] step threshold (disabled)\n"
" -F [step] step threshold only on start (0.0000001)\n"
" -R [rate] slave clock update rate in HZ (1.0)\n"
@@ -598,9 +598,6 @@ int main(int argc, char *argv[])
.kernel_leap = 1,
};
- configured_pi_kp = KP;
- configured_pi_ki = KI;
-
/* Process the command line arguments. */
progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0];
@@ -794,7 +791,7 @@ int main(int argc, char *argv[])
}
}
- dst_clock.servo = servo_create(CLOCK_SERVO_PI, -ppb, max_ppb, 0);
+ dst_clock.servo = servo_create(CLOCK_SERVO_PI, -ppb, max_ppb, 1);
if (pps_fd >= 0) {
servo_sync_interval(dst_clock.servo, 1.0);
--
1.7.10.4
1.7.10.4