Robot Control Library
encoder_eqep.h
Go to the documentation of this file.
1/**
2 * <rc/encoder_eqep.h>
3 *
4 * @brief C interface for the Sitara eQEP encoder counter.
5 *
6 * Functions for reading the eQEP hardware-accelerated quadrature encoder
7 * counters. This can be used for reading encoder channels 1-3 on the Robotics
8 * Cape and BeagleBone Blue. Channel 4 is counted with the PRU, see
9 * <rc/encoder_pru.h> to use the 4th channel.
10 *
11 *
12 * @author James Strawson
13 * @date 1/31/2018
14 *
15 * @addtogroup Encoder_EQEP
16 * @ingroup Quadrature_Encoder
17 * @{
18 */
19
20#ifndef RC_ENCODER_EQEP_H
21#define RC_ENCODER_EQEP_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27
28/**
29 * @brief Initializes the eQEP encoder counters for channels 1-3
30 *
31 * This also resets the encoder position to 0 so the first position read is
32 * consistent. Note this does NOT initialize the PRU-accelerated encoder counter
33 * on channel 4. To use the 4th channel you must use <rc/encoder_pru.h>
34 *
35 * @return 0 on success or -1 on failure
36 */
38
39/**
40 * @brief Stops the eQEP encoder counters and closes file descriptors. This
41 * is not strictly necessary but is recommended that the user calls this
42 * function at the end of their program.
43 *
44 * @return 0 on success or -1 on failure.
45 */
47
48/**
49 * @brief Reads the current position of an encoder channel.
50 *
51 * This is a signed 32-bit integer that wraps around if the position is allowed
52 * to read +- 2^31
53 *
54 * @param[in] ch channel 1-3
55 *
56 * @return The current position (signed 32-bit integer) or -1 and prints an
57 * error message is there is a problem.
58 */
60
61/**
62 * @brief Sets the current position of an eQEP encoder channel. Usually for
63 * resetting a counter to 0 but can set an arbitrary position if desired.
64 *
65 * @param[in] ch channel 1-3
66 * @param[in] pos The new position
67 *
68 * @return 0 on success, -1 on failure
69 */
70int rc_encoder_eqep_write(int ch, int pos);
71
72
73#ifdef __cplusplus
74}
75#endif
76
77#endif // RC_ENCODER_EQEP_H
78
79/** @} end group Encoder_EQEP*/
int rc_encoder_eqep_init(void)
Initializes the eQEP encoder counters for channels 1-3.
int rc_encoder_eqep_read(int ch)
Reads the current position of an encoder channel.
int rc_encoder_eqep_cleanup(void)
Stops the eQEP encoder counters and closes file descriptors. This is not strictly necessary but is re...
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 se...