Sei sulla pagina 1di 10

Home - Search - Members

Full Version: if switch connect lik tis can work or not..?


8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes > Project
Development > Project Help
Clown of G0d
Jul 18 2008, 7:13 PM
this is my final project ...
but now the switch button cant work properly...
can anyone help me troubleshoot d problem ...
thx...

CODE:
;REFERENCE
;===============

;P0 = DISPLAY 7 SEGMENT


;P1 = STEPPER MOTOR ROTATION
;P2 = LED DISPLAY
;P3 =   P3.0 = START
;       P3.1 = NO USE  
;       P3.2 = SELECT TIME
;       P3.3 = NO USE
;       P3.4 = NO USE
;       P3.5 = NO USE
;       P3.6 = NO USE  
;       P3.7 = NO USE

;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                        

MAIN:                           SETB            EX0                    


;ACTIVATE EXT INT 0                                             ;ACTIVATE
AXT INTR 0                                                              
;ACTIVATE AXT INTR 1
                                SETB            EA                    
;ACTIVATE GLOBAL INT                                            ;ACTIVATE
GLOBAL INTR
                                MOV             TMOD,#01H               ;SET
TIMER0 16BIT                                              
                                MOV             R6,#11101110B
                                MOV             P2,R6
                                                       
                                                                             

                                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                            

LOOP2:                          JBC             TF0,LOOP3


                                JMP             LOOP2

LOOP3:                          DJNZ            R3,AGAIN

                                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

LP2:                            MOV             P0,A


                                MOV             R5,A
                                DJNZ            R7,PPS
                                CLR             TR0                          

                                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
                               

S15:                            MOV             R7,#15


                                MOV             R5,#15H
                                JMP             PPS
                               
S30:                            MOV             R7,#30
                                MOV             R5,#30H
                                JMP             PPS
                               
S45:                            MOV             R7,#45
                                MOV             R5,#45H
                                JMP             PPS
                               
S60:                            MOV             R7,#60
                                MOV             R5,#60H
                                JMP             PPS    
                                                             
                                                                             

 
;ROTATION DELAY
;================
                                                                             

SDELAY:                         MOV             R0,#200


D1:                             MOV             R1,#200
                                DJNZ            R1,$
                                DJNZ            R0,D1
                                RET                  
                                                                       
;================
                                                             
                               
                                                             
                                                             
;INTR_SELECT
;================
                               
SELECT:                         XCH             A,R6
                                RL              A
                                CALL            SDELAY
L1:                             MOV             P2,A
                                XCH             A,R6
                                JNB             P3.2,$
                                RETI
                                                             

                                END
 

this is my block diagram...


Arun Kumar V
Jul 18 2008, 9:26 PM
Hello Friend,

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 :

JB P3.0,$ ;"START" PUSH BUTTON


JNB P3.0,$
CALL START

causes problems, better change it like this:

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
 

All the Best !

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 ?

Xtal and ceramic caps are Non-polarised.

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...

hope anyone can help mi...


tis is my 1st project...
if need any information pls tell mi...
thk^^

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.

make this connection and possibly the project should work

[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,

1) you have to connect +12V to stepper's common.

2) bit Sequence is correct.

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).

values for 50mS delay for TMR0 in mode1

TH0 = 3Ch
TL0 = 0B0h

Arun

Arun Kumar V
Jul 26 2008, 8:49 AM
here's how to use ULN2803/ULN2003 with Stepper :

be sure that the stepper motor is rated </= 500 mA


Arun

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

Potrebbero piacerti anche