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

Parents Reply Children
  • Just another point.

    If the motor spins at 500 RPM and there are 600 Pulses (transitions) per revolution.

    that means a pulse occurs every 200uS.

    500 Rev/Min x 1min/60Sec = 8.3 rev/Sec

    8.3Rev/Sec x 600 pulses/rev = 5000 Pulses / Sec = 200uS/Pulse

    If we set the SAMPLEPER to 128uS we should be able to catch each transition??

  • Hi Wes,

    Yes, I agree. Here the *** duration is 200 us, so the pulse period is 400 us. That is no problem with a 128 us sampling period. To be honest, we don't see a lot of QDEC questions and I had not thought this through before. But it must be so that as long as the the sample period is shorter than the pulse with (half the period) you are good, that is Nyquist.

    (The QDEC also counts double transitions in a separate accumulator - ACCDBL, so you can see if the input signal is too fast or there has been a decoding error for other reasons. Though of course you have aliasing when the frequency is higher than half the sampling frequency, so you cannot really trust what you get at this point).

  • 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 

Related