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 thatmake-pulsescan actually use. changes take effect only whenupdate-speedruns. it can (and should) be called less frequently thanmake-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-Abit out โ one of the quadrature outputs. the first one. the A one. ๐ธsim-encoder.N.phase-Bbit out โ the other quadrature output. hi B, we love you too. ๐sim-encoder.N.phase-Zbit out โ the index pulse. โจsim-encoder.N.speedfloat in โ the desired speed of the encoder, in user units per per second. (yes, that's literally what it says.) this gets divided byscale, and the result is used as the encoder speed in revolutions per second. ๐
๐ PARAMETERS ๐
sim-encoder.N.ppru32 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.scalefloat rw โ the scale factor for the speed input. the speed value gets divided byscaleto get the actual encoder speed in revolutions per second. for example, ifscaleis 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. ๐
๐ฆ 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