SIM_ENCODER(9)

๐Ÿ’– SIM_ENCODER(9) ๐Ÿ’–

okay so this is a HAL Component page, bestie โ€” manual section 9, the whole SIM_ENCODER(9) situation. pull up a chair, we're learning about a fake encoder that's genuinely so useful. ๐ŸŽ€


โœจ NAME โœจ

sim_encoder โ€” a simulated quadrature encoder, babes. yes, we're pretending. it slays. ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

loadrt sim_encoder [num_chan=num | names=name1[,name2...]]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

sim_encoder can generate quadrature signals as if they were coming from a real encoder. iconic behaviour, honestly. it also generates an index pulse once per revolution. ๐Ÿ‘‘

it's mostly used for testing and simulation, like when you need to replace hardware that maybe isn't available to you. so it's giving "stand-in bestie energy." it does have a limited maximum frequency though โ€” and so does every other software-based pulse generator, no cap, that's just how it is. ๐Ÿ˜ญ

sim_encoder supports a maximum of eight channels. the number of channels that actually get loaded is set by the num_chan= argument when you load the module. alternatively, you can specify names= with unique names separated by commas. โœจ

the num_chan= and names= specifiers are mutually exclusive โ€” pick one, bestie, you can't have both. ๐Ÿ™ˆ and if you specify neither num_chan= nor names=, the default value is one.


๐Ÿ”ฅ FUNCTIONS ๐Ÿ”ฅ

  • sim-encoder.make-pulses (no floating-point) โ€” this one generates the actual quadrature and index pulses. it must be called as frequently as possible, to maximize the count rate and minimize jitter. it operates on all channels at once. highkey the main character here. ๐Ÿ’–
  • sim-encoder.update-speed (uses floating-point) โ€” reads the speed command and other parameters, then converts the data into a form that make-pulses can actually use. changes take effect only when update-speed runs. it can (and should) be called less frequently than make-pulses. also operates on all channels at once. ๐Ÿซถ

๐Ÿ‘‘ NAMING ๐Ÿ‘‘

the names for pins and parameters are prefixed like this:

sim-encoder.N.   for N=0,1,...,num-1 when using num_chan=num
nameN.           for nameN=name1,name2,... when using names=name1,name2,...

the sim-encoder.N. format is what's shown in all the descriptions below. iykyk. ๐Ÿ’…


๐ŸŽ€ PINS ๐ŸŽ€

  • sim-encoder.N.phase-A bit out โ€” one of the quadrature outputs. the first one. the A one. ๐ŸŒธ
  • sim-encoder.N.phase-B bit out โ€” the other quadrature output. hi B, we love you too. ๐Ÿ’œ
  • sim-encoder.N.phase-Z bit out โ€” the index pulse. โœจ
  • sim-encoder.N.speed float in โ€” the desired speed of the encoder, in user units per per second. (yes, that's literally what it says.) this gets divided by scale, and the result is used as the encoder speed in revolutions per second. ๐ŸŒˆ

๐Ÿ’– PARAMETERS ๐Ÿ’–

  • sim-encoder.N.ppr u32 rw โ€” the pulses per revolution of the simulated encoder. note that this is pulses, not counts, per revolution (ppr). each pulse or cycle from the encoder results in four counts, because every edge gets counted. default value is 100 ppr, which is 400 counts per revolution. math is math. ๐Ÿงฎ๐Ÿ’…
  • sim-encoder.N.scale float rw โ€” the scale factor for the speed input. the speed value gets divided by scale to get the actual encoder speed in revolutions per second. for example, if scale is set to 60, then speed is in revolutions per minute (RPM) instead of revolutions per second. the default value is 1.00. ๐Ÿ”ฅ

and that's the whole page, bestie โ€” go forth and simulate some encoders, you've got this. ๐Ÿฆ‹โœจ

this lil masterpiece is brought to you by the LinuxCNC Documentation crew, dated 2007-01-16, and it lives in the SIM_ENCODER(9) section. mwah. ๐Ÿ’‹