hjl4 said:Hi,
I hope someone out there has done this in assembly before.
I took apart a mouse, and removed the encoder wheels, along with the IR Led's.
I want to use this, as an encoder for an accelerator, using 2 bit gray code.
In other words, when thumb pressure is applied to a spring returned knob, it send gray code to micro. 16f628.
I can't use interupt as it is all ready used by a safety switch. My delema is knowing the direction(accel or deccelerate)the encoder is going. As the encoder is moved clockwise, the micro needs to increase speed of dc motor, and decrease when moving ccw. My guess is ,I should get 4 different speeds. Right?
I have searched this forum, and others, and there search engines sucks..with no good results.
I have googled, and everybody including there dog, has done this.
Unfortunately, I don't have time learning CHBasic or even C. I write in assembly exclusively.
I hope someone can help.
Thank you!
;
; check the Rotary Encoder A and B switches for a change (the
; SWDATA variable contains debounced switch data)
;
ISR_Encoder
movf SWDATA,W ; get switch data '------BA' |B0
andlw b'00000011' ; mask for B and A switches |B0
xorwf ENCOLD,W ; same as last reading? |B0
bz ISR_NextColumn ; yes, branch (no change) |B0
xorwf ENCOLD,W ; else restore encoder bits in W |B0
rrf ENCOLD,f ; prep for B-old ^ A-new |B0
xorwf ENCOLD,f ; ENCOLD bit 0 = direction |B0
rrf ENCOLD,f ; now Carry bit = direction |B0
movwf ENCOLD ; update ENCOLD with new AB |B0
;
I can't use interupt as it is all ready used by a safety switch.
I took apart a mouse, and removed the encoder wheels, along with the IR Led's.
I want to use this, as an encoder for an accelerator, using 2 bit gray code.
Oznog said:Polling could be hokey if the motor speed is significant. You need to dedicate a lot of time to polling.
hjl4 said:Hi Mike,
I have'nt had time to work on my encoder or program.
I 'm trying to read thru your first reply, and I'm having a bit of problem making sense of it.
If I use quadrature encoder, and turn it beyond it's 2 bits(3h), how does the Pic know if I am rotating it clockwise or ccw if I go beyond the 2 bit limit. I mean after 01,11,10,00, and then what???. Does the Pic see this as a reset back to 01?
I have an encoder with total of 25 steps.(optical that is).
I guess it's a matter of opinion and preference (grin)...panic mode said:you don't have to kill yourself with loads of code if you can live with one more chip (dual D-type flip flop). this way all you have to do is count up or down:
**broken link removed**
hjl4 said:Hi Mike,
I have'nt had time to work on my encoder or program.
I 'm trying to read thru your first reply, and I'm having a bit of problem making sense of it.
If I use quadrature encoder, and turn it beyond it's 2 bits(3h), how does the Pic know if I am rotating it clockwise or ccw if I go beyond the 2 bit limit. I mean after 01,11,10,00, and then what???. Does the Pic see this as a reset back to 01?
I have an encoder with total of 25 steps.(optical that is).
Maybe I'm way over my head here.
I can't seem to grasp the concept.
Anyways,Thanks for your replies.
He'd have to spin the knob on his 25-pulse/revolution encoder more than 40 times per second (2400 rpm) to miss a pulse when polling with 1-msec interrupts...philba said:I'd definitely use RBIF but timer driven sampling should work as well. You can pretty easily estimate the speed of of the quad encoder pulses. 1mS might be a bit slow as you should be sampling at least 2X the max rate.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?