| ??? 01/10/02 10:55 Read: times |
#18508 - up/down counter /rotation direction |
hello friends,
i hv problem in counting for direction and pluses , im using both intp with optical sensor for each intp , normally it works fine , but when shaft randomly change the direction of rotation it cant follow the correct direction , im using multiplexed led display ,do i need more than 2 sensor for correct counting ? more over it should not count on vibration ,pls fix these code , here are the code that im using for both intp; IrqExt0: NOP ; clr 26h.4 NOP jbc 26h.1,rtn0 ; direction checking jbc 26h.1,rtn0 NOP setb 26h.2 ; set direction setb 26h.2 ; jb 26h.3,rtn0 ; save from vibration ; setb 26h.3 clr p1.1 setb p1.2 NOP push acc mov a,20h inc a mov 20h,a cjne a,#0,exit0 mov a,21h inc a mov 21h,a cjne a,#0,exit0 mov a,22h inc a mov 22h,a exit0: pop acc mov 27h,20h mov 28h,21h mov 29h,22h ; clr ex0 ; setb ex1 rtn0: reti ;IrqExt1: NOP ; clr 26h.3 NOP jbc 26h.2,rtn1 jbc 26h.2,rtn1 NOP NOP setb 26h.1 setb 26h.1 ; jb 26h.4,rtn1 ; setb 26h.4 clr p1.2 setb p1.1 NOP push acc mov a,20h cjne a,#01h,countd1 ;zero zero detect... should not down to zero mov a,21h cjne a,#0h,countd1 mov a,22h cjne a,#0h,countd1 mov 20h,#01h sjmp exit countd1: mov a,20h dec a mov 20h,a cjne a,#0ffh,exit mov a,21h dec a mov 21h,a cjne a,#0ffh,exit mov a,22h dec a mov 22h,a cjne a,#0ffh,exit exit: pop acc mov 27h,20h mov 28h,21h mov 29h,22h ; clr ex1 ; setb ex0 rtn1: reti ;*************************** |
| Topic | Author | Date |
| Encoder Tutorial Info | 01/01/70 00:00 | |
| RE: Encoder Tutorial Info | 01/01/70 00:00 | |
| RE: Encoder Tutorial Info | 01/01/70 00:00 | |
up/down counter /rotation direction | 01/01/70 00:00 |



