# Picaxe trigger sensitivity problem....



## Manor Matt (Sep 17, 2007)

*Picaxe trigger sensitivity problem....*SOLVED**

Hi all,

I'm having a trigger problem with one of my picaxe setups. I am using an IR breakbeam (IR Breakbeam) to close a relay connected to a 2pin connector, through a 2 connector wire, and the other end goes to the picaxe trigger input. The IR runs on a 9v batt, and the picaxe on a 12v wall wart (the 9v snaps to a holder mounted under the IR board). The relay contacts are not connected to any power source, open or closed. If I directly jump the trigger pins @ the picaxe, it triggers fine. With the IR connected, it will trigger occasionally when the beam is broken, but if I touch a slightly-moistened finger to the trigger wire insulation, it will trigger immediately 'every' time. I have tried connecting the 2 negative sides of the battery & wall wart, but it still happened the same way (connected with direct wire, no resistor). This is driving me crazy, I've spent 1/2 the day today trying to get this to trigger consistantly & correctly.

Here's a pic of the IR board & the picaxe board, the single horizontal orange/red wire is the temporary trigger wire (for testing, the actual trigger wire pair is about 4' long). Touching this wire anywhere (red, orange, middle, either end, etc) will trigger the picaxe.










Does anyone have any ideas on what to check / try next ?!?

I'm running out of time !!


----------



## HalloweenRick (Nov 25, 2005)

I think you may have too much power going to the PICAXE chip. The chip itself only needs 4.5v (3 AA Batteries) to power it. The 12v wall wart can be used to the outputs, but the chip needs to only have the 4.5v, and it should be a regulated 12v wall wart. I see the MOSFET relay- but the your wording above makes that sound like its from the PICAXE to the IR beam? Also if you could post your code for your PICAXE, you may have a "switch bounce" issue. Hope that helps.


----------



## Manor Matt (Sep 17, 2007)

sorry, I should have been more detailed, the picaxe board has a MOSFET to take any input power and regulate it to 5v for that board (I just happened to have a 12v wart plugged in at the moment for power).

Here's part of my code for triggering:

'*********[ Program code ]***********************************
setint %01000000,%01000000 ; sets interrupt pin (C.6), watches for value = 1 (sent from break-beam trigger), 
; jumps to "Interrupt" when triggered.

Main:

'debug

let dirsB = %11111110	; set pin 0 as input and pins 1,2,3,4,5,6,7 as outputs

random timer ; seed w0 with random #

goto main ; loop return

Interrupt:

if pinC.6 = 1 then Interrupt ; checks if trigger is still active and loops back until not active
pause 200
if walk_style <= 85 then gosub Running ; checks value of w0 bit b0, if 85 or less runs "Running" sequence
if walk_style >= 86 and walk_style <= 170 then gosub Skipping	; checks value of w0 bit b0, if 86 to 170, runs "Skipping" sequence
if walk_style >= 171 then gosub Walking ; checks value of w0 bit b0, if above 171, runs "Walking" sequence

; interrupt cleared

setint %01000000,%01000000 ; re-activate interrupt

return ; return from interrupt sub


----------



## HalloweenRick (Nov 25, 2005)

Lets talk about this section here:

setint %01000000,%01000000 ; sets interrupt pin (C.6), watches for value = 1 (sent from break-beam trigger), 
; jumps to "Interrupt" when triggered.


Main:

'debug

let dirsB = %11111110 ; set pin 0 as input and pins 1,2,3,4,5,6,7 as outputs

random timer ; seed w0 with random #

goto main ; loop return


To clarify: Is your input( the IR Beam) hooked up to pin 0 or pin 6? If its hooked up to pin 0, thats an analog input, and I'd try to move that input to pin 3. If it is hooked up to pin 6, then I think your code is fine. I would almost think your culprit would then be that relay on your IR Beam, but that would be a guess if your input is correct. There are some real good PICAXE guys here (Otaku, JeffHass and Fritz42 among others) that you could PM.


----------



## Otaku (Dec 3, 2004)

I'm not really a PICAXE user, but I might be able to help. Is it possible to use a pull-down resistor, say 10K, on the IR beam input? That would hold it solid to ground until a high signal comes through. I do this for external 5VDC triggers on BS2 OEM controllers, helps prevent those annoying false triggers.


----------



## Manor Matt (Sep 17, 2007)

the trigger input on the picaxe is on pin C.6, the code that set the pins as input or outputs was 'old code' when I was going to try to use an analog input. I'm only using C.6, and the output pins for lighting LEDs is B.1 through B.7 (nothing's on B.0). This is a picaxe 18M2 chip.
I'm just not sure why I can trigger it consistently just by touching anywhere on the trigger wire's insulation with my finger (not touching any other part of either board). One pin of the trigger pin pair is 5v (tapped from same supply as V+ pin of picaxe) and other is to common ground. 
Otaku, so the 10k pull-down resistor suggested would go from pin C.6 to ground, correct ?


----------



## Manor Matt (Sep 17, 2007)

Thanks to Steve-O from the Garage of Evil for a fix, I'm tapping the 2 leads from the tiny red LED on the IR board (lower right corner of green Velleman board in picture) to run to the Picaxe trigger pins instead of using the relay. I also added the 10K resistor from pin C.6 ground. No false triggers, and triggers by breaking the beam every time now.


----------



## Otaku (Dec 3, 2004)

If pin 6 is the IR beam trigger input, then yes. Inputs can be pulled down, but not outputs. The triggering you're seeing when you touch the wire is probably the result of stray capacitance. It's how those touch-on, touch-off lamps work.

Edit - posted this just after your update. Good to hear the problem is solved.


----------



## Dead Things (Apr 4, 2009)

I feel your pain. I spent an entire Saturday trying to figure out why the Picaxe wouldn't download. There is some good info on switches and "debounce" in picaxe manual one, around page 60. As well, the Picaxe forum has been invaluable to me (I will never get that Saturday back). If you post, they like as much info as possible, complete code, links to the IR Breakbeam data sheet, etc. 10K goes between pin and 0V


----------

