QDEC on the nRF52840

using nRF5 SDK 17.1.0

Segger

I need some understanding of the QDEC.  if I connect a motor that has a A/B output at a 5KHZ rate.

what is the maximum rate at which the decoder can run?

what do i need to set the SAMPLEPER register to?  is 128uS preferred for faster decoder inputs?

I am looking to know position.  SO if I set the SAMPLEPER to a fast enough speed, what should i set the REPORTPER to?

is this expected to be larger for a longer sample period before events?

when i have the QDEC_EVENT_HANDLER() and do a event.data.report.acc

does this clear the accumulator?  or do i need to manually do this?

if manually do i set a task to RDCLRACC before i read the ACC in the event?

if so, how?

If I am not using the LED, do i just simply set ledpre =0 and there is no other setting needed?

thanks for you support

  • Thanks for your feedback.  I have not had any QDEC questions and i am just trying to understand the function of the QDEC.  I keep asking for more understanding because the customer is only able to achieve 1/4 the expected rate.  They can only spin the motor at 100 RPM.  SO at 600 Pulses per revolution they are only seeing 1KHZ pulse frequency.  when the above calculation expects to be able to see the 4.5Khz their motor can produce.  We are just trying to figure out why

  • one more thing;

    I ran the example that was posted by ovrebekk (case 273524) and am not certain of the functionality and this is adding to my confusion. if I use his example as delivered.  it sets the pulses to 200Hz (period of the signals is 50Hz) and the REPORTPER to 240.  Since this is simulating a constant revolution of the motor( Not backward) i would think i would get 240 from ACCREAD in the terminal window.  I thought each transition should generate a SAMPLE and add to the ACC. this would then create a REPORTRDY after there are 240 SAMPLES.

    but i am getting 49 SAMPLES.  what am i missing?.  If i push this to any number above 1000 and change the SAMPLEPER to 128uS.  I need to add the DBFEN and i only get 30 SAMPLES from a REPORTRDY event and ACCREAD.  Clearly i am missing something 

  • Hi Wes,

    I see the same results when I test Torbjørn's example (though I don't have to enable denouncing when using 1000 Hz input and 128 us sampling period).

    The numbers makes sense, though. With 1024 us SAMPLEPER and 240 REPORTPER you will get a report every 1024 us * 240 samples / report = 246 ms. And with a 200 Hz input that will give you 200 Hz * 246 ms = 49 samples per report. The same reasoning explains why you get 30 samples per report with 1000 Hz input and 128 us SAMPLEPER.

    Einar

  • Thank you for the response.  So i guess with a Motor at 475 RPM and 600 Pulses Per revolution that would require we capture each transition that is happening at 4.75 Khz, that is not attainable.

Related