Hi dave,
Thanks for your help, I will have a look at the links later.
Yes you are right, I am using the internal oscillator at 4 mhz.
The botton is pressed by a piston.
So I need to stop the piston after 3 pulses.
Thanks.
Hi dave,
Thanks for your help, I will have a look at the links later.
Yes you are right, I am using the internal oscillator at 4 mhz.
The botton is pressed by a piston.
So I need to stop the piston after 3 pulses.
Thanks.
Is it really a button type switch or some other kind of sensor?
I ask because a mechanical switch may not be the best at high speeds.
And the way you have the code implies the button is pulled high and at button press goes to zero volts. This can cause arcing as the contacts open giving the chance of several "make/breaks" on each press.
If the switch were wired pulled low and pressing it brought it high then the arcing is almost not a problem.
Just thoughts....
Dave
Always wear safety glasses while programming.
yes the idea is a proper botton switch, the wired to pull it low it is some thing that i dont understand.
The voltage for the circuitry is 5v....amperes very little, I think is not going to be a problem.
I am more concern with the switch being able to work at that speed...i dont know...i rather first understand the code, see what it should be, have something that i can built my proptotype on, and then see pros and cons.
Otherwise this can be very long...
Thanks for the help guys.
Best regards.
You should ALWAYS assume EVERY mechanical contact switch bounces. The effects can be made less with tricks like DAVE suggests, and with higher quality snap type switches. But heres the thing: as 1 contact approaches the other, they WILL arc. The arc is the "bounce" this happens when opening and closing. Also, switches HATE DC. So if you want this to work for any lengh of time, be certain the switch is DC rated. DC causes the contacts to "plate" and then the bounceing gets worse until the switch quits all together.
Not a bad approace at all. Good luck!I am more concern with the switch being able to work at that speed...i dont know...i rather first understand the code, see what it should be, have something that i can built my proptotype on, and then see pros and cons.
Otherwise this can be very long...
Thanks for the help guys.
Best regards.![]()
-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!
# 20 updated to our friend's desires ...
Alain
************************************************** ***********************
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 " !!!
*****************************************
hi, the code works fine under slow speed, it will count up to 3 and go off the led for 1 s, then on back again.
Please see actual code.
I need much faster reading from the pic, other wise, it will count moreto go off, on breadboard, it may not even go on again.Code:DEFINE OSC 4 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 ' Slow Things down GOTO Detect '****************************************************************************** Pressed: ' Some > 10ms press detected IF cnt <=1 Then 'tocount uptu 3, bigger values will add up. cnt = cnt + 1 ELSE cnt = 0 LOW mosfet PAUSE 1000 high mosfet ENDIF WHILE !Boton : WEND ' Wait Boton release !!! goto detect END
For some oscure reason, my Pbasic compiler, does not like the configuration line you put, after the OSCAL SETTING, in line one.
So I have to set it manualy, using software configuration bit facility.
See my circuit, but, instead of 2 only one led, on GP1, and Push boton on GP2.
Best regards.
Thanks Acetronics.
Last edited by gutisie; - 26th September 2010 at 13:21.
************************************************** ***********************
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