SYNOPSIS
loadrt encoder [ num_chan=num | names=name1[,name2…] ]
DESCRIPTION
encoder is used to measure position by counting the pulses generated by a quadrature encoder. As a software-based implementation it is much less expensive than hardware, but has a limited maximum count rate. The limit is in the range of 10 kHz to 50 kHz, depending on the computer speed and other factors. If better performance is needed, a hardware encoder counter is a better choice. Some hardware-based systems can count at MHz rates.
encoder supports a maximum of eight channels. The number of channels actually loaded is set by the num_chan argument when the module is loaded. 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, or if num_chan=0 is specified, the default value is three.
encoder has a one-phase, unidirectional mode called counter. In this mode, the phase-B input is ignored; the counts increase on each rising edge of phase-A. This mode may be useful for counting a unidirectional spindle with a single input line, though the noise-resistant characteristics of quadrature are lost.
If used in counter-mode it is also possible to enable the missing-teeth index mode, where a gap in the pulse train of one or more teeth is used as in index marker. This system is used extensively for automotive crank position sensors.
Funciones
- encoder.update-counters (sin punto flotante)
-
Does the actual counting, by sampling the encoder signals and decoding the quadrature waveforms. Must be called as frequently as possible, preferably twice as fast as the maximum desired count rate. Operates on all channels at once.
- encoder.capture-position (usa punto flotante)
-
Captures the raw counts from update-counters and performs scaling and other necessary conversion, handles counter rollover, etc. Can (and should) be called less frequently than update-counters. Operates on all channels at once.
NAMING
The names for pins and parameters are prefixed as: encoder.N. for N=0,1,…,num-1 when using num_chan=num nameN. for nameN=name1,name2,… when using names=name1,name2,…
El formato codificador.N. se muestra en las descripciones siguientes.
PINS
- encoder.N.counter-mode bool i/o
-
Habilita el modo contador. Cuando es Verdadero, el contador cuenta cada flanco ascendente de la entrada de la fase A, ignorando el valor en la fase B. Esto es útil para contar la salida de un solo canal del sensor (sin cuadratura). Cuando es Falso, cuenta en modo cuadratura.
- encoder.N.counts sint out
-
Posición en conteo de codificador.
- encoder.N.index-enable bool i/o
-
When true, counts and position are reset to zero on the next rising edge of Phase-Z. At the same time, index-enable is reset to zero to indicate that the rising edge has occurred.
- encoder.N.min-speed-estimate real in (default: 1.0)
-
Determine the minimum speed at which velocity will be estimated as nonzero and postition-interpolated will be interpolated. The units of min-speed-estimate are the same as the units of velocity. Setting this parameter too low will cause it to take a long time for velocity to go to 0 after encoder pulses have stopped arriving.
- encoder.N.phase-A bool in
-
Quadrature input for encoder channel N.
- encoder.N.phase-B bool in
-
Quadrature input.
- encoder.N.phase-Z bool in
-
Index pulse input.
- encoder.N.position real out
-
Posición en unidades escaladas (ver position-scale)
- encoder.N.position-interpolated real out
-
Position in scaled units, interpolated between encoder counts. Only valid when velocity is approximately constant and above min-speed-estimate. Do not use for position control.
- encoder.N.position-scale real i/o
-
Scale factor, in counts per length unit. For example, if position-scale is 500, then 1000 counts of the encoder will be reported as a position of 2.0 units.
- encoder.N.missing-teeth sint in
-
The number of teeth missing from the index gap. For example a 60 tooth gear with two teeth shortened to form an index so that there are 58 pulses per revolution would use a position-scale of 60 and a missing-teeth of 2.
- encoder.N.rawcounts sint out
-
The raw count, as determined by update-counters. This value is updated more frequently than counts and position. It is also unaffected by reset or the index pulse.
- encoder.N.reset bool in
-
Cuando es Verdadero, fuerza counts y position a cero de inmediato.
- encoder.N.velocity real out
-
Velocidad en unidades escaladas por segundo. codificador utiliza un algoritmo que reduce en gran medida la cuantificación de ruido comparado con una simple diferenciación de la salida de posición. Cuando la magnitud de la verdadera velocidad está por debajo de la estimación de velocidad mínima, la salida de velocidad es 0.
- encoder.N.velocity-rpm real out
-
Velocity in scaled units per minute. Simply encoder.N.velocity scaled by a factor of 60 for convenience.
- encoder.N.x4-mode bool i/o
-
Habilita el modo 4x. Cuando es verdadero (el predeterminado), el contador cuenta cada borde de la forma de onda en cuadratura (cuatro cuentas por ciclo completo). Cuando es falso, solo cuenta una vez por ciclo completo. En counter-mode este parámetro es ignorado.
- encoder.N.latch-input bool in
-
+
- encoder.N.latch-falling bool in (default: TRUE)
-
+
- encoder.N.latch-rising bool in (default: TRUE)
-
+
- encoder.N.counts-latched sint out
-
+
- encoder.N.position-latched real out
-
Update counts-latched and position-latched on the rising and/or falling edges of latch-input as indicated by latch-rising and latch-falling.
- encoder.N.counter-mode bool rw
-
Habilita el modo contador. Cuando es Verdadero, el contador cuenta cada flanco ascendente de la entrada de la fase A, ignorando el valor en la fase B. Esto es útil para contar la salida de un solo canal del sensor (sin cuadratura). Cuando es Falso, cuenta en modo cuadratura.
- encoder.N.capture-position.tmax sint rw
-
Maximum time in ns it took to execute this function.
PARAMETERS
The encoder component has no HAL Parameters.