logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

encoder_ratio - an electronic gear to synchronize two axes

Description

encoder_ratio  can be used to synchronize two axes (like an "electronic gear").  It counts encoder pulses
       from both axes in software, and produces an error value that can be used with a  PID  loop  to  make  the
       slave encoder track the master encoder with a specific ratio.

       This  module  supports  up  to  eight  axis  pairs.   The  number of pairs is set by the module parameter
       num_chan.  Alternatively, specify names= and unique names separated by commas.

       The num_chan= and names= specifiers  are  mutually  exclusive.   If  neither  num_chan=  nor  names=  are
       specified, the default value is one.

Functions

encoder-ratio.sample
              Read all input pins.  Must be called at twice the maximum desired count rate.

       encoder-ratio.update(usesfloating-point)
              Updates all output pins.  May be called from a slower thread.

Name

       encoder_ratio - an electronic gear to synchronize two axes

Naming

       The names for pins and parameters are prefixed as:
         encoder-ratio.N. for N=0,1,...,num-1 when using num_chan=numnameN. for nameN=name1,name2,... when using names=name1,name2,...

       The encoder-ratio.N. format is shown in the following descriptions.

Parameters

encoder-ratio.N.master-ppr unsigned rw
       encoder-ratio.N.slave-ppr unsigned rw
              The number of pulses per revolution of the master and slave axes

       encoder-ratio.N.master-teeth unsigned rw
       encoder-ratio.N.slave-teeth unsigned rw
              The number of "teeth" on the master and slave gears.

Pins

encoder-ratio.N.master-A bit in
       encoder-ratio.N.master-B bit in
       encoder-ratio.N.slave-A bit in
       encoder-ratio.N.slave-B bit in
              The encoder channels of the master and slave axes

       encoder-ratio.N.enable bit in
              When  the  enable  pin  is  FALSE,  the  error  pin  simply  reports  the  slave axis position, in
              revolutions.  As such, it would normally be connected to the feedback  pin  of  a  PID  block  for
              closed  loop  control  of  the  slave  axis.   Normally the command input of the PID block is left
              unconnected (zero), so the slave axis simply sits still.  However when the enable input goes TRUE,
              the error pin becomes the slave position minus the scaled master position.  The  scale  factor  is
              the  ratio  of  master teeth to slave teeth.  As the master moves, error becomes non-zero, and the
              PID loop will drive the slave axis to track the master.

       encoder-ratio.N.error float out
              The error in the position of the slave (in revolutions)

See Also

encoder(9)

LinuxCNC Documentation                             2007-01-16                                   ENCODER_RATIO(9)

Synopsis

loadrtencoder_ratio[num_chan=num|names=name1[,name2...]]

See Also