Self triggering Issue

Andrei IRL

Senior Member
Hello everyone.

I have a very strange issue that i am trying to understand and possibly fix.

For some reason, some times part of my code that should only trigger upon receiving HIGH signal gets triggered by itself.

I am using latest PICAXE 08M2+ chip.

The device is used on a motorcycle and is powered by the bikes on-board power.

I have attached the circuit diagram.

I am using LM7812 and 78LM05 as i require dual voltage.

So the power gets regulated twice before getting to the PICAXE.

I am using two electrolytic caps on the either side of the LM7812 Regulator, 22nF and 10nF or something around these values.

Below is the part of the code thats running continuously on the CHIP.

Code:
main:       high greenled	
		if pin3=1 then fire 
		
	ReadAdc 1, b5
	Select Case b5
  		Case > 144 : Goto BothPushed
  		Case > 106 : Goto Plusone
  		Case > 42  : Goto Minusone
  	End Select

			
goto main
The Code is monitoring input on PIN3, and should only trigger when PIN3 goes HIGH.
This is the part that gets randomly triggered randomly. It happens rarely but still does.

ReadAdc is monitoring input from two buttons connected in Voltage divider configuration.

I have attached circuit diagrams i am using for the power supply as well as the main circuit itself.

PIN3 has a 10K Pull Down resistor as part of the voltage divider so i really dont understand what triggers the input into thinking its HIGH?

Many thanks in advance.

Circuit1.JPG
Circuit2.JPG
 

hippy

Technical Support
Staff member
Vehicles can be an electrically noisy environment so it could be that a signal is being induced on to the wiring to PRX (pin3). Does the self-triggering stop if you disconnect the "PRX" connection ?

You may be able to improve things by ignoring short pulses on pin3, by checking it has gone high and is still high some time later, rather than just doing a single check for high.
 

Andrei IRL

Senior Member
Vehicles can be an electrically noisy environment so it could be that a signal is being induced on to the wiring to PRX (pin3). Does the self-triggering stop if you disconnect the "PRX" connection ?

You may be able to improve things by ignoring short pulses on pin3, by checking it has gone high and is still high some time later, rather than just doing a single check for high.
Thanks very much for the reply hippy.

Proximity sensor is normally connected to PRX (PIN3) input.

I did experience the triggering even with the Proximity sensor disconnected from the PRX (PIN3) input.

Unfortunately this application is time dependent and i require for the PICAXE to react to in inputs on PIN3 without any noticeable delay.

What would be the shortest time i would need to monitor the input on PIN3 that i could get away with would you think?

What would be the best command to use to perform this check hippy?

Thanks very much for your help.

Its much appreciated.
 

hippy

Technical Support
Staff member
What would be the shortest time i would need to monitor the input on PIN3 that i could get away with would you think?
That is hard to say. The best thing to do would be to write a test program which monitors the pin, sets a LED when triggered, then adjust the trigger detection until there are no false triggers.

It may be possible to use the BUTTON command to do the detection or one could check the pin, PAUSE and check again, or check while repeatedly looping ( which is what the BUTTON command would be doing ).

How long should the proximity pulse or signal last normally, what does it monitor ?
 

Andrei IRL

Senior Member
Thanks very much for the ideas, i will test them.

The proximity sensor is constantly monitoring a metal object, as soon as the object is detected the signal is sent to PICAXE, the metal object will continue moving towards proximity sensor until PICAXE receives the signal about it.

I will write a test program and test both PAUSE and BUTTON commands.

Thanks very much again.
 

hippy

Technical Support
Staff member
The proximity sensor is constantly monitoring a metal object, as soon as the object is detected the signal is sent to PICAXE, the metal object will continue moving towards proximity sensor until PICAXE receives the signal about it.
That's all a bit vague to me. From "if pin3=1 then fire" in your code is this part of an ignition system, rocket launcher ?

The more detail you can give on what the full project is the easier it will be to see what else may be in the program, what challenges there are, and what the better solutions may be, what problems certain solutions may have.
 

Andrei IRL

Senior Member
That's all a bit vague to me. From "if pin3=1 then fire" in your code is this part of an ignition system, rocket launcher ?

The more detail you can give on what the full project is the easier it will be to see what else may be in the program, what challenges there are, and what the better solutions may be, what problems certain solutions may have.
haha, rocket launcher i wish...

Sorry i was just trying to explain in the previous post with out going into too much detail.

This device is part of an ignition system interrupt. So basically when a metal rod comes in contact with the proximity sensor PICAXE disables the ignition for a pre-determined length of time through a set of relays.

I have made some changes to my code using your advice, i have added another routine FIRECHECK which checks the signal on PIN3 few miliseconds after it hase been detected for the first time.
After that the program jumps to FIRE sub routine if signal is still there.

Code:
main:       high greenled

		if PIN3=1 then firecheck
		
	ReadAdc 1, b5
	Select Case b5
  		Case > 144 : Goto BothPushed
  		Case > 106 : Goto Plusone
  		Case > 42  : Goto Minusone
  	End Select

			
goto main

firecheck:	pause 10
		if PIN3=1 then fire
goto main

fire:	     	
		high relay1
goto main
 

The bear

Senior Member
Hi Andrei,
Have you got a 'scope? Its a very noisy environment you are working with.
I would try adding more capacitors, maybe a choke, sorry don't know what value.
You would have to study power supply information, its all very complicated.
Good luck, bear..
 
Last edited:

Andrei IRL

Senior Member
The bear:312721 said:
Hi Andrei,
Have you got a 'scope? Its a very noisy environment you are working with.
I would try adding more capacitors, maybe a choke, sorry don't know what value.
You would have to study power supply information, its all very complicated.
Good luck, bear..
Thanks very much for your help.
I have an old analog scope.
Haven't really used yet properly.
What exactly am i looking to check with the scope?
If you give me a little crash course on what to check and what to expect to see on the scope.
I think i am ok setting it up.

I Will add another 10nf cap directly at the picaxe power pins also.

Thanks very much for your hell
 

erco

Senior Member
Self triggering issue? Stop that before you go blind... :)

Seriously, your bike is a very noisy environment and all wires (incl spark plug wires) are dangerously close to each other. The wire carrying the signal into pin3 is a long antenna picking up all that stray RFI. You can try shielding the wire, or reducing the value of your 10K pulldown resistor, it might need 1K or even less. You could also try a filter capacitor from pin 3 to ground to bypass noise, maybe 0.1-1 uF.
 

Andrei IRL

Senior Member
erco:312723 said:
Self triggering issue? Stop that before you go blind... :)

Seriously, your bike is a very noisy environment and all wires (incl spark plug wires) are dangerously close to each other. The wire carrying the signal into pin3 is a long antenna picking up all that stray RFI. You can try shielding the wire, or reducing the value of your 10K pulldown resistor, it might need 1K or even less. You could also try a filter capacitor from pin 3 to ground to bypass noise, maybe 0.1-1 uF.
Thanks very much.
I will indeed reduce resistor values for the voltage divider .
I Will try the small cap at pin 3.
Thanks very much for the suggestion.
 

The bear

Senior Member
Hi Andrei,
'Scope, internet for info.
Basic, scope your supply rails, you are looking for 'noise' which manifests itself as fuzz.
With the 'scope switched to AC, Y axis ~1volt ish. If your supply rails are good (Clean), the trace should be a thin horizontal line.
Can you test it with the engine running?
Good Luck, bear..
 

hippy

Technical Support
Staff member
Pin 3 (leg 4) on an 08M2 is also a pin which does not have clamping diodes fitted internally to the chip. This may make it more susceptible to higher voltage EMI than other pins.

It might be worth adding external clamping diodes to that pin; one will be cathode (pointy-end) to V+, anode to leg 4, the other, cathode to leg 4, anode to 0V.
 

Andrei IRL

Senior Member
Thanks very much bear and hippy.
I think i have great information to set me on the right path.

Thanks very much for taking the time to help.
 

hippy

Technical Support
Staff member
Hippy. Which diode would be best suited for clamping as suggested?
Analogue electronics isn't my speciality so I am not sure. I would normally use 1N4148 for clamping voltages, but there might be benefit in using a BAT85 or similar Schottky diode. Hopefully someone more experienced will throw their two-penneth into the ring.
 

AllyCat

Senior Member
Hi,

Yes, normally one would use Schottky (lower forward voltage drop) diodes to ensure that any current flows in them and not the chip's internal diodes. But as Leg 4 (pin c.3) doesn't have a diode there, then a 4148 (or almost anything) should be good enough.

Personally, in such an environment, I would put a capacitor of 10nF - 100nF directly on the PICaxe pin to ground for any "external" input. Then a resistor, perhaps as high as 10k and maybe a ferrite bead (inductor) as well, in series with any input wire. Of course any pull-down resistor directly on a PICaxe pin must have a higher value than the series resistor.

If the "noise" is principally fast, short duty cycle "spikes" then simple "majority decision" code may be good enough (and wise in such an application anyway). For example:

Code:
if pin3=1 then
   if pin3=1 then fire
else
   if pin3=0 then fallthrough
   if pin3=1 then fire
endif
fallthrough:
Cheers, Alan.
 

Andrei IRL

Senior Member
Thanks very much hippy and Alan for some additional information.

Your time and help is much appreciated.

I have modified the code, added 1N4148 clamping diodes and also added 1nF Cap to the Leg4.

Also i have lowered the values of the resistors for my Voltage divider for the input on Leg4.

Hopefully it'll sort out the issue i am having.

Andrei,
 
Last edited:

Goeytex

Senior Member
@Andrei

With a noisy electrical system such as may be found in certain motorcycle electrical systems, it may be advisable to use a "transorb" diode to suppress electrical noise at the regulator.

But are are you sure that it is actually "self triggering". What I mean is are you assuming that pin 3 is going high because the relay(s) seem to energize? Did you monitor pin 3 and actually see it go high? The reason I bring this up is that years ago I developed a Picaxe based Rev-limiter for racing go-karts and had a similar issue. After a bit of head scratching, the problem was traced down to vibration / g-forces, where hard bumps (Gs) and vibration caused the relay contacts to seemingly intermittently and randomly bounce closed. The relay was not rated for the extreme conditions. It was a cheap relay. The problem was resolved by replacing the relay with a TRIAC to shunt the primary ignition signal to ground.

A similar method is shown in U.S. Patent 5138996


Does the problem show up on the bench with a bench power supply? Or did you develop it on the bike with no bench prototyping?

To "prove" that the input pin is actually going high and that is is not relay contact bouncing you may want to consider writing some test code that logs the state of the input pin while taking the bike around the course. Do this with the relays disconnected from the system.
 

Andrei IRL

Senior Member
@Andrei

With a noisy electrical system such as may be found in certain motorcycle electrical systems, it may be advisable to use a "transorb" diode to suppress electrical noise at the regulator.

But are are you sure that it is actually "self triggering". What I mean is are you assuming that pin 3 is going high because the relay(s) seem to energize? Did you monitor pin 3 and actually see it go high? The reason I bring this up is that years ago I developed a Picaxe based Rev-limiter for racing go-karts and had a similar issue. After a bit of head scratching, the problem was traced down to vibration / g-forces, where hard bumps (Gs) and vibration caused the relay contacts to seemingly intermittently and randomly bounce closed. The relay was not rated for the extreme conditions. It was a cheap relay. The problem was resolved by replacing the relay with a TRIAC to shunt the primary ignition signal to ground.

A similar method is shown in U.S. Patent 5138996


Does the problem show up on the bench with a bench power supply? Or did you develop it on the bike with no bench prototyping?

To "prove" that the input pin is actually going high and that is is not relay contact bouncing you may want to consider writing some test code that logs the state of the input pin while taking the bike around the course. Do this with the relays disconnected from the system.
Hi Goeytex.

Thanks very much for your post.

The reason i know it was self triggering is the fact that i have an LED connected to the Same output as the relay and i saw it flash.

Also, when pin3 goes high PICAXE is programmed to activate the relay for a certain time.

When i experienced self triggering it happened when it was running from the bike electrical system with the bike idling and the relay and LED got activated for the exact duration of

what was programmed into the chip.

Also, i am using top of the range automotive relays by TYCO.

Could you provide any more information on using TRIAC in place of a relay please?
 
Top