Discussion in "Project Doubts" started by    sankalp_s    Nov 30, 2014.
Thu Dec 18 2014, 09:54 am
#11
Code is all ok.. just change EXT0 to EX0... By mistake I wrote the wrong bit name. EX0 is for external interrupt 0.
 sankalp_s like this.
Fri Dec 19 2014, 02:02 am
#12
SIR THIS CODE IS NOT WORKING..

ORG 000H ; starting address
SJMP LABEL
ORG 13H
    JNB P3.3, $
    RETI
SJMP LABEL1

LABEL1:
SETB EX1 ; Enable external interrupt 1
SETB EA   ; Enable interrupts

L1 EQU	 P1.2 ;LED CONECTED TO THIS PORT	
L2 EQU	 P1.3 ;LED CONECTED TO THIS PORT
L3 EQU   P1.4 ;LED CONECTED TO THIS PORT
L4 EQU   P1.5 ;LED CONECTED TO THIS PORT
L5 EQU   P1.6 ;LED CONECTED TO THIS PORT
L6 EQU   P1.7 ;LED CONECTED TO THIS PORT


LABEL:	
MOV R3, #05 ;REPEtion of pattern 
D7:	CALL DESGN7
DJNZ R3,D7	
MOV R3, #05 ;REPEtion of pattern 
D8:	CALL DESGN8
DJNZ R3,D8	
MOV R3, #05 ;REPEtion of pattern 
D9:	CALL DESGN9
DJNZ R3,D9	
JMP LABEL

DESGN7:	CALL ALLON 
CALL DELAY
SETB L1
CALL DELAY
SETB L2
CALL DELAY
SETB L3
CALL DELAY
SETB L4
CALL DELAY
SETB L5
CALL DELAY
SETB L6
CALL DELAY
CALL DELAY	
SETB L6
CALL DELAY	
SETB L5
CALL DELAY	
SETB L4
CALL DELAY	
SETB L3
CALL DELAY	
SETB L2
CALL DELAY
SETB L1
CALL DELAY
RET

DESGN8:	CALL ALLON
SETB L6
SETB L1
CALL DELAY
CALL ALLON	
SETB L5
SETB L2
CALL DELAY
CALL ALLON	
SETB L4
SETB L3
CALL DELAY
RET

DESGN9:	CALL ALLON 
CALL DELAY	
SETB L6
CALL DELAY	
SETB L5
CALL DELAY	
SETB L4
CALL DELAY	
SETB L3
CALL DELAY	
SETB L2
CALL DELAY
SETB L1
CALL DELAY
RET	

CLEAR:	SETB L1
SETB L2
SETB L3
SETB L4
SETB L5
SETB L6
RET

ALLON:	CLR L1
CLR L2
CLR L3
CLR L4
CLR L5
CLR L6
RET

DELAY:	MOV R0,#0FFH
INLOP:	MOV R1,#0FFH
DJNZ R1,$
DJNZ R0,INLOP
RET
END

Fri Dec 19 2014, 02:06 am
#13



i've tried this code but faced a syntax error on line of setb ext0...
( Symbol not defined: ext0)

sankalp_s


Which compilier are you using ?



sir one thing more can u give me the while loop code
example for my requirement ..

sankalp_s



ORG 03H
JNB P3.2, $
RETI

This is all the code you need to freeze the display.


can i use pin int1 for this operation?

sankalp_s


Yes, but the code changes to..
    ORG 13H
    JNB P3.3, $
    RETI

//and 
SETB EXT1 ; Enable external interrupt 1
SETB EA   ; Enable interrupts


An alternative method does not use an interrupt.
Monitor the key in the delay routine.
DELAY: MOV R0,#0FFH
INLOP: MOV R1,#0FFH
buttonTest:             ;button is the input pin 
JNB button, buttonTest  ;wait while pressed
DJNZ R1,buttonTest
DJNZ R0,INLOP
RET


ExperimenterUK





I'm using mcu8051ide for compiling..
and sorry sir the alternate code is also not working..
Fri Dec 19 2014, 02:10 am
#14


SIR THIS CODE IS NOT WORKING..

ORG 000H ; starting address
SJMP LABEL
ORG 13H
    JNB P3.3, $
    RETI
SJMP LABEL1

LABEL1:
SETB EX1 ; Enable external interrupt 1
SETB EA   ; Enable interrupts

L1 EQU	 P1.2 ;LED CONECTED TO THIS PORT	
L2 EQU	 P1.3 ;LED CONECTED TO THIS PORT
L3 EQU   P1.4 ;LED CONECTED TO THIS PORT
L4 EQU   P1.5 ;LED CONECTED TO THIS PORT
L5 EQU   P1.6 ;LED CONECTED TO THIS PORT
L6 EQU   P1.7 ;LED CONECTED TO THIS PORT


LABEL:	
MOV R3, #05 ;REPEtion of pattern 
D7:	CALL DESGN7
DJNZ R3,D7	
MOV R3, #05 ;REPEtion of pattern 
D8:	CALL DESGN8
DJNZ R3,D8	
MOV R3, #05 ;REPEtion of pattern 
D9:	CALL DESGN9
DJNZ R3,D9	
JMP LABEL

DESGN7:	CALL ALLON 
CALL DELAY
SETB L1
CALL DELAY
SETB L2
CALL DELAY
SETB L3
CALL DELAY
SETB L4
CALL DELAY
SETB L5
CALL DELAY
SETB L6
CALL DELAY
CALL DELAY	
SETB L6
CALL DELAY	
SETB L5
CALL DELAY	
SETB L4
CALL DELAY	
SETB L3
CALL DELAY	
SETB L2
CALL DELAY
SETB L1
CALL DELAY
RET

DESGN8:	CALL ALLON
SETB L6
SETB L1
CALL DELAY
CALL ALLON	
SETB L5
SETB L2
CALL DELAY
CALL ALLON	
SETB L4
SETB L3
CALL DELAY
RET

DESGN9:	CALL ALLON 
CALL DELAY	
SETB L6
CALL DELAY	
SETB L5
CALL DELAY	
SETB L4
CALL DELAY	
SETB L3
CALL DELAY	
SETB L2
CALL DELAY
SETB L1
CALL DELAY
RET	

CLEAR:	SETB L1
SETB L2
SETB L3
SETB L4
SETB L5
SETB L6
RET

ALLON:	CLR L1
CLR L2
CLR L3
CLR L4
CLR L5
CLR L6
RET

DELAY:	MOV R0,#0FFH
INLOP:	MOV R1,#0FFH
DJNZ R1,$
DJNZ R0,INLOP
RET
END


sankalp_s




sir can you explain what is missing in this code?
what would value of R3 in this code.
Fri Dec 19 2014, 05:51 am
#15
This version works.
Edit it to use either method.


ORG 000H ; starting address
SJMP LABEL
ORG 13H
    JNB P3.3, $
    RETI


L1 EQU	 P1.2 ;LED CONECTED TO THIS PORT	
L2 EQU	 P1.3 ;LED CONECTED TO THIS PORT
L3 EQU   P1.4 ;LED CONECTED TO THIS PORT
L4 EQU   P1.5 ;LED CONECTED TO THIS PORT
L5 EQU   P1.6 ;LED CONECTED TO THIS PORT
L6 EQU   P1.7 ;LED CONECTED TO THIS PORT


LABEL:	
;SETB EX1 ; Enable external interrupt 1
;SETB EA   ; Enable interrupts

MOV R3, #05 ;REPEtion of pattern 
D7:	CALL DESGN7
DJNZ R3,D7	
MOV R3, #05 ;REPEtion of pattern 
D8:	CALL DESGN8
DJNZ R3,D8	
MOV R3, #05 ;REPEtion of pattern 
D9:	CALL DESGN9
DJNZ R3,D9	
JMP LABEL

DESGN7:	CALL ALLON 
CALL DELAY
SETB L1
CALL DELAY
SETB L2
CALL DELAY
SETB L3
CALL DELAY
SETB L4
CALL DELAY
SETB L5
CALL DELAY
SETB L6
CALL DELAY
CALL DELAY	
SETB L6
CALL DELAY	
SETB L5
CALL DELAY	
SETB L4
CALL DELAY	
SETB L3
CALL DELAY	
SETB L2
CALL DELAY
SETB L1
CALL DELAY
RET

DESGN8:	CALL ALLON
SETB L6
SETB L1
CALL DELAY
CALL ALLON	
SETB L5
SETB L2
CALL DELAY
CALL ALLON	
SETB L4
SETB L3
CALL DELAY
RET

DESGN9:	CALL ALLON 
CALL DELAY	
SETB L6
CALL DELAY	
SETB L5
CALL DELAY	
SETB L4
CALL DELAY	
SETB L3
CALL DELAY	
SETB L2
CALL DELAY
SETB L1
CALL DELAY
RET	

CLEAR:	SETB L1
SETB L2
SETB L3
SETB L4
SETB L5
SETB L6
RET

ALLON:	CLR L1
CLR L2
CLR L3
CLR L4
CLR L5
CLR L6
RET

DELAY:	MOV R0,#0FFH
INLOP:	MOV R1,#0FFH
buttonTest:            
;JNB P3.3, buttonTest  ;enable this line wait while pressed
DJNZ R1,buttonTest

DJNZ R0,INLOP
RET
END




[ Edited Fri Dec 19 2014, 06:10 am ]
 sankalp_s like this.
Fri Dec 19 2014, 11:34 pm
#16


This version works.
Edit it to use either method.


ORG 000H ; starting address
SJMP LABEL
ORG 13H
    JNB P3.3, $
    RETI


L1 EQU	 P1.2 ;LED CONECTED TO THIS PORT	
L2 EQU	 P1.3 ;LED CONECTED TO THIS PORT
L3 EQU   P1.4 ;LED CONECTED TO THIS PORT
L4 EQU   P1.5 ;LED CONECTED TO THIS PORT
L5 EQU   P1.6 ;LED CONECTED TO THIS PORT
L6 EQU   P1.7 ;LED CONECTED TO THIS PORT


LABEL:	
;SETB EX1 ; Enable external interrupt 1
;SETB EA   ; Enable interrupts

MOV R3, #05 ;REPEtion of pattern 
D7:	CALL DESGN7
DJNZ R3,D7	
MOV R3, #05 ;REPEtion of pattern 
D8:	CALL DESGN8
DJNZ R3,D8	
MOV R3, #05 ;REPEtion of pattern 
D9:	CALL DESGN9
DJNZ R3,D9	
JMP LABEL

DESGN7:	CALL ALLON 
CALL DELAY
SETB L1
CALL DELAY
SETB L2
CALL DELAY
SETB L3
CALL DELAY
SETB L4
CALL DELAY
SETB L5
CALL DELAY
SETB L6
CALL DELAY
CALL DELAY	
SETB L6
CALL DELAY	
SETB L5
CALL DELAY	
SETB L4
CALL DELAY	
SETB L3
CALL DELAY	
SETB L2
CALL DELAY
SETB L1
CALL DELAY
RET

DESGN8:	CALL ALLON
SETB L6
SETB L1
CALL DELAY
CALL ALLON	
SETB L5
SETB L2
CALL DELAY
CALL ALLON	
SETB L4
SETB L3
CALL DELAY
RET

DESGN9:	CALL ALLON 
CALL DELAY	
SETB L6
CALL DELAY	
SETB L5
CALL DELAY	
SETB L4
CALL DELAY	
SETB L3
CALL DELAY	
SETB L2
CALL DELAY
SETB L1
CALL DELAY
RET	

CLEAR:	SETB L1
SETB L2
SETB L3
SETB L4
SETB L5
SETB L6
RET

ALLON:	CLR L1
CLR L2
CLR L3
CLR L4
CLR L5
CLR L6
RET

DELAY:	MOV R0,#0FFH
INLOP:	MOV R1,#0FFH
buttonTest:            
;JNB P3.3, buttonTest  ;enable this line wait while pressed
DJNZ R1,buttonTest

DJNZ R0,INLOP
RET
END



ExperimenterUK



Thank u so much sir for your quick response..
sir code which is posted last time by u is working.. but when interrupt occurs then main function do not work.. only led blow continuously.. but i want something else

I'm very sorry sir it was my mistake that i could no explain exact need.

ok i explain what i want to do.

please look this code


MOV R3, #05 ;REPEtion of pattern 
D7:	CALL DESGN7
DJNZ R3,D7	
MOV R3, #05 ;REPEtion of pattern 
D8:	CALL DESGN8
DJNZ R3,D8	
MOV R3, #05 ;REPEtion of pattern 
D9:	CALL DESGN9
DJNZ R3,D9


first design is D7 , there is line MOV R3, #05 it means D7 will repeat 5 time, then D8 will execute, & after that D9,,
suppose D7 is running, and when we press the switch then repetition number of D7 should be infinite means when is switch pressed then only D7 should will execute, and when switch goes its earlier condition means off condition then design will repeat only five time, after it D8 will execute n after D9 by the chip.
this interrupt should work for every design.

sorry for my mistake, i think this is enough explanation..


[ Edited Fri Dec 19 2014, 11:35 pm ]
Sat Dec 20 2014, 03:28 am
#17
For what you want,it is easier to not use interrupts.
If the pattern gets much more complicated,
using an interrupt may be better.

Don't enable interrupts and change your code to this.

MOV R3, #05 ;REPEtion of pattern 
D7:	CALL DESGN7
JNB P3.3,D7 
DJNZ R3,D7	


MOV R3, #05 ;REPEtion of pattern 
D8:	CALL DESGN8
JNB P3.3,D8
DJNZ R3,D8	

MOV R3, #05 ;REPEtion of pattern 
D9:	CALL DESGN9
JNB P3.3,D9
DJNZ R3,D9
 ajay_bhargavsankalp_s like this.
Sat Dec 20 2014, 11:01 pm
#18


For what you want,it is easier to not use interrupts.
If the pattern gets much more complicated,
using an interrupt may be better.

Don't enable interrupts and change your code to this.

MOV R3, #05 ;REPEtion of pattern 
D7:	CALL DESGN7
JNB P3.3,D7 
DJNZ R3,D7	


MOV R3, #05 ;REPEtion of pattern 
D8:	CALL DESGN8
JNB P3.3,D8
DJNZ R3,D8	

MOV R3, #05 ;REPEtion of pattern 
D9:	CALL DESGN9
JNB P3.3,D9
DJNZ R3,D9

ExperimenterUK




Thanks a lot sir, its working,
great support, quick response,thanks admin sir & co admin sir..

i've some queries more about this project..
first one is,
if i using 2051 chip then how can i use ANALOG COMPARATOR for blinking speed control of design by the external controller like potentio meter. and what would be code for it?


[ Edited Sat Dec 20 2014, 11:10 pm ]
Mon Dec 22 2014, 03:46 am
#19


Thanks a lot sir, its working,
great support,

sankalp_s


Thank you.


i've some queries more about this project..
first one is,
if i using 2051 chip then how can i use ANALOG COMPARATOR for blinking speed control of design by the external controller like potentio meter. and what would be code for it?

sankalp_s


The ANALOG COMPARATOR on the 2051 seems to be
just a comparator , that is , not programmable.
You will need extra hardware to use it.

I would suggest adding a 555 timer circuit that generates a
square wave controlled by a pot.
Then just measure the frequency or length of the square waves.



[ Edited Mon Dec 22 2014, 06:05 am ]
Mon Dec 22 2014, 10:22 pm
#20



Thanks a lot sir, its working,
great support,

sankalp_s


Thank you.


i've some queries more about this project..
first one is,
if i using 2051 chip then how can i use ANALOG COMPARATOR for blinking speed control of design by the external controller like potentio meter. and what would be code for it?

sankalp_s


The ANALOG COMPARATOR on the 2051 seems to be



ExperimenterUK


but sir i have seen speed controlling in 2051 chip without 555 ic,
sir my second query is, there are three program in side the code:
for example in program 1st has three design, program 2nd has two design program 3rd has six design,
now i'm using any two pin for call these design. (ie.pin p3.2 & p3.3)
if no any pin is low then only program 1 will be run
if 3.2 then only program 2
& when 3.3 then only program 3
is this possible with JB & JNB instruction?
i've tried but only 1 program works,
could you please give me code for that.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

RodneyKnorb
Thu Apr 25 2024, 07:08 pm
Williamjef
Thu Apr 25 2024, 02:08 pm
SamuelSmise
Thu Apr 25 2024, 09:56 am
DustinErele
Thu Apr 25 2024, 08:44 am
ztaletpzca
Wed Apr 24 2024, 11:19 pm
IrardlPex
Wed Apr 24 2024, 08:42 pm
Charlestehed
Wed Apr 24 2024, 05:20 pm
Robertgurse
Wed Apr 24 2024, 02:43 pm