8051 With Switch
8051 With Switch
8051 With Switch
CODE:
;REFERENCE
;===============
;R0 = SDELAY
;R1 = SDELAY
;R2 = NO USE
;R3 = DJNZ PURPOSE
;R4 = HOW MANY ROTATE TIME
;R5 = 7 SEGMENT COUNT DOWN
;R6 = LED
;R7 = 7 SEGMENT DECREASE PURPOSE
;================
ORG 0000H
JMP MAIN
ORG 0003H
JMP SELECT
JB P3.0,$
;"START" PUSH BUTTON
JNB P3.0,$
CALL START
START: SETB TR0 ;SET
THE TIMER0 TO RUN
JNB P2.0,S15
;INTR_SELECT 15SEC FEED FISH
JNB P2.1,S30
;INTR_SELECT 30SEC FEED FISH
JNB P2.2,S45
;INTR_SELECT 45SEC FEED FISH
JNB P2.3,S60
;INTR_SELECT 60SEC FEED FISH
PPS: MOV A,R5
MOV P0,A
MOV R3,#50 ;1SEC
MOV R4,#20 ;HOW
MUCH FOOD FOR FEED
AGAIN: MOV TL0,#8BH ;SET
TL0'S VALUE
MOV TH0,#0B8H ;SET
TH0'S VALUE
DEC A
CJNE A,#0FH,DD1
SUBB A,#06H
DD1: CJNE A,#1FH,DD2
SUBB A,#06H
DD2: CJNE A,#2FH,DD3
SUBB A,#06H
DD3: CJNE A,#3FH,DD4
SUBB A,#06H
DD4: CJNE A,#4FH,DD5
SUBB A,#06H
DD5: CJNE A,#5FH,LP2
SUBB A,#06H
MOV A,R2
SMOTOR:
MOV A,#10101010B
;STERER MOTOR CODE1
MOV P1,A
CALL SDELAY
MOV A,#10011001B
;STERER MOTOR CODE2
MOV P1,A
CALL SDELAY
MOV A,#01010101B
;STERER MOTOR CODE3
MOV P1,A
CALL SDELAY
MOV A,#01100110B
;STERER MOTOR CODE4
MOV P1,A
CALL SDELAY
DJNZ R4,SMOTOR
JMP START
;ROTATION DELAY
;================
END
Yes, it is the correct way of connecting a switch to a micro,you have defined 2 switches in your
code,
one for start and other for time
p3.0 = START
P3.2 = SELECT TIME
but you are not checking the status of P3.2 anywhere in the program, secondly,
your instruction :
CODE:
JB P3.0,$ ;"START" PUSH BUTTON
LCALL DEBOUNCE_DELAY
JNB P3.0,$
CALL START
CODE:
DEBOUNCE_DELAY:
MOV R1,#255D
Q1: MOV R2,#255D
Q2: NOP
DJNZ R2,Q2
DJNZ R1,Q1
RET
Arun
Clown of G0d
Jul 20 2008, 12:47 AM
but i connect all the thing in test board it can work....
when i connect all the thing with my hardware...it cant work adi...
then i connect the 8952 at test board then connect 7 segment, push button, stepper motor and
LED to my hardware it can work...
i dunno where get wrong...
em...
cystal & capasistor(ceramic) dun hav positive and negative side right...?
Arun Kumar V
Jul 20 2008, 4:55 AM
Hi friend,
you mean to say that your project works on Bread board(test board) and not on normal vero
board/PCB ?
Can you pl.send the photos of your setup i,e your breadboard and PCB where you are testing the
project.
Arun
pdi33
Jul 20 2008, 7:33 AM
ur circuit does not show EA/VVPP terminal connected to VCC which is necessary for the uC to
take the internal program memory. just check if ur PCB has the appropriate track for it.
Clown of G0d
Jul 24 2008, 7:38 AM
sorry...
now a day bz for exam...
last time i told test board is a set of test board...
if u put 8952 inside u can test LED, dot martix, 7-segment ....
****
the problem soft adi...
so... i take back my pic....
****
Clown of G0d
Jul 24 2008, 8:01 AM
hope u all can understand my pic^^i dunno what problem now...
i use my school test board then connect to pic 1 tat hardware can use...
when i connect all together tat mean pic1 + pic3 the switch got problem...
LED, 7-segment ( part1, part2) can use...
now the problem is the switch (part3) problem...
when i push the white button " start" it no work....
then all LED bright together...
pdi33
Jul 24 2008, 9:42 AM
hi C-O-G,
It is very difficut to see clearly ur PCB tracking, but i think u have still not connected the pin
31(EA/VPP) of 89s52 to VCC. please confirm that first as it is very neccesary for the working of
the circuit.
:-) .
Arun Kumar V
Jul 24 2008, 11:37 AM
Hmmm..... Yup, feels like you haven't connected the Pin 31(EA) to VCC, the copper side of the
board doesn't show solder bumps at pin 31.
with out this connection the micro won't fetch the code from the internal ROM.
[Camera Tip : use Macro ON for shooting close objects between 10-15 cms, this gives you clear
pics instead of blurred images]
Arun
Clown of G0d
Jul 24 2008, 12:42 PM
emm...
wat is the purpose for pin 31....
pdi33
Jul 24 2008, 12:50 PM
hi C,
well,in 8051 u can fetch the program instructions in two ways,one is from the inbuilt flash
program memory by pulling it high to VCC and the other method is to fetch it from the external
ROM /EPROM memory by interfacing the uC to it using the address /data lines .the second
method is used usually if the program meory size exceeds ur inbuilt memory size.so if u do not
connect the ea/vpp to vcc, the uc will seek some external program memory which is not
exsisting. so my dear freind, do connect it to VCC. got it?
Clown of G0d
Jul 24 2008, 2:08 PM
thx...
got adi...
all can run adi...
thx arun and pdi33 much much..... :-)
but last week i present about tis assignment adi...
get low marks...><
can i ask another question about this project....
if i wan increase my stepper motor to 12v
then i use transitor N3904 better or N2222...
my idea is use uP give a small current to transistor then turn on the motor....
(if giv current continuance to stepper motor for a long time (1 day) ....the motor will very hot...i
scare the motor will burn...)
or hav any suggestion to this problem....?
Arun Kumar V
Jul 24 2008, 7:53 PM
Hi friend,
you can use Darlington driver array like ULN2803 which has got 8 Channels to drive a Stepper,
infact you can drive two steppers with one ULN2803.
Arun
Clown of G0d
Jul 26 2008, 12:30 AM
i wan to giv 12v at ULN2803 or common stepper motor...
em..
the code of steper motor correct or not...
1000
0100
0010
0001
then repeat again....
i refer to book...the time of timer no very accurate....
can suggest how to calc timer for 1sec...
12mHz Xtal...
Arun Kumar V
Jul 26 2008, 7:51 AM
Hi COG,
3) load timer with 50 millisec values and increment a counter for 20 times inside the timer ISR to
get 1 sec delay ( 50mS X 20 = 1000mSec).
TH0 = 3Ch
TL0 = 0B0h
Arun
Arun Kumar V
Jul 26 2008, 8:49 AM
here's how to use ULN2803/ULN2003 with Stepper :
Clown of G0d
Jul 26 2008, 3:34 PM
thx.....
Ajay
Jul 28 2008, 9:21 AM
also check the stepper motor tutorial for programming and connections.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.
Rickey's World © 2003 - 2007