Robot Control Library
Encoder_EQEP

Description

C interface for the Sitara eQEP encoder counter.

<rc/encoder_eqep.h>

Functions for reading the eQEP hardware-accelerated quadrature encoder counters. This can be used for reading encoder channels 1-3 on the Robotics Cape and BeagleBone Blue. Channel 4 is counted with the PRU, see <rc/encoder_pru.h> to use the 4th channel.

Author
James Strawson
Date
1/31/2018

Functions

int rc_encoder_eqep_init (void)
 Initializes the eQEP encoder counters for channels 1-3. More...
 
int rc_encoder_eqep_cleanup (void)
 Stops the eQEP encoder counters and closes file descriptors. This is not strictly necessary but is recommended that the user calls this function at the end of their program. More...
 
int rc_encoder_eqep_read (int ch)
 Reads the current position of an encoder channel. More...
 
int rc_encoder_eqep_write (int ch, int pos)
 Sets the current position of an eQEP encoder channel. Usually for resetting a counter to 0 but can set an arbitrary position if desired. More...
 

Function Documentation

◆ rc_encoder_eqep_init()

int rc_encoder_eqep_init ( void  )

Initializes the eQEP encoder counters for channels 1-3.

This also resets the encoder position to 0 so the first position read is consistent. Note this does NOT initialize the PRU-accelerated encoder counter on channel 4. To use the 4th channel you must use <rc/encoder_pru.h>

Returns
0 on success or -1 on failure
Examples:
rc_balance.c, and rc_test_encoders_eqep.c.

◆ rc_encoder_eqep_cleanup()

int rc_encoder_eqep_cleanup ( void  )

Stops the eQEP encoder counters and closes file descriptors. This is not strictly necessary but is recommended that the user calls this function at the end of their program.

Returns
0 on success or -1 on failure.
Examples:
rc_balance.c, and rc_test_encoders_eqep.c.

◆ rc_encoder_eqep_read()

int rc_encoder_eqep_read ( int  ch)

Reads the current position of an encoder channel.

This is a signed 32-bit integer that wraps around if the position is allowed to read +- 2^31

Parameters
[in]chchannel 1-3
Returns
The current position (signed 32-bit integer) or -1 and prints an error message is there is a problem.
Examples:
rc_balance.c, and rc_test_encoders_eqep.c.

◆ rc_encoder_eqep_write()

int rc_encoder_eqep_write ( int  ch,
int  pos 
)

Sets the current position of an eQEP encoder channel. Usually for resetting a counter to 0 but can set an arbitrary position if desired.

Parameters
[in]chchannel 1-3
[in]posThe new position
Returns
0 on success, -1 on failure
Examples:
rc_balance.c.