Any one please share a working code of quadrature encoder
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Any one please share a working code of quadrature encoder
Hello Amit,
The input to the QEI is from 2 HES sensors.
irection and position is working fine.Velocity is the only issue issue.
Also if I put QEIEnable(QEI0_BASE); at the end then QEIPositionSet function is not executing.
so I have written like this
QEIConfigure(QEI0_BASE, (QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_NO_RESET | QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_SWAP),10000000);
QEIVelocityConfigure(QEI0_BASE,QEI_VELDIV_1,100000);
QEIVelocityEnable(QEI0_BASE);
QEIEnable(QEI0_BASE);
QEIPositionSet(QEI0_BASE, 5000000);
Also can you tell me more about QEIVelocityConfigure function and its arguments.I read the peripheral driver library
but i am not getting it completly .
May I add a voice (and vote) in support of Amit's position? And - if anyone is entitled to "disagree" w/the general use of "DRM" - that person clearly is Mr. Ashara.
This forum is tasked w/serving a large volume of users - anything which complicates, extends, & forces extra effort upon Amit - cannot be good. Long ago we were taught to, "reason/probe toward the limit." (this w/in college chemistry) Adapted here - should the majority of users adopt your (preferred) DRM code style - Amit's (and other's) response rate will spectacularly decline. Can that be good?
Now there are times when fast code, or more compact code provides key advantage. But in your example - the "one-time" set-up/config of QEI Registers - that benefit pales. (and the degree of difficulty/complexity rises, exponentially.)
As Amit noted - the API is broad, extensive, and supremely "time-tested." And DRM? Every use proves an adventure - prepare to spend vast (added) amounts of time turning MCU manual pages - in search of the "exact" Registers which are required. And then, "Read, Understand, and Program - each/every one of those (mostly) 32 bit registers - to perfection.
As a small, tech biz owner - staff/I apply the, "Ten foot pole rule" to DRM. (i.e. Kidz - Do NOT try this (DRM) @ home!)
Perhaps "disagree" was too "gentle" a word...
Hello Amit,
I am working with Jithin k joy, we need the QEI for measuring the speed of a motor coupled with two Hall effect sensors. The Magnetic wheel has 36 poles. The Sensors will give signals of 90-degree phase shifted waveform as required by QEI.
My doubt is how fast can the velocity be calculated? Because the motor is running at 0 to 2000 or 3000 RPM Max.
If the velocity calculation happens very fast, the number of interrupts will be too low to calculate.
for example, as I calculated, if my motor is running at 10000RPM, I will get only 12 interrupts in 1ms time frame( rising edge and falling edge interrupts of both sensors). As the motor is only at 3000RPM Max, I will get only 3 are 4 interrupts in 1 ms time. this resolution is too low to calculate the velocity.
No.Of poles in magnetic disk = 36
total rising and falling edge interrupt of 2 sensors = 36*2= 72
At 10000RPM no of interrupt per minute = 10000*72 = 720000
At 10000RPM no of interrupt per millisecond = 720000/(60*1000) = 12
Thus approximately at 3000RPM, I will get only 3 or 4 interrupts in 1ms.If the velocity calculation happens still faster, velocity can't be updated properly.
For still slower speed no interrupt will come in 1ms and the velocity calculation is not possible.
Am I Correct?
Please Clarify my doubts.
Thanking you in advance.
SubaAnanthan T
and for still slower speed no interrupt will come in 1ms
subaananthan T said:No.Of poles in magnetic disk = 36
total rising and falling edge interrupt of 2 sensors = 36*2= 72
Pardon - but believe I've spotted a rather large mistake. Is it not true that ONE magnet - passing one hall sensor - will generate TWO Interrupts? If so - your "72" result is one-half of that expected!
You argue that, "Velocity can't be updated properly" w/3 or 4 interrupts in 1mS. Yet you do not define that (ever) elusive, "Proper Update!"
My firm has produced advanced BLDC Motor Control Systems for past 5 years - we find 1mS update rate adequate - in most all circumstances.
In the event 1mS proves inadequate - would not your INCREASING the number of hall sensors be an (obvious) and simple, means of improvement?