nrf5340 - qdec sample reporting wrong rotations

Hello,

I tested QDEC0 using the zephyr qdec sample (which uses the nrfx_qdec driver) and a DC motor with a built-in encoder.

Below you will see the overlay file configuration for the QDEC0:

&qdec0 {
status = "okay";
a-pin = <3>;
b-pin = <28>;
enable-pin = <30>;
led-pin = <0xFFFFFFFF>;
led-pre = <0>;
steps = <24>;
};

I connected the pinA of the encoder to P0.03 and pinB of the encoder to P0.28 as per the board configuration.

However, it looks like for almost every positive rotation of 1 step (360/24steps = 15) I got an instant counter measurement of -1 step. The motor was steadily rotating one side.

Before digging deeper and seeing what is actually the output of the encoder (I will need an oscilloscope for this), I was thinking if I can read something to better understand how is the sensor value calculated in case the channel is SENSOR_CHAN_ROTATION. I know this is mainly zephyr stuff but any input is welcome. The only thing I was able to determine is that if the channel is SENSOR_CHAN_ROTATION the qdec_nrfx_sample_fetch function calls the nrfx_qdec_accumulators_read function and then accumulates the cumulative number of steps. 

Moreover, I noticed that I got only single step rotations (15degrees-1step). In case I was polling the channel slower and I was not facing this issue with 1 step clockwise and 1 step counter-clockwise rotations, Should I be able to get multi-step rotation responses (Nx360/number_of_steps) taking into consideration how the nrfx_qdec driver is working (accumulating the valid rotations and resetting upon read request) ?

Parents Reply Children
No Data
Related