On 24 January 2017 at 00:06, John Thornton <j...@gnipsel.com> wrote:
>     if(enable){
>         float min_velocity = requested_vel
> -(requested_vel*(1/velocity_tol));
>         if(current_vel > 0 && current_vel >= min_velocity){vel_status = 1;}
>         else {vel_status = 0;}
>
>         if(torch_on && arc_ok && vel_status){ // allow correction
>             //if(volts_requested - volts > volts_limit){
>             //    volts = volts_requested - volts_limit;
>             //}
>             //else if(volts_requested + volts > volts_limit){
>             //   volts = volts_requested +volts_limit;
>             //}
>             if (abs(volts_requested - volts) > voltage_tol) {
>                 offset += (volts_requested - volts) * p_gain;
>             }
>             last_z_in = 0;
>         }


The code for an actual PID is pretty simple.

static double olderror, iterm
        if(torch_on && arc_ok && vel_status){ // allow correction
            error = (volts_requested - volts)
            dterm = (error - olderrer) * Dgain
            olderror = error
            iterm += error * Igain
            pterm = error * Pgain
            if (absf(error) > deadband){
                 offset += pterm + iterm + dterm
            }

Is close. You probably need to initialise olderror intelligently, to
avoid a single-cycle crazy value.

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1916

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to