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
7
Merge Requests
7
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
22a4bef2
Commit
22a4bef2
authored
Sep 08, 2020
by
Guido Visser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modifcations for use HPSEC and tuning on the command line
parent
32934014
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
150 additions
and
45 deletions
+150
-45
TuneGuido.h
include/TuneGuido.h
+12
-2
cmd_tune.c
shell/cmd_tune.c
+44
-23
softpll_ng.c
softpll/softpll_ng.c
+48
-0
softpll_ng.h
softpll/softpll_ng.h
+5
-0
spll_common.h
softpll/spll_common.h
+1
-0
spll_main.c
softpll/spll_main.c
+32
-11
wrc_main.c
wrc_main.c
+8
-9
No files found.
include/TuneGuido.h
View file @
22a4bef2
#ifndef __TUNEGUIDO_H
#define __TUNEGUIDO_H
static
int32_t
pguido
=-
201
,
iguido
=-
11
;
static
int32_t
*
Kphpsec
,
*
Kihpsec
;
static
int32_t
*
Kphpsec
;
static
int32_t
*
Kihpsec
;
static
int32_t
holdVtune
=
0
;
static
int32_t
VtuneHoldVal
;
/*
const uint32_T B[15] = {
0, 0, 27442877, 117306601, 0, 0,
651916251, 1250090468, 651916251, 0, 0, 117306601,
27442877, 0, 0
};
int32_t ring_buffer[15];*/
#endif
shell/cmd_tune.c
View file @
22a4bef2
...
...
@@ -4,8 +4,6 @@
* Released according to the GNU GPL, version 2 or any later version.
*/
#include <stdlib.h>
#include <string.h>
#include <errno.h>
...
...
@@ -13,35 +11,58 @@
#include "softpll_ng.h"
#include "shell.h"
#include "spll_common.h"
#include <TuneGuido.h>
#include <TuneGuido.h>
#include "softpll_ng.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
])
int
GuidoTemp
=
0
,
A
=
0
,
B
=
0
;
//pp_printf("Tuning the world\n");
if
(
!
strcasecmp
(
args
[
0
],
"val"
)){
if
(
!
args
[
0
])
return
-
EINVAL
;
pp_printf
(
"Hello dave
\n
"
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"KpKi"
)){
}
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);
}
A
=
(
atoi
(
args
[
1
]));
Kphpsec
=
&
A
;
pp_printf
(
"A:%i
\t
Aptr: %i
\n
"
,
A
,
*
Kphpsec
);
B
=
(
atoi
(
args
[
2
]));
Kihpsec
=
&
B
;
pp_printf
(
"B:%i
\t
Bptr: %i
\n
"
,
B
,
*
Kihpsec
);
pp_printf
(
"Entered Kp:%i
\t
Ki: %i
\n
"
,
*
Kphpsec
,
*
Kihpsec
);
spll_set_pi
(
*
Kphpsec
,
*
Kihpsec
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"kp"
)){
if
(
!
args
[
1
])
return
-
EINVAL
;
A
=
(
atoi
(
args
[
1
]));
Kihpsec
=
&
A
;
//pp_printf("A:%i\t Aptr: %i\n",A,*Kphpsec);
spll_set_pi_solo_kp
(
A
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"ki"
)){
if
(
!
args
[
1
])
return
-
EINVAL
;
B
=
(
atoi
(
args
[
1
]));
Kihpsec
=
&
B
;
//pp_printf("A:%i\t Aptr: %i\n",B,*Kihpsec);
spll_set_pi_solo_ki
(
B
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"show"
)){
if
(
!
args
[
0
])
return
-
EINVAL
;
spll_show_kpki
();
}
else
if
(
!
strcasecmp
(
args
[
0
],
"init"
)){
if
(
!
args
[
0
])
return
-
EINVAL
;
spll_init
(
3
,
0
,
0
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"picontrol"
)){
if
(
!
args
[
1
])
return
-
EINVAL
;
spll_set_vtune_off
(
atoi
(
args
[
1
]));
}
//pp_printf("%d\n", spll_check_lock(atoi(args[1])));
else
else
return
-
EINVAL
;
return
0
;
...
...
softpll/softpll_ng.c
View file @
22a4bef2
...
...
@@ -889,3 +889,51 @@ void spll_set_aux_mode( int channel, int mode )
{
softpll
.
aux
[
channel
].
mode
=
mode
;
}
// Guido's heel smerig manier om er data in te proppem
void
spll_set_pi
(
int
kp
,
int
ki
)
{
//A=softpll.mpll.pi.y;
//pp_printf("output PI Y %i\n",softpll.mpll.pi.y);
softpll
.
mpll
.
pi
.
kp
=
kp
;
softpll
.
mpll
.
pi
.
ki
=
ki
;
spll_show_kpki
();
//pp_printf("setted Kp %i\t Ki %i\n",softpll.mpll.pi.kp,softpll.mpll.pi.ki);
}
void
spll_set_pi_solo_kp
(
int
kp
)
{
softpll
.
mpll
.
pi
.
kp
=
kp
;
spll_show_kpki
();
}
void
spll_set_vtune_off
(
int
control
)
{
int
A
=
0
;
softpll
.
mpll
.
pi
.
disablecontrol
=
control
;
A
=
softpll
.
mpll
.
pi
.
disablecontrol
;
pp_printf
(
"PI bypass? %i
\n
"
,
A
);
pp_printf
(
"OUTATIME
\n
"
);
}
void
spll_set_pi_solo_ki
(
int
ki
)
{
softpll
.
mpll
.
pi
.
ki
=
ki
;
spll_show_kpki
();
}
void
spll_show_kpki
()
{
// to display actual Kp Ki
pp_printf
(
"setted Kp %i
\t
Ki %i
\n
"
,
softpll
.
mpll
.
pi
.
kp
,
softpll
.
mpll
.
pi
.
ki
);
pp_printf
(
"PI bypass? %i
\n
"
,
softpll
.
mpll
.
pi
.
disablecontrol
);
}
softpll/softpll_ng.h
View file @
22a4bef2
...
...
@@ -131,6 +131,11 @@ int spll_get_debug_queue_samples( uint32_t *buf, int size, int undersample );
void
spll_debug_queue_purge
(
void
);
void
spll_set_aux_mode
(
int
channel
,
int
mode
);
void
spll_set_pi
(
int
kp
,
int
ki
);
void
spll_set_pi_solo_kp
(
int
kp
);
void
spll_set_pi_solo_ki
(
int
ki
);
void
spll_set_vtune_off
(
int
control
);
void
spll_show_kpki
();
/*
* Aux and main state:
...
...
softpll/spll_common.h
View file @
22a4bef2
...
...
@@ -39,6 +39,7 @@ typedef struct {
int
y_max
;
int
x
,
y
,
d
;
/* Current input (x) and output value (y) */
int
dithered
;
/* Enable dithering of DAC output */
int
disablecontrol
;
/* only for testing.*/
}
spll_pi_t
;
/* lock detector state */
...
...
softpll/spll_main.c
View file @
22a4bef2
...
...
@@ -46,13 +46,17 @@ 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
=
-
2
00
;
// / 2;
s
->
pi
.
kp
=
-
30
00
;
// / 2;
s
->
pi
.
ki
=
-
10
;
// / 2;
s
->
pi
.
kd
=
0
;
s
->
pi
.
kd
=
0
;
// is not nessary...
#else
#error "Please set CONFIG for wr switch or wr node"
#endif
//pp_printf("Main PLL PI Values enter: Kp %i\t Ki%i\n",A,B);
s
->
pi
.
disablecontrol
=
1
;
// Only for testing added.
pp_printf
(
"Main PLL PI Values: Kp %i
\t
Ki%i
\n
"
,
s
->
pi
.
kp
,
s
->
pi
.
ki
);
s
->
enabled
=
0
;
/* Freqency branch lock detection */
...
...
@@ -62,7 +66,6 @@ void mpll_init(struct spll_main_state *s, int id_ref,
s
->
id_ref
=
id_ref
;
s
->
id_out
=
id_out
;
s
->
dac_index
=
id_out
-
spll_n_chan_ref
;
pp_printf
(
"Main PLL PI Values: Kp %i
\t
Ki%i
\n
"
,
s
->
pi
.
kp
,
s
->
pi
.
ki
);
if
(
s
->
gain_sched
)
{
...
...
@@ -216,13 +219,31 @@ 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
;
if
(
s
->
pi
.
disablecontrol
==
0
)
{
y
=
VtuneHoldVal
;
}
else
{
y
=
pi_update
((
spll_pi_t
*
)
&
s
->
pi
,
err
);
// pp_printf("DAC VAL %i\n",y);
VtuneHoldVal
=
y
;
// for (k=0; k<15; k++)
// {
// ring_buffer[15]=y;
// }
// k=0;
}
// for
// Y = (coeffsLPF[k])*(ring_buffer[(k+rb_idx)%FilterSize]);
SPLL
->
DAC_MAIN
=
SPLL_DAC_MAIN_VALUE_W
(
y
)
|
SPLL_DAC_MAIN_DAC_SEL_W
(
s
->
dac_index
);
if
(
s
->
dac_index
==
0
)
...
...
wrc_main.c
View file @
22a4bef2
...
...
@@ -47,6 +47,7 @@
#endif
#ifdef CONFIG_LLDP
#include "lib/lldp.h"
#endif
...
...
@@ -54,10 +55,6 @@ char wrc_hw_name[HW_NAME_LENGTH];
uint32_t
cal_phase_transition
=
2389
;
// dirty Hack
int
wrc_vlan_number
=
CONFIG_VLAN_NR
;
...
...
@@ -74,6 +71,9 @@ static void wrc_initialize(void)
#ifdef CONFIG_USE_SDB
sdb_find_devices
();
#endif
// dirty Hack
// Kphpsec=&pguido;
// Kihpsec=&iguido;
console_init
();
timer_init
(
1
);
...
...
@@ -81,12 +81,11 @@ static void wrc_initialize(void)
usleep_init
();
wrc_board_early_init
();
pp_printf
(
"WR Core: starting up...
\n
"
);
Kphpsec
=&
pguido
;
pp_printf
(
"Val of %d
\n
"
,
*
Kphpsec
);
pp_printf
(
"Val of %d
\t
%d
\n
n"
,
Kphpsec
,
Kihpsec
);
get_hw_name
(
wrc_hw_name
);
net_rst
();
ep_init
();
/* Sleep for 1s to make sure WRS v4.2 always realizes that
...
...
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