Open alzzxx opened 3 years ago
Hi @alzzxx ,
the quadrature module is not enabled by default in the mbed build, hence the compile time error.
The best thing you can do is retrieving nrfx_qdec.c
from https://github.com/arduino/mbed-os, remove the #ifdef
lines and add it to your sketch.
I prepared a zip file with everything in it; it compiles fine but I didn't test if it works correctly :slightly_smiling_face:
Try giving it a spin and if you could, please report back since a lot of people might be interested in using that IP :wink:
Gee, thanks, I'll give it a try, and sure i'll report back the result! Thanks again!
Hi,
Is anyone able to get this to work? I would very much like to be able to use the built in quadrature decoder.
@facchinm,
I tried your attached file, it compiles but when uploaded the Nano 33BLE freezes. I am a novice at this, so any help would be greatly appreciated! :)
Subject of the issue
I'd like to gain access to the hardware decoder inside the nrF528x, right now I'm reading a quadrature encoder using interrupts on pins 4 (for channel A) and 6 (for channel B), using the InterruptIn mbed instructions, starting from a mbed library found on mbed site, and adapting it to work under arduino core, basically by adding mbed:: before mbed instructions and some callbacks.
The code works great for frequencies under 7 kHz, pulse count is correct and also frequency and speed calculations, but when i increase the motor speed i start to lose pulses and the count (and also frequency and speed calculation) goes wrong. So I wanted to see if the problem was the interrupt frequency, maybe is too slow for that motor speed, and I thought that using the hardware decoder was a good option because in theory it gives me the pulse count without any software calculation on the main loop so it should be the fastest option. I started from the example on the nordic SDK 15.0 for the QDEC and a wrote a little sketch to see if I was able to compile it:
But the problem as commented on arduino/ArduinoCore-nRF528x-mbedos#58, I get the compiler error:
and as stated on arduino/ArduinoCore-nRF528x-mbedos#58, the src files for
nrfx_qdec.h
are missing, I tried copying the files from nordic SDK 15 directly on the sketch folder as suggested by @facchinm but that didn't work either, I took a look at arduino/ArduinoCore-nRF528x-mbedos#72 and what @Polldo said here https://github.com/arduino/ArduinoCore-nRF528x-mbedos/issues/58#issuecomment-625179806, but I think I'm using the right file#include <nrfx_qdec.h>
So, if there is something I could try to solve this problem? There are some mbed API's to read the decoder directly??
Thanks for all the help you could provide guys!!
My workbench
Expected behavior
Well I'd like to use the hardware decoder inside the arduino nano 33 BLE
Actual behavior
The code doesn't compile because it can find the source files for nrfx_qdec.h