Thanks for that code, I looked at pid.c a few times but > 600 lines of C 
made me dizzy. Let me see what I can do with that.

JT


On 1/24/2017 7: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.
>


------------------------------------------------------------------------------
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