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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/06/11 07:53
Read: times


 
Msg Score: -1
 -1 Looks like homework
#184091 - Speed control of running light
Hi Friends
Actually, I have a program in Assembly and want to include up/down buttons to change the speed of running.
I tried with calling differet delay routines but not getting success please suggest some idea.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;PROGRAM FOR DANCING LED;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;WITH SPEED CONTROL
;Three speeds UP & DOWN;
;USING TACTILE SWITCHES AT P0.0 & P0.1 for up & down buttons;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;

ORG 0000H


L1 EQU P3.4
L2 EQU P3.1
L3 EQU P3.0
L4 EQU P1.7
L5 EQU P1.6
L6 EQU P1.5
L7 EQU P1.4
L8 EQU P1.3
L9 EQU P1.2
L10 EQU P1.1
L11 EQU P1.0


MOV R4,#03H
FNAUTO: MOV R3,#05
D1: CALL DESGN1
DJNZ R3,D1
MOV R3,#05
D2: CALL DESGN2
DJNZ R3,D2
MOV R3,#05
D3: CALL DESGN3
DJNZ R3,D3
MOV R3,#05
D4: CALL DESGN4
DJNZ R3,D4
MOV R3,#05
D5: CALL DESGN5
DJNZ R3,D5
MOV R3,#05
D6: CALL DESGN6
DJNZ R3,D6
MOV R3,#05
D7: CALL DESGN7
DJNZ R3,D7
MOV R3,#05
D8: CALL DESGN8
DJNZ R3,D8
MOV R3,#05
D9: CALL DESGN9
DJNZ R3,D9
MOV R3,#05
JMP FNAUTO



DESGN1: CLR L1
SETB L2
CLR L3
SETB L4
CLR L5
SETB L6
CLR L7
SETB L8
CLR L9
SETB L10
CLR L11
CALL DELAY
CLR L2
SETB L1
CLR L4
SETB L3
CLR L6
SETB L5
CLR L8
SETB L7
CLR L10
SETB L9
SETB L11
CALL DELAY
RET

DESGN2: CALL CLEAR
CLR L1
CALL DELAY
CALL CLEAR
CLR L2
CALL DELAY
CALL CLEAR
CLR L3
CALL DELAY
CALL CLEAR
CLR L4
CALL DELAY
CALL CLEAR
CLR L5
CALL DELAY
CALL CLEAR
CLR L6
CALL DELAY
CALL CLEAR
CLR L7
CALL DELAY
CALL CLEAR
CLR L8
CALL DELAY
CALL CLEAR
CLR L9
CALL DELAY
CALL CLEAR
CLR L10
CALL DELAY
CALL CLEAR
CLR L11
CALL DELAY
RET

DESGN3: CALL CLEAR
CLR L11
CALL DELAY
CALL CLEAR
CLR L10
CALL DELAY
CALL CLEAR
CLR L9
CALL DELAY
CALL CLEAR
CLR L8
CALL DELAY
CALL CLEAR
CLR L7
CALL DELAY
CALL CLEAR
CLR L6
CALL DELAY
CALL CLEAR
CLR L5
CALL DELAY
CALL CLEAR
CLR L4
CALL DELAY
CALL CLEAR
CLR L3
CALL DELAY
CALL CLEAR
CLR L2
CALL DELAY
CALL CLEAR
CLR L1
CALL DELAY
RET

DESGN4: CALL CLEAR
CLR L1
CALL DELAY
CALL CLEAR
CLR L2
CALL DELAY
CALL CLEAR
CLR L3
CALL DELAY
CALL CLEAR
CLR L4
CALL DELAY
CALL CLEAR
CLR L5
CALL DELAY
CALL CLEAR
CLR L6
CALL DELAY
CALL CLEAR
CLR L7
CALL DELAY
CALL CLEAR
CLR L8
CALL DELAY
CALL CLEAR
CLR L9
CALL DELAY
CALL CLEAR
CLR L10
CALL DELAY
CALL CLEAR
CLR L11
CALL DELAY
CALL CLEAR
CLR L11
CALL DELAY
CALL CLEAR
CLR L10
CALL DELAY
CALL CLEAR
CLR L9
CALL DELAY
CALL CLEAR
CLR L8
CALL DELAY
CALL CLEAR
CLR L7
CALL DELAY
CALL CLEAR
CLR L6
CALL DELAY
CALL CLEAR
CLR L5
CALL DELAY
CALL CLEAR
CLR L4
CALL DELAY
CALL CLEAR
CLR L3
CALL DELAY
CALL CLEAR
CLR L2
CALL DELAY
CALL CLEAR
CLR L1
CALL DELAY
RET

DESGN5: CALL CLEAR
CLR L1
CLR L11
CALL DELAY
CALL CLEAR
CLR L2
CLR L10
CALL DELAY
CALL CLEAR
CLR L3
CLR L9
CALL DELAY
CALL CLEAR
CLR L4
CLR L8
CALL DELAY
CALL CLEAR
CLR L5
CLR L7
CALL DELAY
CALL CLEAR
CLR L6
CALL DELAY
CALL CLEAR
CLR L7
CLR L5
CALL DELAY
CALL CLEAR
CLR L8
CLR L4
CALL DELAY
CALL CLEAR
CLR L9
CLR L3
CALL DELAY
CALL CLEAR
CLR L10
CLR L2
CALL DELAY
CALL CLEAR
CLR L11
CLR L1
CALL DELAY
CALL CLEAR
RET

DESGN6: CALL ALLON
CALL DELAY
CALL CLEAR
CALL DELAY
RET

DESGN7: CALL ALLON
SETB L1
CALL DELAY
CALL ALLON
SETB L2
CALL DELAY
CALL ALLON
SETB L3
CALL DELAY
CALL ALLON
SETB L4
CALL DELAY
CALL ALLON
SETB L5
CALL DELAY
CALL ALLON
SETB L6
CALL DELAY
CALL ALLON
SETB L7
CALL DELAY
CALL ALLON
SETB L8
CALL DELAY
CALL ALLON
SETB L9
CALL DELAY
CALL ALLON
SETB L10
CALL DELAY
CALL ALLON
SETB L11
CALL DELAY
RET

DESGN8: CALL ALLON
SETB L11
CALL DELAY
CALL ALLON
SETB L10
CALL DELAY
CALL ALLON
SETB L9
CALL DELAY
CALL ALLON
SETB L8
CALL DELAY
CALL ALLON
SETB L7
CALL DELAY
CALL ALLON
SETB L6
CALL DELAY
CALL ALLON
SETB L5
CALL DELAY
CALL ALLON
SETB L4
CALL DELAY
CALL ALLON
SETB L3
CALL DELAY
CALL ALLON
SETB L2
CALL DELAY
CALL ALLON
SETB L1
CALL DELAY
RET

DESGN9: CALL ALLON
SETB L11
SETB L1
CALL DELAY
CALL ALLON
SETB L10
SETB L2
CALL DELAY
CALL ALLON
SETB L9
SETB L3
CALL DELAY
CALL ALLON
SETB L8
SETB L4
CALL DELAY
CALL ALLON
SETB L7
SETB L5
CALL DELAY
CALL ALLON
SETB L6
CALL DELAY
CALL ALLON
SETB L5
SETB L7
CALL DELAY
CALL ALLON
SETB L4
SETB L8
CALL DELAY
CALL ALLON
SETB L3
SETB L9
CALL DELAY
CALL ALLON
SETB L2
SETB L10
CALL DELAY
CALL ALLON
SETB L1
SETB L11
CALL DELAY
RET

CLEAR: SETB L1
SETB L2
SETB L3
SETB L4
SETB L5
SETB L6
SETB L7
SETB L8
SETB L9
SETB L10
SETB L11
RET

ALLON: CLR L1
CLR L2
CLR L3
CLR L4
CLR L5
CLR L6
CLR L7
CLR L8
CLR L9
CLR L10
CLR L11
RET

DELAY:
JNB P0.0, CHECK
NOP
;JB P0.0,NOR_DEL
JNB P0.1,CHECK1
NOP
;JB P0.1,NOR_DEL
CHECK:
INC R4
MOV A,#03H
SUBB A,R4
JZ NOR_DEL
JC INCR
JNC DECR
CHECK1:
DEC R4
MOV A,#03H
SUBB A,R4
JZ NOR_DEL
JC INCR
JNC DECR


NOR_DEL:MOV R0,#0FFH
MOV R1,#0FFH
INLOP: MOV R2,#01H
DJNZ R2,$
DJNZ R1,$
DJNZ R0,INLOP
RET


INCR: ;INC R4
CJNE R4,#04H,NXT1
MOV R0,#80H
MOV R1,#0FFH ;DEL+
AJMP INLOP
NXT1: CJNE R4,#05H,NXT2
MOV R0,#01H ;DEL++
MOV R1,#80H
AJMP INLOP
NXT2: CJNE R4,#06H,NXT3
LAST: MOV R0,#01H
MOV R1,#01H ;DEL+++
AJMP INLOP
NXT3: MOV A,#06H
SUBB A, R4
CJNE A,#00H,NXT2
AJMP LAST

DECR: ;DEC R4 ; MUST REQUIRED RST BUTTON TO AVOID CRASH
CJNE R4,#02H, NXT4
MOV R0,#36H ;DEL-
AJMP INLOP
NXT4: CJNE R4,#01H, NXT5
MOV R0,#80H ;DEL-
AJMP INLOP
NXT5: CJNE R4,#00H, NXT5
MOV R0,#0FFH ;DEL-
AJMP NXT5


END


List of 16 messages in thread
TopicAuthorDate
Speed control of running light            01/01/70 00:00      
   Please insert the legible source code            01/01/70 00:00      
      comments            01/01/70 00:00      
   please suggest some idea            01/01/70 00:00      
   Bad            01/01/70 00:00      
   Better to use timer            01/01/70 00:00      
      May be better - but not essential            01/01/70 00:00      
      Ok that 's fine            01/01/70 00:00      
      hw-timers for delays            01/01/70 00:00      
         there doesn't seem to be any other tasks            01/01/70 00:00      
            Not uncommon to have            01/01/70 00:00      
   no, you don't            01/01/70 00:00      
   do you have pullups on P0?            01/01/70 00:00      
   ***__HORRIBLE CODE__***            01/01/70 00:00      
   This Problem Shouts "Use a Table"            01/01/70 00:00      
   new tutorial needed            01/01/70 00:00      

Back to Subject List