Hi,
I am using mechanical QDEC which doesn't have LED and simply A and B pins. After going through forum I set the QDEC confguration as follows.
nrf_drv_qdec_config_t qdec_config =
{
.reportper = NRF_QDEC_REPORTPER_40, /**< Report period in samples. */
.sampleper = NRF_QDEC_SAMPLEPER_8192us, /**< Sampling period in microseconds. */
.psela = ENC_2_A, /**< Pin number for A input. */
.pselb = ENC_2_B, /**< Pin number for B input. */
.pselled = 0xFFFFFFFF, /**< Pin number for LED output. */
.ledpre = 10, /**< Time (in microseconds) how long LED is switched on before sampling. */
.ledpol = NRF_QDEC_LEPOL_ACTIVE_LOW, /**< Active LED polarity. */
.dbfen = true, /**< State of debouncing filter. */
.sample_inten = true, /**< Enabling sample ready interrupt. */
.interrupt_priority = 3, /**< QDEC interrupt priority. */
};
Then changed function in nrfx_qdec.c
nrfx_err_t nrfx_qdec_init(nrfx_qdec_config_t const * p_config,
nrfx_qdec_event_handler_t event_handler)
{
...
...
...
nrf_qdec_sampleper_set(p_config->sampleper);
// nrf_gpio_cfg_input(p_config->pselled, NRF_GPIO_PIN_NOPULL);
// nrf_gpio_cfg_input(p_config->psela, NRF_GPIO_PIN_NOPULL);
// nrf_gpio_cfg_input(p_config->pselb, NRF_GPIO_PIN_NOPULL);
nrf_qdec_pio_assign(p_config->psela, p_config->pselb, p_config->pselled);
...
...
...
}
Now I am getting values only if encoder is moving very slow and not at normal operation. At normal operation I get m_accread = 1 & m_accdblread = 0 which is incorrect.
Also I get negative value for forward movement and positive for reverse. I have attached proper connections at A and B and also defined them correctly.
Normal operation frequency would be around 2560Hz.
What could possibly go wrong or how to resolve this issue?
SDK 15.2
Regards