UDT for PWMSS-QEP modules, containing the functions to drive the hardware. More...
Public Member Functions | |
QepMod (BYVAL_AS_Pruio__PTR) | |
The constructor for QEP features of the PWMSS. More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | config (BYVAL_AS_UInt8, BYVAL_AS_UInt32, BYVAL_AS_Float_t, BYVAL_AS_Float_t, BYVAL_AS_UInt8) |
Configure header pins and a eQEP module. More... | |
FUNCTION_CDECL_AS_ZSTRING_PTR | Value (BYVAL_AS_UInt8, BYVAL_AS_UInt32_PTR, BYVAL_AS_Float_t_PTR) |
Analyse the QEP input pulse trains, get position and velocity. More... | |
Public Attributes | |
Pruio__PTR | Top |
pointer to the calling PruIo instance | |
Float_t | FVh [PRUIO_AZ_PWMSS+1] |
Factor for high velocity measurement. | |
Float_t | FVl [PRUIO_AZ_PWMSS+1] |
Factor for low velocity measurement. | |
UInt32 | Prd [PRUIO_AZ_PWMSS+1] |
Period value to switch velocity measurement. | |
UDT for PWMSS-QEP modules, containing the functions to drive the hardware.
This structure contains the functions to drive the hardware of the eQEP modul in the PWMSS subsystems.
See ARM Reference Guide, chapter 15.4 for hardware details.
Definition at line 303 of file pruio_pwmss.bi.
QepMod::QepMod | ( | BYVAL_AS_Pruio__PTR | T | ) |
The constructor for QEP features of the PWMSS.
T | A pointer of the calling PruIo structure. |
Each of the three Pulse Width Modulation SubSystems (PWMSS) in the CPU contains modules (PWM, CAP and QEP). In order to create a clear API from the user point of view, the functions to control the modules are separated to extra classes. This UDT contains functions to control the QEP module, which is used to analyse the outputs of quadrature encoder pulse trains.
The constructor just copies a pointer to the calling main UDT PruIo.
Definition at line 846 of file pruio_pwmss.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR QepMod::config | ( | BYVAL_AS_UInt8 | Ball, |
BYVAL_AS_UInt32 | PMax = &h7FFFFFFFul , |
||
BYVAL_AS_Float_t | VHz = 25. , |
||
BYVAL_AS_Float_t | Scale = 1. , |
||
BYVAL_AS_UInt8 | Mo = 0 |
||
) |
Configure header pins and a eQEP module.
Ball | The CPU ball number (either input A, B or I). |
PMax | The maximum position counter value (defaults to &h7FFFFFFF). |
VHz | The frequency to compute velocity values (defaults to 25 Hz). |
Scale | The Scale factor for velocity values (defaults to 1.0). |
Mo | The modus to use for pinmuxing (0 or PRUIO_PIN_RESET). |
This function configures headers pins to be used for quadrature encoder sensors (analysed by the QEP subsystem). By default the module gets configured to work in Quadrature Count Mode, meaning that the Quadrature detector is used to analyse raw input. See subsection QEP for further information and see ARM Reference Guide, chapter 15.4.2.5 for details.
Up to three header pins may get configured, but only one of the pins get specified by parameter Ball
directly. The other pins are configured internally, depending on the type of the specified pin. libpruio selects the matching pins for the subsystem connected to the specified pin (parameter Ball
).
Parameter PMax
is the maximum value for the position counter. On overflow (Pos > PMax
) the counter starts at 0 (zero) again. In case of an underflow (Pos < 0
) the counter continues at PMax. Note that each impulse is counted four times (positive and negative transition, input A and B). Ie. for a rotary encoder with 1024 impulses specify the PMax parameter as 4095 = 1024 * 4 - 1
. The maximum value is &h7FFFFFFF (which is the default). The highest bit is reserved for velocity computation. Higher values can get specified, but will result in inaccurate velocity computation in case of an position counter over- or underflow.
Parameter VHz
is the frequency to update velocity computation. The capture unit of the QEP module is used to generate velocity input and to latch the input values at the given frequency. The minimal frequency is less than 12 Hz and the maximum ferquency is 50 GHz. The higher the frequency, the less is the resolution of the speed measurement. So it's recommended to use the lowest possible frequency. The default value is 25 Hz.
Parameter Scale
is a factor to be applied to the computed velocity value. By default this factor is 1.0 and the velocity gets computed as transitions per second. Ie. to compute the rotational speed in rpm of a sensor with 1024 lines per revolution, set this factor as
Wrapper function (C or Python): pruio_qep_config().
Definition at line 915 of file pruio_pwmss.bas.
FUNCTION_CDECL_AS_ZSTRING_PTR QepMod::Value | ( | BYVAL_AS_UInt8 | Ball, |
BYVAL_AS_UInt32_PTR | Posi = 0 , |
||
BYVAL_AS_Float_t_PTR | Velo = 0 |
||
) |
Analyse the QEP input pulse trains, get position and velocity.
Ball | The CPU ball number (as in QepMod::config() call). |
Posi | A pointer to store the position value (or NULL). |
Velo | A pointer to store the valocity value (or NULL). |
Compute position and speed from the sensor pulse trains. Either a single sensor signal gets evaluated (when an A input is specified as parameter Ball
) to compute Velo information only. Or two sensor signals get evaluated to compute the speed and the position (when a B or C input is specified as parameter Ball
).
The position value is scaled in transitions (since the start or the last index impulse) and counts upwards in case of a single input (A pin passed as parameter Ball
). Otherwise the position gets counted considering the direction. The Velo
value is scaled as transitions per second by default and get customized by parameter Scale
in the previous call to function QepMod::config(). Either of the parameters Posi
or Velo
may be NULL to skip this computation.
In order to speed up execution this function doesn't check the configuration of all input pins, meaning it computes (erratic) output even if some (or all) of the pins are not in the matching configuration.
Wrapper function (C or Python): pruio_qep_Value().
Definition at line 1041 of file pruio_pwmss.bas.