nrf5340dk build error with CONFIG_QDEC_NRFX and CONFIG_SENSOR enabled

Hello,

I am using an nrf5340dk and I am trying to create a qdec sample using as reference the wheel module.

I have added set the CONFIG_SENSOR and CONFIG_QDEC_NRFX to y and also added an .overlay file in /boards directory of my project folder (following the instructions here https://docs.zephyrproject.org/latest/build/dts/howtos.html#set-devicetree-overlays

The overlay file includes the following:

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

However when I build the project using the SES, I get the following error:

'DT_N_S_soc_S_peripheral_50000000_S_qdec_33000_P_steps' undeclared (first use in this function); did you mean 'DT_N_S_soc_S_peripheral_50000000_S_qdec_33000_P_status'?

It looks like I am doing something wrong with the device tree configuration.

Parents Reply Children
  • Hi again,

    Yes, unfortunately qdec1 is not currently supported by the nrfx_qdec driver, but support will be a part of a future release.

  • Hello Oivind,

    thank you for the update. Is there any suggested way for reading the 2nd encoder until the qdec1 is released ? Should I use the gpio driver ? Is there any sample code doing something like this ?

  • Hi again,

    Unfortunately I do not have any sample code for this to give you.

    My best bet to make this work before the next release, would require you to look at how the nrfx driver sets up QDEC0 and try to replicate that for QDEC1 in some way. If it even is possible, this would be very difficult to do properly, and you would mostly be on your own if you go this route.

  • Hello Oivind,

    I will wait for the release of the QDEC1 before moving on with this then.

    In the meantime, I tested QDEC0 using a DC motor with a built-in encoder.

    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 get an instant counter measurement of -1 step. However the motor is 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.

    Last, I was checking about qdec malfunctioning in the nordic dev zone and found out this:

    Does this mean that there is some issue with the qdec0 ?

    One last question:

    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) ?

  • Hi,

    The "QDEC0 is not functional" issue was present on one of the early engineering samples of the chip and is not present on the release revision. You can see that the issue is under "Engineering A Errata" in the sidebar. If your DK is revision 0.11.0 or higher, it does not apply to your chip.

    It would be best to make a new ticket for the rest of these questions, as we try to keep tickets to a single issue.

Related