If you are setting the configs in code space comment that line out.
Dave
Always wear safety glasses while programming.
Hi Dave, yes thats it.
When I delete the first 2 lines "define ocs" and "@...", both codes compile ok.
Unfortunately, the behaviour is basicaly the same....they start with led off, and it should be on, more over, the counting is not regular, it depends in the speed of the click.
Some times, it goes off at 3, others at 5...etc....
I dont know....it is very over me.
I have tried to cut here and there taking ideas from both codes, but it does not work either.
I have to mention, that the clicks will be very fast, we could have posibly.......20 clicks per second, but we need to stop the mosfet after counting 3 clicks, hence the pause for 1 second.
I am sorry, my spanish brain is too tyre and can not speak properly.
Thanks for helping me guys.
Much appreciated.
Best regards.
You might not need the
DEFINE OSC 4
but it is a good idea to put it in. That is the line that tell PBP how fast the chip is running. I assume you are using the 4MHz internal.
The state of the mosfet/led depends on how you have the hardware setup. Just change the LOW/HIGH around to do what you want.
Like I said before. This will need a good denouncing routine to work correctly. Now that you say the button could be pressed at 20HZ even more so. What is going to press a button that fast?
Here are a couple of threads that might help you.
http://www.picbasic.co.uk/forum/showthread.php?t=13516
http://www.picbasic.co.uk/forum/showthread.php?t=2180
Read them all the way through.
Dave
Always wear safety glasses while programming.
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.
************************************************** ***********************
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