ENCODER_RATIO(9)
π ENCODER_RATIO(9) π
ok bestie, this is a HAL Component page, and we're about to get so synchronized. no cap. π
β¨ NAME β¨
encoder_ratio β it's literally an electronic gear that syncs up two axes. that's the whole vibe. π¦
πΈ SYNOPSIS πΈ
loadrt encoder_ratio [num_chan=num | names=name1[,name2...]]
π DESCRIPTION π
okay so picture this: encoder_ratio is your go-to when you need to synchronize two axes, like an "electronic gear" (iconic concept, iykyk). what it does is count encoder pulses from both axes, in software, and then it spits out an error value. that error value is the moment β you feed it to a PID loop and the slave encoder starts tracking the master encoder at a specific ratio. obsessed. π
this module supports up to eight axis pairs, fr fr. you set how many pairs you want with the module parameter num_chan. or, alternatively, you can use names= and pass unique names separated by commas. slay.
π«Ά heads up bestie:num_chan=andnames=are mutually exclusive. you cannot have both, that's the rule. and if you specify neithernum_chan=nornames=, the default value is one. one singular pair, main character energy. π
β FUNCTIONS β
encoder-ratio.sampleβ reads all the input pins. it must be called at twice the maximum desired count rate. don't skimp on this, it's giving important.encoder-ratio.update(uses floating-point) β updates all the output pins. this one may be called from a slower thread, so it's lowkey flexible. π
π NAMING π
the names for pins and parameters get prefixed like this:
encoder-ratio.N.forN=0,1,...,num-1when you usenum_chan=numnameN.fornameN=name1,name2,...when you usenames=name1,name2,...
and the encoder-ratio.N. format is what's shown in all the descriptions below, just so we're on the same page. π
π¦ PINS π¦
encoder-ratio.N.master-Abit inencoder-ratio.N.master-Bbit inencoder-ratio.N.slave-Abit inencoder-ratio.N.slave-Bbit in
these are the encoder channels of the master and slave axes. the whole squad. π§
encoder-ratio.N.enablebit in
okay this one is the drama of the whole page, listen up. when the enable pin is FALSE, the error pin just reports the slave axis position, in revolutions. simple, chill. so normally you'd connect it to the feedback pin of a PID block for closed loop control of the slave axis. and normally the command input of that PID block is left unconnected (zero), which means the slave axis literally just sits still. π however β plot twist β 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. so as the master moves, error becomes non-zero, and the PID loop drives the slave axis to track the master. it's giving choreography. π₯
encoder-ratio.N.errorfloat out
the error in the position of the slave (in revolutions). periodt. β¨
π PARAMETERS π
encoder-ratio.N.master-pprunsigned rwencoder-ratio.N.slave-pprunsigned rw
the number of pulses per revolution of the master and slave axes. π
encoder-ratio.N.master-teethunsigned rwencoder-ratio.N.slave-teethunsigned rw
the number of "teeth" on the master and slave gears. yes, teeth, we love a mechanical metaphor. π¦·β¨
π SEE ALSO π
and that's the whole page, bestie!! π this one came from the LinuxCNC Documentation, dated 2007-01-16, and it's the ENCODER_RATIO(9) manual page. go forth and synchronize those axes, you absolute icon. ππ
π«Ά
π¦ where this page comes from
- debian bookworm: linuxcnc-uspace 2.9.0~pre1+git20230208.f1270d6ed7-1+deb12u2 Β· GFDL-1.1-or-later
- debian trixie: linuxcnc-uspace 1:2.9.4-2+deb13u1 Β· GFDL-1.1-or-later
- ubuntu questing: linuxcnc-uspace 1:2.9.4-2ubuntu2
- ubuntu resolute: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- ubuntu stonking: linuxcnc-uspace 1:2.9.4-2ubuntu4 Β· GFDL-1.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms