Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/28/07 10:33
Read: times


 
#143691 - count the timing interval
Responding to: ???'s previous message
MOTOR_KON:
CLR c
MOV A,#00H
MOV R0,#00H
MOV R1,#00H
MOV R2,#00H
MOV R3,#00H
MOV R4,#00H
MOV R5,#00H
MOV R6,#00H
MOV R7,#80H
MOV B,#00H
SETB P3.2
mov tmod,#11h
mov ie,#09h
setb ea
SETB IT0
mov detik,#00h
MOV kal,#0B3H


MOTOR_KONT1:
MOV P2,KAL
JMP MOTOR_KONT1

;================================================================
; INTERRUPT
;================================================================

SENSOR_KONT:
push 01
push 07
push acc
push detik
push 00
push cek_angka
PUSH KAL
PUSH 05
CLR TR1
CLR C
MOV TH1,#HIGH(-10000)
MOV TL1,#LOW(-10000)
SETB TR1
MOV R7,#80H
MOV A,DETIK
MOV R1,#59H
SUBB A,@R1
JC COMPAR
MOV A,kal
INC A
cjne a,#0e4h,lanj
pop 01
pop 07
pop acc
pop detik
pop 00
pop cek_angka
POP KAL
ret

lanj:
MOV kal,A
pop 01
pop 07
pop acc
pop detik
POP KAL
pop 00
pop cek_angka
RET

COMPAR:
MOV A,kal
DEC A
CJNE A,#081H,LANJ2
pop 01
pop 07
pop acc
pop detik
pop 00
pop cek_angka
POP KAL
RET

LANJ2:
MOV kal,A
pop 01
pop 07
pop acc
pop detik
pop 00
pop cek_angka
POP KAL
RET

EXIT:
RET

;===============================================================
; INTERRUPT TIMER
;================================================================

TIMER_KON:

PUSH 07
push detik
INC R7
mov DETIK,r7
CLR TR1
CLR TF1
MOV TH1,#HIGH(-10000)
MOV TL1,#LOW(-10000)

SETB TR1
pop detik
POP 07
RET





if KAL is DAC input to control the reference voltage from PWM so we can adjust the speed of the motor.
CEK_ANGKA is the reference time we want.

this point of this program is to compare the the reference time and the the real time(real time is the time between first and the second interrupt). The interrupt is caused by rotary encoder sensor.

If the reference time>real time ===> the KAL will decrease
if the reference time<real time ===> the KAL will Increase


iS ANYBODY COULD HELP ME WITH THIS PROGRAM?? I think the program is already correct, but if we installed the program to hardware, the output of the PWM is increasing until 100%.And i don't know why??

For joe many thx .



Best regards





Henrico

List of 12 messages in thread
TopicAuthorDate
Help ME!!!            01/01/70 00:00      
   TIMER 2 IN CAPTURE MODE            01/01/70 00:00      
   Elaborate            01/01/70 00:00      
      help me            01/01/70 00:00      
         toggle the timer            01/01/70 00:00      
            count the timing interval            01/01/70 00:00      
               just formatted your code            01/01/70 00:00      
               severe errors            01/01/70 00:00      
         I think it's too easy!!!            01/01/70 00:00      
            only if interval is >>1ms !!            01/01/70 00:00      
               no it's not necessary!!!            01/01/70 00:00      
                  sorry, You are right            01/01/70 00:00      

Back to Subject List