QEP dependency on time step

I am using QEP module to sense the speed using JENCODER speed sensor. I am finding it strange that QEP output is changing with respect to time step when i am trying to compile the file and see the output in HIL simulation file. When the time step is small (3000Hz) the QEP is getting saturated at 0.5 value. When time step is 20000Hz the QEP is shooting through value of 1 for very low speed. QEP is giving linear response from 0 to 1 only when I am keeping time step to be 10000Hz. I am also attaching the complete file for reference. I would be glad if someone point me out why the QEP module behaviour is changing with respect to timestep and how to make QEP behaviour independent of time step.

Hi Sachin,Overall, you had a

Hi Sachin, Overall, you had a good approach, but there were a couple issues with your diagram:

  1. The encoder scaling you were using was set up for a 4000 tick count encoder, but your diagram comments indicate that you are using 256 counts.
  2. You have only 256 counts in your encoder, and you used a 4 pole division to get electrical angle which you used for speed measurement which reduced your counts to 64 and multiplied your speed by 4. This will have very rough results at low speeds. As you arent' doing FOC, there is no need for rotor electrical angle, so need to divide by pole count. You should use mechanical angle.
  3. The TI "QEP Speed" block has poor results for low encoder tick counts. We recommend use of the Embedded > Examples > Digital Motor Control > Tools > fxCalcSpeed

The attached diagram below has the mods mentioned above.

Hello,The QEP is being read


The QEP is being read by the MCU at the set frequency of the controller, but the received data goes through some calculations and adjustments before it is fed out (it goes through the encoder to Elec Angle and the QEP Speed Calculator). All these calculations are running at the set time step speed. That means that for a 100μs time step you the value of the calculations refreshes every 100μs.

My recommendation is for you to use set your diagram to the smallest time step needed (which in your case would be dictated by the QEP). You can then select the parts of your diagram that don't demand such speed and place them in a compound block. Right click on the created compound block and set the time step to something bigger for that compound. Note that if some parts are not time critical you can set a compound block to run as a background thread. That would give that specific block a lower priority when it comes to task scheduling.