Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
32934014
Commit
32934014
authored
Aug 26, 2020
by
Guido Visser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start to make that PI parameters can be tuned via the cmd
parent
1d709171
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
104 additions
and
19 deletions
+104
-19
rxts_calibrator.c
dev/rxts_calibrator.c
+1
-1
TuneGuido.h
include/TuneGuido.h
+7
-0
wrc.h
include/wrc.h
+2
-0
cmd_tune.c
shell/cmd_tune.c
+53
-0
shell.c
shell/shell.c
+1
-1
shell.mk
shell/shell.mk
+1
-0
spll_common.c
softpll/spll_common.c
+11
-8
spll_common.h
softpll/spll_common.h
+3
-3
spll_helper.c
softpll/spll_helper.c
+1
-0
spll_helper.h
softpll/spll_helper.h
+1
-1
spll_main.c
softpll/spll_main.c
+12
-4
wrc_main.c
wrc_main.c
+11
-1
No files found.
dev/rxts_calibrator.c
View file @
32934014
...
...
@@ -272,6 +272,6 @@ int calib_t24p(int mode, uint32_t *value)
//update phtrans value in socket struct
if
(
ret
>=
0
)
ptpd_netif_set_phase_transition
(
*
value
);
//
ptpd_netif_set_phase_transition(*value);
return
ret
;
}
include/TuneGuido.h
0 → 100755
View file @
32934014
#ifndef __TUNEGUIDO_H
#define __TUNEGUIDO_H
static
int32_t
pguido
=-
201
,
iguido
=-
11
;
static
int32_t
*
Kphpsec
,
*
Kihpsec
;
#endif
include/wrc.h
View file @
32934014
...
...
@@ -22,6 +22,8 @@
#include <wrc-debug.h>
#define sprintf pp_sprintf
//static int32_t pguido=-201,iguido=-11;
//static int32_t *Kphpsec,*Kpihpsec;
#ifndef min
#define min(a, b) \
...
...
shell/cmd_tune.c
0 → 100755
View file @
32934014
/*
* This work is part of the White Rabbit project
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <wrc.h>
#include "softpll_ng.h"
#include "shell.h"
#include "spll_common.h"
#include <TuneGuido.h>
struct
spll_main_state
*
s
;
static
int
cmd_tune
(
const
char
*
args
[])
{
int
cur
,
tgt
,
GuidoTemp
;
pp_printf
(
"Tuning the world
\n
"
);
pp_printf
(
"Val of %d
\n
"
,
*
Kphpsec
);
if
(
!
strcasecmp
(
args
[
0
],
"hello hal"
)){
if
(
!
args
[
1
])
return
-
EINVAL
;
pp_printf
(
"Hello dave
\n
"
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"KpKi"
)){
if
(
!
args
[
2
])
return
-
EINVAL
;
GuidoTemp
=
(
atoi
(
args
[
1
]));
*
Kphpsec
=
GuidoTemp
;
GuidoTemp
=
(
atoi
(
args
[
2
]));
*
Kihpsec
=
GuidoTemp
;
pp_printf
(
"Kp %d
\n
"
,
*
Kphpsec
);
pp_printf
(
"Ki %d
\n
"
,
*
Kihpsec
);
//pp_printf("test GuidoTemp %d\n",GuidoTemp);
}
//pp_printf("%d\n", spll_check_lock(atoi(args[1])));
else
return
-
EINVAL
;
return
0
;
}
DEFINE_WRC_COMMAND
(
tune
)
=
{
.
name
=
"tune"
,
.
exec
=
cmd_tune
,
};
shell/shell.c
View file @
32934014
...
...
@@ -364,7 +364,7 @@ void shell_register_commands(void)
REGISTER_WRC_COMMAND
(
diag
);
REGISTER_WRC_COMMAND
(
init
);
REGISTER_WRC_COMMAND
(
sfp
);
REGISTER_WRC_COMMAND
(
tune
);
if
(
HAS_IP
)
REGISTER_WRC_COMMAND
(
ip
);
}
shell/shell.mk
View file @
32934014
...
...
@@ -7,6 +7,7 @@ obj-$(CONFIG_WR_NODE) += \
shell/cmd_ps.o \
shell/cmd_uptime.o \
shell/cmd_refresh.o \
shell/cmd_tune.o \
shell/cmd_diag.o
obj-$(CONFIG_EMBEDDED_NODE) += \
...
...
softpll/spll_common.c
View file @
32934014
...
...
@@ -17,7 +17,7 @@
static
int
gen_dither
(
int
pi_shift
)
{
static
const
uint32_t
lcg_m
=
1103515245
;
static
const
uint32_t
lcg_i
=
12345
;
static
const
uint32_t
lcg_i
=
12345
;
static
uint32_t
seed
=
0
;
seed
*=
lcg_m
;
...
...
@@ -29,18 +29,22 @@ static int gen_dither( int pi_shift )
return
-
d
;
else
return
d
;
}
int
pi_update
(
spll_pi_t
*
pi
,
int
x
)
{
int64_t
i_new
;
int64_t
i_new
,
d_new
;
int
y
;
int
d
;
pi
->
x
=
x
;
i_new
=
pi
->
integrator
+
(
int64_t
)
pi
->
ki
*
x
;
pi
->
d
=
d
;
int64_t
y_preround
=
(
i_new
+
(
int64_t
)
x
*
pi
->
kp
)
+
(
1
<<
(
pi
->
shift
-
1
)
);
i_new
=
pi
->
integrator
+
(
int64_t
)
pi
->
ki
*
x
;
//d_new = pi->derivative
d_new
=
(
x
-
pi
->
derivative
);
int64_t
y_preround
=
(
i_new
+
(
int64_t
)
x
*
pi
->
kp
)
+
pi
->
kd
*
d_new
+
(
1
<<
(
pi
->
shift
-
1
)
);
int
dither
=
pi
->
dithered
?
gen_dither
(
pi
->
shift
)
:
0
;
y
=
(
(
y_preround
+
dither
)
>>
pi
->
shift
)
+
pi
->
bias
;
...
...
@@ -77,7 +81,7 @@ void pi_init(spll_pi_t *pi)
if it's withing an acceptable range (i.e. <-ld.threshold,
ld.threshold>. If it has been inside the range for
(ld.lock_samples) cyckes, the FSM assumes the PLL is locked.
Return value:
0: PLL not locked
1: PLL locked
...
...
@@ -117,7 +121,7 @@ void ld_init(spll_lock_det_t *ld)
ld
->
lock_changed
=
0
;
}
/* Enables/disables DDMTD tag generation on a given (channel).
/* Enables/disables DDMTD tag generation on a given (channel).
Channels (0 ... splL_n_chan_ref - 1) are the reference channels
(e.g. transceivers' RX clocks or a local reference)
...
...
@@ -147,4 +151,3 @@ void spll_enable_tagger(int channel, int enable)
pll_verbose
(
"%s: ch %d, OCER 0x%x, RCER 0x%x
\n
"
,
__FUNCTION__
,
channel
,
SPLL
->
OCER
,
SPLL
->
RCER
);
}
softpll/spll_common.h
View file @
32934014
...
...
@@ -30,14 +30,14 @@ extern volatile struct PPSG_WB *PPSG;
/* PI regulator state */
typedef
struct
{
int
ki
,
kp
;
/* integral and proportional gains (1<<PI_FRACBITS == 1.0f) */
int
ki
,
kp
,
kd
;
/* integral and proportional gains (1<<PI_FRACBITS == 1.0f) */
int
shift
;
/* fractional bits shift factor (defaults to PI_FRACBITS) */
int64_t
integrator
;
/* current integrator value */
int64_t
integrator
,
derivative
;
/* current integrator value */
int
bias
;
/* DC offset always added to the output */
int
anti_windup
;
/* when non-zero, anti-windup is enabled */
int
y_min
;
/* min/max output range, used by clapming and antiwindup algorithms */
int
y_max
;
int
x
,
y
;
/* Current input (x) and output value (y) */
int
x
,
y
,
d
;
/* Current input (x) and output value (y) */
int
dithered
;
/* Enable dithering of DAC output */
}
spll_pi_t
;
...
...
softpll/spll_helper.c
View file @
32934014
...
...
@@ -25,6 +25,7 @@ void helper_init(struct spll_helper_state *s, int ref_channel)
// s->pi.ki = -10; // / 2;
s
->
pi
.
kp
=
-
750
;
// / 2;
s
->
pi
.
ki
=
-
2
;
// / 2;
s
->
pi
.
kd
=
0
;
#else
s
->
pi
.
kp
=
150
;
s
->
pi
.
ki
=
2
;
...
...
softpll/spll_helper.h
View file @
32934014
...
...
@@ -20,7 +20,7 @@
#define HELPER_TAG_WRAPAROUND 100000000
/* Maximum abs value of the phase error. If the error is bigger, it's
* clamped to this value. */
#define HELPER_ERROR_CLAMP 150000
...
...
softpll/spll_main.c
View file @
32934014
...
...
@@ -11,6 +11,7 @@
#include <wrc.h>
#include "softpll_ng.h"
#include <TuneGuido.h>
#define MPLL_TAG_WRAPAROUND 100000000
...
...
@@ -45,8 +46,10 @@ void mpll_init(struct spll_main_state *s, int id_ref,
#elif defined(CONFIG_WR_NODE) && defined(CONFIG_TARGET_SPEC7)
// s->pi.kp = -800; // / 2;
// s->pi.ki = -10; // / 2;
s
->
pi
.
kp
=
-
5500
;
// / 2;
s
->
pi
.
ki
=
-
30
;
// / 2;
s
->
pi
.
kp
=
-
200
;
// / 2;
s
->
pi
.
ki
=
-
10
;
// / 2;
s
->
pi
.
kd
=
0
;
#else
#error "Please set CONFIG for wr switch or wr node"
#endif
...
...
@@ -213,7 +216,13 @@ int mpll_update(struct spll_main_state *s, int tag, int source)
#endif
//s->pi.kp = Kphpsec;
//s->pi.ki = Kpihpsec;
//s->pi.kd = 0;
s
->
pi
.
kp
=
*
Kphpsec
;
s
->
pi
.
ki
=
*
Kihpsec
;
y
=
pi_update
((
spll_pi_t
*
)
&
s
->
pi
,
err
);
// pp_printf("DAC VAL %i\n",y);
SPLL
->
DAC_MAIN
=
SPLL_DAC_MAIN_VALUE_W
(
y
)
|
SPLL_DAC_MAIN_DAC_SEL_W
(
s
->
dac_index
);
if
(
s
->
dac_index
==
0
)
...
...
@@ -254,7 +263,7 @@ int mpll_update(struct spll_main_state *s, int tag, int source)
}
ld_update
((
spll_lock_det_t
*
)
&
s
->
ld
,
err
);
if
(
s
->
ld
.
lock_changed
)
if
(
s
->
ld
.
lock_changed
)
spll_debug
(
DBG_EVENT
|
DBG_MAIN
,
DBG_EVT_LOCKED
,
1
);
mpll_handle_gain_schedule
(
s
);
...
...
@@ -301,4 +310,3 @@ int mpll_shifter_busy(struct spll_main_state *s)
{
return
s
->
phase_shift_target
!=
s
->
phase_shift_current
;
}
wrc_main.c
View file @
32934014
...
...
@@ -36,6 +36,7 @@
#include <system_checks.h>
#include <ppsi/ppsi.h>
#include <TuneGuido.h>
#ifdef CONFIG_DAC_LOG
#include "dev/dac_log.h"
...
...
@@ -53,6 +54,11 @@ char wrc_hw_name[HW_NAME_LENGTH];
uint32_t
cal_phase_transition
=
2389
;
// dirty Hack
int
wrc_vlan_number
=
CONFIG_VLAN_NR
;
// fixme: this probably deserves to be moved to another file...
...
...
@@ -77,6 +83,8 @@ static void wrc_initialize(void)
wrc_board_early_init
();
pp_printf
(
"WR Core: starting up...
\n
"
);
Kphpsec
=&
pguido
;
pp_printf
(
"Val of %d
\n
"
,
*
Kphpsec
);
get_hw_name
(
wrc_hw_name
);
net_rst
();
...
...
@@ -219,7 +227,7 @@ static int wrc_dispatch_ptp_events_poll(void)
prev_ptp_mode
=
mode
;
// observe the PTP state machine transitions and the servo state - and depending on the mode of
// observe the PTP state machine transitions and the servo state - and depending on the mode of
// operation (master/slave), send the 'Timing up'/'Timing down' events.
if
(
mode
==
WRC_MODE_MASTER
)
{
...
...
@@ -328,5 +336,7 @@ int main(void)
events_dispatch
();
/* better safe than sorry */
check_stack
();
// dirty Hack
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment