libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
QepMod Class Reference

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.
 

Detailed Description

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.

Since
0.4

Definition at line 303 of file pruio_pwmss.bi.

Constructor & Destructor Documentation

◆ QepMod()

QepMod::QepMod ( BYVAL_AS_Pruio__PTR  T)

The constructor for QEP features of the PWMSS.

Parameters
TA 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.

Since
0.4.0

Definition at line 846 of file pruio_pwmss.bas.

Here is the caller graph for this function:

Member Function Documentation

◆ config()

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.

Parameters
BallThe CPU ball number (either input A, B or I).
PMaxThe maximum position counter value (defaults to &h7FFFFFFF).
VHzThe frequency to compute velocity values (defaults to 25 Hz).
ScaleThe Scale factor for velocity values (defaults to 1.0).
MoThe modus to use for pinmuxing (0 or PRUIO_PIN_RESET).
Returns
Zero on success (otherwise a string with an error message).

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).

  • When an A input pin is specified, the QEP system runs in frequency count mode. No position is available (always counts upwards) and the velocity is always positive (no direction gets detected).
  • When an B input pin is specified, the QEP system runs in position / velocity mode, but no reference position (index) is detected.
  • When an Index input pin is specified, the QEP system runs in position / velocity mode, and the reference index position is used to reset the position counter.

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

Scale = 60 [s/min] / (1024 [imp/rev] * 4 [cnt/imp])

Wrapper function (C or Python): pruio_qep_config().

Since
0.4.0

Definition at line 915 of file pruio_pwmss.bas.

Here is the caller graph for this function:

◆ Value()

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.

Parameters
BallThe CPU ball number (as in QepMod::config() call).
PosiA pointer to store the position value (or NULL).
VeloA pointer to store the valocity value (or NULL).
Returns
Zero on success (otherwise a string with an error message).

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().

Since
0.4.0

Definition at line 1041 of file pruio_pwmss.bas.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: