Discussion in "Project Help" started by    zyrex    Dec 22, 2007.
Mon Dec 31 2007, 12:11 am
#21
ok i understand and i can change its value but my problem is interrupt... i will send you my codes soon...
Mon Dec 31 2007, 01:31 am
#22
$include(REG51.inc)
 
 STATUS_file EQU 20h ; STATUS_file.0 =1 turn right 0 turn left bit.1=1 turn  0 stop bit.2=1 from1 interrupt 0 from0 interrupt
 DT          EQU 21h 
 MAX-DT      EQU 22h
 MIN_DT      EQU 23h  
 L293B_4A   equ P1.0          ; MOTOR turn right
 L293B_3A   equ P1.1          ; MOTOR turn left
 L293D_E    equ P1.2     
             
 	ORG 2000h
   jmp START
   ORG 000bh
   jmp ISR
ISR:
   MOV DT,#125
   CLR TR0
	CLR TF0
	JNB STATUS_file.2,BIRLE
	JMP SiFiRLA
BIRLE:
   setb STATUS_file.2
   CJNE A,#'K',AZALT_1
   JMP ARTTIR_1
    
AZALT_1: ;from 0 interrupt
   CJNE A,#'L',BIRLE
   MOV A,DT
   INC A
   MOV TH0,A
   ret
ARTTIR_1:
   MOV A,DT
   DEC A
   MOV TH0,A
   ret
SiFiRLA:
   CLR STATUS_file.2
   CJNE A,#'K',AZALT      
	JMP ARTTIR
AZALT: ;from 1 interrupt
   CJNE A,#'L',SiFiRLA
   MOV A,DT
   DEC A
   MOV TH0,A
   ret
ARTTIR:
   MOV A,DT
   INC A
   MOV TH0,A
   ret


reti


START:
    SETB ETO  ;TIMER 0 work
    MOV TMOD,#10h           ;TIMER 0 configuration
    SETB TR0
    MOV TLO,#255 
    MOV MIN_DT,#25
    MOV MAX_DT,#250
    CLR STATUS_file 
    MOV TH1,#0FDH
    MOV TL1,#0FDH
    ORL 87h,#080h  ;SMOD 1
    MOV SCON,#048h
    MOV TMOD,#020h
    SETB TR1
    CLR RI
BEKLE:  
    SETB REN
    LCALL GETCH
    CLR REN
    CJNE A,#'N',SOL_BAK ;CALIS
    CALL SAG
     SOL_BAK:
    CJNE A,#'T',B_BAK ; SAG
    CALL SOL
  B_BAK:
    CJNE A,#'R',BEKLE  ; SOL
    CAll DUR
    
GETCH:
    JNB RI,$
    CLR RI
    MOV A,SBUF
    RET
PUTCH:
    JNB TI,$
    CLR TI
    MOV SBUF,A
    RET
    
SAG:
    CALL PUTCH
    setb  L293D_A      ;Make Positive of motor 1
    clr   L293D_B      ;Make negative of motor 0
    setb  L293D_E      ;Enable to run the motor
    ret                ;Return from routine
         
SOL:
    CALL PUTCH
    clr   L293D_A      ;Make positive of motor 0
    setb  L293D_B      ;Make negative of motor 1
    ret                ;Return from routine
         
DUR:
    CALL PUTCH
    clr   L293D_A      ;Make Positive of motor 0
    clr   L293D_B      ;Make negative of motor 0
    clr   L293D_E      ;Disable the o/p
    ret                ;Return from routine
         
END 
    


[ Edited Mon Dec 31 2007, 01:27 pm ]
Mon Dec 31 2007, 01:32 am
#23
iam using ride51 to compile them:D
Mon Dec 31 2007, 01:45 pm
#24
there are few mistakes in your code.
and there are few thing which i do not understand..
i am going to comment it so explain them to me

The first main and serious mistake is.. you are not using RETI while coming back from interrupt routine.. and interrupt routine seems to be worng..

ISR:
   MOV DT,#125
   CLR TR0
        CLR TF0
        JNB STATUS_file.2,BIRLE
        JMP SiFiRLA
BIRLE:
   setb STATUS_file.2
   CJNE A,#'K',AZALT_1
   JMP ARTTIR_1
   
AZALT_1: ;from 0 interrupt
   CJNE A,#'L',BIRLE
   MOV A,DT
   INC A
   MOV TH0,A
   ret ;RETI
ARTTIR_1:
   MOV A,DT
   DEC A
   MOV TH0,A
   ret   ;RETI
SiFiRLA:
   CLR STATUS_file.2
   CJNE A,#'K',AZALT      
        JMP ARTTIR
AZALT: ;from 1 interrupt
   CJNE A,#'L',SiFiRLA
   MOV A,DT
   DEC A
   MOV TH0,A
   ret   ;RETI
ARTTIR:
   MOV A,DT
   INC A
   MOV TH0,A
   ret ;RETI should be used

reti ;there is no use of this Return instruction


What exactly you are doing in your ISR? i cant understand..
Mon Dec 31 2007, 05:54 pm
#25
:D:D this is second version of my codes. first version can turn the motor right,left and can stops the motor. i tried to write interrupt section and i see it in my book. ISR is interrupt section i mean when user pushs a button the program must go ISR section. I now its wrong . if you want i can send you first version so you can say how can i add interrupt and pwm??
Mon Dec 31 2007, 06:05 pm
#26
u can have interrupt and PWM.. not a problem.. just keep ur ISR small.. and.. increase the priority of timer interrupt..

you actually do not need any interrupt for reading buttons in your code..
if you have taken a look at the fan control project in the same post where i posted the PWN code you will come to know how to use PWM..
i give you the link.. go through the program. do not care about the temperature thing.. just see how the manual part works..
http://www.8051projects.net/forum-t2321-post.html
see fanlow routine.. here i am loading R7 with a value.. with your project. this value need to be changed when button is pressed.. either increase it or decrease it..
and timer0_int is the PWM code.. read it carefully


[ Edited Mon Dec 31 2007, 06:05 pm ]
Mon Dec 31 2007, 06:11 pm
#27
i know when reading buttons, i want to use interrupt for PWM when pushing speed up button ....
thank alot i try to understand code which your post...
Mon Dec 31 2007, 06:21 pm
#28
i think this program cant be fan speed done because it have never jump low_done just speed up ... am i right i try to do this way but i cant complete the code :S
Mon Dec 31 2007, 07:02 pm
#29
i will try to edit your code.. to make it work with PWM..
i really don't know how your circuit looks like..
and coz of difference in language.. i cant understand the labels
hope we can workout something..
Mon Dec 31 2007, 08:14 pm
#30
i am translating:D:D:D
BIRLE: SETB (means make logic 1)
AZALT: DECRESE
ARTTIR: INCRESE
SiFiRLA: CLEAR
BEKLE: WAIT
SAG:RIGHT
SOL:LEFT
DUR:STOP
i use L293B to control motor and h bridge thanks a lot

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am