| cac liu |
| I want to use the Rotary Encoder to control the cs3310,but I don't known how to use the Rotary Encoder,Could anyone help me? |
|
|
| janneman |
You would need to use a microcontroller to decode the rotary control pulses and to write to the CS3310 registers. Have you ever done anything with microcontrollers?
Jan Didden |
|
|
| cac liu |
I just know about the 89s51(mcs51)
I want to use to 89s51 to connect Rotary Encoder |
|
|
| analog_sa |
| quote: | Originally posted by cac liu
I just know about the 89s51(mcs51)
I want to use to 89s51 to connect Rotary Encoder |
Use it if you want. Probably an overkill but will certainly do the job. |
|
|
| cac liu |
| but how to write the program??? |
|
|
| janneman |
You only need two input lines. Here's a bit of documentation from a project I did once:
;--------System design notes-------------------------------------
;
; The encoders output a 2-bit value:
; the A-bit signals rotation,
; the B-bit signals the direction of rotation.
; encoder movement is detected by polling and debouncing in the b-port.
;
;CW channel A ___ ___ ___ [channel A leads channel B]
; ___| |___| |___|
;
; channel B ___ ___ ___
; |___| |___| |___|
;
;
;
; CCW: channel A ___ ___ ___ [channel A trails channel B]
; ___| |___| |___|
;
; channel B ___ ___ ___
; __| |___| |___|
;
; A-bit B-bit Direction
; 0>1 0 CW
; 1 CCW
; 1>0 0 CCW
; 1 CW
You poll the A-bit (or hang it on an interrupt line) and then check the B-bit for direction of rotation. Ther's probably a ton of other ways to do this, this happened to work for me.
Edit: I realize the formatting is screwed up, if needed I can email it to you.
Jan Didden |
|
|
| cac liu |
I had try to write some,but it has dithering,so it is not steady
Could you send me the program you had write for MCS51 , I want
to have a reference.
my mail box is cacworld@126.com |
|
|
| janneman |
You have to debounce the bits. At the moment the switches close/open they bang around some time, depending on the quality of the encoder, but they all do it. So once you detect bit change, you wait a couple of milliseconds (I forgot exactly how many, it's trial and error and depends as I said on the type/brand of encoder), then after the delay you check the bit values and do your processing.
Edit: I think I used 6 msec debounce. Can't take too long, else you miss some pulses if someone turns it real fast...
Jan Didden |
|
|
| cac liu |
I think I start to understand what you have just say.
I get to try again !
Could you send me your program to me to be referance?
Thank you very much !!! |
|
|
| janneman |
| quote: | Originally posted by cac liu
I think I start to understand what you have just say.
I get to try again !
Could you send me your program to me to be referance?
Thank you very much !!! |
I'm sorry but there is no 'program' to speak of...
It depends on the microcontroller you use, in 'meta-speak', you can do (with polling):
- see if the A bit is different from last time you looked;
- if yes, wait the debounce period;
- test the A-bit status (one or zero);
- test the B-bit status;
-depending on one of the four combinations, go to a routine to do whatever you want to do as action to the encoder movement.
I did this in a PIC and it is just a bunch of bittest and goto statements, but embedded in the program so I can't really send it to you.
But if you understand the process it should be a no-brainer.
Jan Didden |
|
|
| cac liu |
How about this?
MAIN: MOV P2,#0FFH
S0: JB P3.6,S0
S1: JB P3.7,S1
JB P3.6,S2
JNB P3.6,S3
JMP MAIN
INC1: CLR P2.7
JMP MAIN
DEC1: CLR P2.1
JMP MAIN
S2: JNB P3.7,INC1
RET
S3: JB P3.7,DEC1
RET
END |
|
|
| janneman |
Sorry, I can't decode this, I am totally unfamiliar with anything MC51...
Jan Didden |
|
|
|