so please confirm:
test should have "goto check" instead of "return"?
so please confirm:
test should have "goto check" instead of "return"?
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Yes
that pretty much does it for me today. Too many DOHS.
Dave
Always wear safety glasses while programming.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
hi guys,
thanks all for your help, but no luck so far, before the last suggested changes, the code will just stay on forever.
Now, with the ANSEL part, just wont compile, it says "syntax error".
Removing the ansel part, it compiles, i run it and after the boton is pressed it jumps direct to the last part of the code (off_led/off_mosfet)
This is my actual code:
Any sugestions?Code:cnt VAR BYTE boton VAR GPIO.2 mosfet VAR GPIO.1 CMCON = 7 'Ports Output mosfet Input boton cnt=0 CHECK: high mosfet IF boton = 0 THEN TEST GOTO CHECK TEST: cnt = cnt + 1 IF cnt = 3 THEN OFF_MOSFET GOTO CHECK OFF_MOSFET: cnt = 0 low mosfet pause 1000 GOTO CHECK end
Much appreciated, and thanks again.
Having no idea what your circuit looks like, my first guess is your button is bouncing. So when you press it, the pic sees any number of presses during that short time between starting to make contact and fully pressed. To test, add a pause in the "test" :
TEST:
pause
cnt = cnt + 1
IF cnt = 3 THEN OFF_MOSFET
GOTO CHECK
I don't know the exact format of pause, but set it for something big like 100mS. That way for every button press, execution waits to allow your finger to catch up with the pic.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Thanks, My circuit is just real pic simulator, so no circuit yet.
but it should be something like a push boton normaly open, and a led with the resistor.
I think it is the ansel thing, to set things digital.
Excuse my ignorance....but if there is a newbie, my level is the same as the pet, of the pet of the newbie.
Well, thanks again for your help guys.
I will keep doing as you say.
Thanks.
-Bert
The glass is not half full or half empty, Its twice as big as needed for the job!
http://foamcasualty.com/ - Warbird R/C scratch building with foam!
Nope, I made one of my many mistakes. I was planning to give the OP a basic working code like I just did for something to "start" with. Then if needed try to do a little "teaching".
Seems like a simple operation, but to make it work well some sort of de-bouncing and maybe an interrupt will be needed.
Dave
Always wear safety glasses while programming.
Hi,
May be that one ???
AlainCode:'**************************************************************** '* Name : Bôton.BAS * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 17/09/2010 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** DEFINE OSC 4 DEFINE BUTTON_PAUSE 10 ' 10 is default value @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF cnt VAR BYTE delay var byte boton VAR GPIO.2 mosfet VAR GPIO.1 ' ANSEL = 0 '12F675 for test CMCON = 7 OPTION_REG.7 = 0 'Pullups enabled WPU = %00000100 cnt = 0 GPIO = %00000110 ' Nosurprise startup ... TRISIO = %00000100 '****************************************************************************** Detect: 'Button presses W/Debounce ' delay = 0 BUTTON Boton ,0,255,0,delay,1,pressed Pause 20 ' Slow Things down GOTO Detect '****************************************************************************** Pressed: ' Some > 10ms press detected IF cnt < 3 Then cnt = cnt + 1 ELSE cnt = 0 LOW mosfet PAUSE 1000 ENDIF WHILE !Boton : WEND ' Wait Boton release !!! goto detect END
Last edited by Acetronics2; - 18th September 2010 at 14:42. Reason: Inverted Mosfet on/Off
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks