Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pushbutton problem.pls help.

Status
Not open for further replies.

prinsloo

Member level 5
Joined
Sep 19, 2004
Messages
93
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Location
Bethlehem RSA
Activity points
697
Dear Members

The code at the bottom is for a pushbutton to control a light.The problem that I have is that when the button is pushed it connects the micro to ground.This STOP the program.

When I leave it open then the program START (out of controll).
I want the program to activate when I push the button once and not run out of controll.


ORG 0
goto start__code

ORG 4
_interrupt
bcf INTCON, T0IF ;clear interrupt flag
retfie

start__code
_main__code
movlw D'192'
bsf STATUS, RP0
movwf _option_reg
label_0006
bsf STATUS, RP0
movf TRISB, W
iorlw D'16'
movwf TRISB
bcf STATUS, RP0
movf PORTB, W
andlw D'16'
sublw D'16'
movlw 1
btfss STATUS, Z
clrw
movwf _FCV_KEY
movf _FCV_KEY, W
btfsc STATUS, Z
goto label_0006
label_0008
goto label_0006
label_0007
_mainendloop
goto _mainendloop
_main__end
const_ptr_data
END

Thanks in advance
 

It is possible that the problem is not in your code but in your hardware connection be sure to use pull-up or pull-down resistor to maintain input logic.
 

you need to use code tags when posting you code so it will be easily readable for others to help you. Before pasting your code, click on the code button beside the quote button.

You should do a google search or search this forum for the word "debounce" or "switch debouncing".

I think that may be your problem.

Good Luck
 

could you please post your complete program? (_fcv_key definition missing) also can you post your schematic???

Why don`t you just
Code:
btfsc PORTB,4
to ask the bit???
also, why you use 2
Code:
goto lable006
???anyway when you'll push your button it will roll over and over...

also don't forget to turn off the Watchdog... and which PIC you said you are using??? (Oh my! you didn't said!!!!)
 

Dear Members

The problem is with the software.I have to keep a NEGATIVE pulse on the Pic in order for it to STOP the program. This is a program for a pedestrian crossing-if you push the button the lights must change and after one completed sycle it must WAIT for the button to be pressed again.

I need it to sense ONE negative pulse in order for the software cycle to run once.

Thanks
 

Try to modify your connection as the picture which i upload
and post ur result to help u

52_1184443080.jpg
 

use some delay......
 

first! you need a pull-up resistor for your push button!!! if you don`t put it... the PIC will act strange!!!!

and.. .could you post THE ORIGINAL SOURCE!!! not the c2c generated ASM-file... And why do you use c2c??? (sorry, I don't like c2c)
there are many ways to do it nicely in asembler or in C (use cc5x or ccs, IMHO they are better) but don't mix them that way...
 

Dear Members
Thanks for the response so far.I have attached ALL the files I have on this project.The push button have a resistor-1k-to earth or negative.

I don't know assembly language-these file was created via CROCODILE TECHNOLOGY program.(flow code)

The c-language file was also created via the same program.
I have managed to stabelise the program-while there is a negative on the INPUT the program waits for the nagative to be removed-then it change the lights.

For this to happen I must keep the push button close.This will keep a negative on the INPUT and the lights wont change.

I want to use a NORMALLY OPEN switch not a NORMALLY CLOSE switch.

Any idees on how to solve this problem will be awarded.

Thanks in advance
Johan
 

Can anybody please assisst me? I uploaded all the files I have.

Regards
Johan
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top