why not just use the pid component that is already in linuxcnc? On 1/24/2017 7:49 AM, EBo wrote: > On Jan 24 2017 6:29 AM, andy pugh wrote: >> 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. > I am not completely convinced that the offset calculation in case of > "absf(error) > deadband" is sufficient. The various terms might still > give you an unreasonable offset. Might need to clamp that as well, but > I am not fully sure what that would imply. > > EBo -- > > ------------------------------------------------------------------------------ > 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 > >
------------------------------------------------------------------------------ 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