]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/commitdiff
RoCoN: include support to select alternative controller type.
authorPavel Pisa <ppisa@pikron.com>
Sat, 13 Jun 2015 17:28:22 +0000 (19:28 +0200)
committerPavel Pisa <ppisa@pikron.com>
Sat, 13 Jun 2015 17:28:22 +0000 (19:28 +0200)
The actual choice is between standard PID and PID
with non-linear/accelerated I component decrease.

Signed-off-by: Pavel Pisa <ppisa@pikron.com>
submodule/pxmc
sw/app/rocon/appl_cmds.c
sw/app/rocon/appl_pxmc.c
sw/app/rocon/appl_pxmc.h

index 002bf91c0907845b45bb7d5a8221edd57ce722da..7e85415ba55fe746ddc1fc230244abc4908ac389 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 002bf91c0907845b45bb7d5a8221edd57ce722da
+Subproject commit 7e85415ba55fe746ddc1fc230244abc4908ac389
index 7923cb86f497867874e5bb070a80bec626666144..7c029249f1f458dfcff50b4b36f64373d192e795 100644 (file)
@@ -96,6 +96,30 @@ int cmd_do_pthalign(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
     return 0;
 }
 
+int cmd_do_reg_type(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+{
+  int val;
+  pxmc_state_t *mcs;
+
+  if((mcs=cmd_opchar_getreg(cmd_io,des,param))==NULL) return -CMDERR_BADREG;
+
+  if(*param[2]=='?') {
+    return cmd_opchar_replong(cmd_io, param, pxmc_get_reg_type(mcs), 0, 0);
+  }
+
+  if(*param[2]!=':') return -CMDERR_OPCHAR;
+
+  if(mcs->pxms_flg&PXMS_BSY_m) return -CMDERR_BSYREG;
+
+  val=atol(param[3]);
+  val=pxmc_set_reg_type(mcs, val);
+
+  if(val<0)
+    return val;
+
+  return 0;
+}
+
 /**
  * cmd_do_axis_mode - checks the command format and busy flag validity, calls pxmc_axis_mode
  *
@@ -290,6 +314,9 @@ cmd_des_t const cmd_des_stamp={0, CDESM_OPCHR,
 cmd_des_t const cmd_des_pthalign={0, CDESM_OPCHR|CDESM_RW,"PTHALIGN?","run alignement of phase according to HAL",
                        cmd_do_pthalign,
                        {0,0}};
+cmd_des_t const cmd_des_reg_type={0, CDESM_OPCHR|CDESM_RW,
+                       "REGTYPE?","select controller structure and type",cmd_do_reg_type,
+                       {}};
 cmd_des_t const cmd_des_axis_mode={0, CDESM_OPCHR|CDESM_WR,
                        "REGMODE?","axis working mode",cmd_do_axis_mode,
                        {}};
@@ -324,6 +351,7 @@ cmd_des_t const *const cmd_appl_specific[]={
   &cmd_des_status_bsybits,
   &cmd_des_stamp,
   &cmd_des_pthalign,
+  &cmd_des_reg_type,
   &cmd_des_axis_mode,
   &cmd_des_axes_outmap,
   &cmd_des_errstop,
index 6d44c8af32096694695053edde24bf5bdaa1fca2..5d19fb70caf12f56efe000e350d0d2617f657f9d 100644 (file)
@@ -2493,6 +2493,37 @@ void pxmc_sfi_isr(void)
 
 }
 
+pxmc_call_t *const pxmc_reg_type_table[] = {
+  pxmc_pid_con,
+  pxmc_pid_con,
+  pxmc_pidnl_con
+};
+
+
+int pxmc_get_reg_type(pxmc_state_t *mcs)
+{
+  int reg_type;
+  int max_type = sizeof(pxmc_reg_type_table) / sizeof(*pxmc_reg_type_table);
+
+  for (reg_type = 1; reg_type < max_type; reg_type++)
+    if (mcs->pxms_do_con == pxmc_reg_type_table[reg_type])
+      return reg_type;
+  return 0;
+}
+
+int pxmc_set_reg_type(pxmc_state_t *mcs, int reg_type)
+{
+  int max_type = sizeof(pxmc_reg_type_table) / sizeof(*pxmc_reg_type_table);
+
+  if ((reg_type < 0) || (reg_type >= max_type))
+    return -1;
+  if (mcs->pxms_flg & PXMS_ENR_m)
+    return -1;
+
+  mcs->pxms_do_con = pxmc_reg_type_table[reg_type];
+  return 0;
+}
+
 int pxmc_clear_power_stop(void)
 {
   return 0;
index 2b68cbe61c21ca89c58c40df4a4455b2eb66d656..1077cfa1bf6bdb9674ec04ce7209f6e42b79c50e 100644 (file)
@@ -46,4 +46,8 @@ int pxmc_rocon_pwm_direct_wr(unsigned chan, unsigned pwm, int en);
 
 int pxmc_rocon_wait_rx_done(void);
 
+int pxmc_get_reg_type(pxmc_state_t *mcs);
+
+int pxmc_set_reg_type(pxmc_state_t *mcs, int reg_type);
+
 #endif /*_APPL_PXMC_H_*/