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

UDT for PWMSS-CAP modules, containing the functions to drive the hardware. More...

Public Member Functions

 CapMod (BYVAL_AS_Pruio__PTR)
 Curr = DRam[2]. More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR config (BYVAL_AS_UInt8, BYVAL_AS_Float_t)
 Configure a header pin as eCAP input. More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR Value (BYVAL_AS_UInt8, BYVAL_AS_Float_t_PTR, BYVAL_AS_Float_t_PTR)
 Analyse a digital pulse train, get frequency and duty cycle. More...
 

Public Attributes

Pruio__PTR Top
 pointer to the calling PruIo instance
 

Detailed Description

UDT for PWMSS-CAP modules, containing the functions to drive the hardware.

This structure contains the functions to drive the hardware of the eCAP modul in the PWMSS subsystems in input mode.

See ARM Reference Guide, chapter 15.3 for hardware details.

Since
0.2

Definition at line 276 of file pruio_pwmss.bi.

Constructor & Destructor Documentation

◆ CapMod()

CapMod::CapMod ( BYVAL_AS_Pruio__PTR  T)

Curr = DRam[2].

The constructor for the CAP feature 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 CAP module, which is used to analyse the frequency and duty cycle of a digital pulse train.

The constructor just copies a pointer to the calling main UDT PruIo.

Since
0.2

Definition at line 690 of file pruio_pwmss.bas.

Here is the caller graph for this function:

Member Function Documentation

◆ config()

FUNCTION_CDECL_AS_ZSTRING_PTR CapMod::config ( BYVAL_AS_UInt8  Ball,
BYVAL_AS_Float_t  FLow = 0. 
)

Configure a header pin as eCAP input.

Parameters
BallThe CPU ball number to configure.
FLowMinimal frequency to measure in Hz (> .0232831).
Returns
Zero on success (otherwise a string with an error message).

This function configures a header pin for Capture and Analyse Pulse (CAP) trains. The pins configuration gets checked. If it's not configured as input for the CAP module in the PWMSS subsystem, libpruio tries to adapt the pinmuxing. This fails if the program isn't executed with admin privileges.

Currently CAP is available on pins P9_42, P9_28 and SD_10.

The parameter FLow specifies the minimal frequency to measure in Hz. When not set (values < .0232831) and the input doesn't change, the counter runs until an overflow before it returns the new values (in this case frequency = 0 and duty cycle = 0). This lasts about 43 seconds before the new values are available. To shorten this time, you can specify the lowest frequency. When a period without change is over, the counter gets restarted.

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

Since
0.2

Definition at line 720 of file pruio_pwmss.bas.

Here is the caller graph for this function:

◆ Value()

FUNCTION_CDECL_AS_ZSTRING_PTR CapMod::Value ( BYVAL_AS_UInt8  Ball,
BYVAL_AS_Float_t_PTR  Hz = 0,
BYVAL_AS_Float_t_PTR  Du = 0 
)

Analyse a digital pulse train, get frequency and duty cycle.

Parameters
BallThe CPU ball number to test.
HzA pointer to store the frequency value (or null).
DuA pointer to store the duty cycle value (or null).
Returns
Zero on success (otherwise a string with an error message).

This function returns the frequency and duty cycle of a digital pulse train on a header pin. The header pin needs to get configured first by a call to function CapMod::config().

The parameters Hz and Du contain the results of the last measured period. You can pass a zero pointer to either of them if you don't need this value.

A period is limited by the counter resolution. The minimal frequency is 0.0232831 Hz, so a period lasts maximal 43 seconds. When the state of the input pin doesn't change twice during a period, the counter restarts and zero gets returned for both results (Hz and Du). The minimal frequency can get adapted by parameter FLow in the previous call to function CapMod::config().

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

Since
0.2

Definition at line 788 of file pruio_pwmss.bas.

Here is the caller graph for this function:

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