On Thu, Mar 3, 2011 at 1:45 PM, andy pugh <bodge...@gmail.com> wrote:

> On 3 March 2011 16:53, Jon Elson <el...@pico-systems.com> wrote:
>
> > I STILL don't like it.  You need a HAL component that looks at commanded
> > position
> > (comes from axis.8.motor-pos-cmd, I think) and compares current to last
> > position.
>
> Whilst also not liking it, this custom HAL component would do the
> trick: (It needs to be compiled with comp --install timeout.comp)
>
> component timeout """Reduces motor command to a predetermied value after a
> certain number of seconds of no axis motion""";
>
> pin in float position-command-in "link to motor-pos-cmd";
> pin in float current-in "link to the PID output";
> pin out float current-out "link to the DAC";
> param rw float timeout = 10 "timeout in seconds";
> param rw float default-current = 0 "current output after timeout";
> variable float old_pos;
> variable float t = 0;
> function _;
> license "GPL";
> author "Andy Pugh";
>
> ;;
>
> FUNCTION(_){
>    if (old_pos != position_command_in){
>        t = timeout;
>    }
>    else {
>        t -= fperiod;
>    }
>
>    if (t < 0){
>        current_out = default_current;
>    }
>    else {
>        current_out = current_in;
>    }
>
>    old_pos = position_command_in;
> }
>
>
>
Andy, this is an awesome comp, except that it does not quite work. Here's
the version that I use:

 component timeout """Reduces motor command to a predetermied value after a
certain number of seconds of no axis motion""";

pin in float position-command-in "link to motor-pos-cmd";
pin in float current-in "link to the PID output";
pin out float current-out "link to the DAC";
param rw float timeout = 10 "timeout in seconds";
param rw float default-current = 0 "current output after timeout";
variable float old_pos;
variable float t = 0;
function _;
license "GPL";
author "Andy Pugh";

;;

FUNCTION(_){
   if (old_pos != position_command_in){
       t = timeout;
   }
   else {
       t -= fperiod;
   }

   if (t < 0){
       current_out = default_current * current_in;
   }
   else {
       current_out = current_in;
   }

   old_pos = position_command_in;
}

It works in the sense that its output is equal to input.

It does not work in the sense that it does not shut down after 10 seconds.

Your code looks very good to me, and I think that what is happening is that
you are trying to subtract a small number fperiod, from a large number t,
and that does not work.

The config I have says

newsig pid-W-out        float
#newsig pid-W-command-in float

setp w_axis_timeout.default-current 0 # current factor applied after timeout
setp w_axis_timeout.timeout        10 # Timeout in seconds

linksp pid-W-out               <= pid.4.output                  # pid-W-out
is output of pid 4
linksp Wpos-cmd                => w_axis_timeout.position-command-in     #
and it goes into timeout
linksp pid-W-out               => w_axis_timeout.current-in     # and it
goes into timeout
linksp Woutput                 <= w_axis_timeout.current-out    # output
from timeout will go to motor

i
------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to