I see a couple of things that make me wonder, your "Temp" Var should be set to 0 at the beggining before you call "Button", if not "Button" won't work correctly.
Also, you are looking for a switch being closed at rates up to 58 times per second. 1/58 = 17 ms, so ever 17 milli seconds a magnet will sail past your switch, closing it for a moment, then it will re-open. If your magnets cover 50% of the circumference that would give you a 50% duty cycle. So the switch would be closed for 17/2 = 8.5 ms and open for 8.5 ms. In reality, your switch is probably closed about 10 % of the time or 1.7 ms.
In your code :
Code:
Button RB7pin10, 0, 255, 0, Temp, 1, magnetic_switch_closed
You have delay set at 255, this will perform debounce, but no auto repeat.
Default debounce is 10 ms, so the switch needs to be closed for 10 ms before you go to "switch_closed"
You might try a delay of 0, this shuts off the debounce.
Also you can change the debounce delay:
DEFINE BUTTON_PAUSE 1 'set button debouce to 1 ms
1 ms is still cutting it close.
Or you can skip the button all together and just read the port, something like:
Code:
If RB7pin10 = 0 Then switch_closed
You can read the state of the switch again in the "switch_closed" code, if it's still closed continue, if not jump back out. That performes a high speed debounce. You can also use PAUSEUS before you double check, so you can wait a couple of micro seconds then double check the switch is really closed.
Just some idea's.
Shane
Bookmarks