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= and names= are mutually exclusive. you cannot have both, that's the rule. and if you specify neither num_chan= nor names=, 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. for N=0,1,...,num-1 when you use num_chan=num
  • nameN. for nameN=name1,name2,... when you use names=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-A bit in
  • encoder-ratio.N.master-B bit in
  • encoder-ratio.N.slave-A bit in
  • encoder-ratio.N.slave-B bit in

these are the encoder channels of the master and slave axes. the whole squad. 🧚

  • encoder-ratio.N.enable bit 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.error float out

the error in the position of the slave (in revolutions). periodt. ✨


πŸ’œ 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. yes, teeth, we love a mechanical metaphor. 🦷✨


🌟 SEE ALSO 🌟

encoder(9)


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. πŸŽ€πŸ’…πŸ«Ά