Commit 22a4bef2 authored by Guido Visser's avatar Guido Visser

Modifcations for use HPSEC and tuning on the command line

parent 32934014
#ifndef __TUNEGUIDO_H
#define __TUNEGUIDO_H
static int32_t pguido=-201,iguido=-11;
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
};
static int32_t pguido=-201,iguido=-11;
static int32_t *Kphpsec,*Kihpsec;
int32_t ring_buffer[15];*/
#endif
......@@ -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);
}
//pp_printf("%d\n", spll_check_lock(atoi(args[1])));
else
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]));
}
else
return -EINVAL;
return 0;
......
......@@ -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);
}
......@@ -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:
......
......@@ -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 */
......
......@@ -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 = -200; // / 2;
s->pi.kp = -3000; // / 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,9 +66,8 @@ 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 )
if( s->gain_sched )
{
s->gain_sched->current_stage = 0;
s->gain_sched->locked_d = 0;
......@@ -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)
......
......@@ -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("WR Core: starting up...\n");
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
......@@ -201,7 +200,7 @@ int wrc_is_timing_up()
{
return prev_timing_ok;
}
static void wrc_dispatch_ptp_events_init(void)
{
prev_ptp_mode = -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment