18m2 timer cutting out

steviejay

Member
Hi
I have a timer for the kontiki using 18m2, and two reed switches, built on a kiwipatch board. The timer activates an auto relay.One of the reeds is solely to interrupt at at any time, the other reed moves through three different timer settings, activating when the magnet is removed..

It is however cutting out randomly when in use. What I have checked: I thought perhaps connections resetting the picaxe so checked everything. Seems ok.

Im thinking maybe current going to the 12v kontiki motor(2x7AH gel batteries) is affecting current passing thru the LM7805? Or perhaps the 100nF caps across the reeds are an issue? I dont have a schematic but attachng a picture of the timer and the code. Or perhaps I have made a mistake encasing the thing in resin(I flooded and wrecked the last timer)

Any suggestions would be appreciated.

Thanks
Steve
Code:
setint %10000000,%10000000 'interrupting any timer setting on first reed

main:
sertxd ("back at main ",13,10) ' communicate with the pc for testing

pause 50      'pause for 50 ms
high B.4    'flash the end LED output B.4
pause 500            
low B.4
pause 500
wait 1

if pinc.2 = 1 then          'if reed switch 2 is on(magnet over) then
sertxd ("going to timerreadyA",13,10) 
        'send a message that timerreadyA has been initiated
goto timerreadyA    'initiate timerreadyA
endif            'end of the condition

if pinc.2 = 0 then 'if reed switch 2 is off then
sertxd ("reed off ",13,10)    'send a message back to the pc 'reed off'
goto main        'go back to main
endif            'end of the condition

timerreadyA:    'where if you remove magnet timerA will activate
for b0 = 1 to 5    'use b0 variable memory space for a loop flash 5 times          
high B.5        'output pin B.5 on    
pause 250        
low B.5            
pause 250            
next b0
high B.5            
pause 1000    
low B.5        
                

if pinc.2 = 1 then  'if reed switch 2 is on(magnet over) then
sertxd ("going to timerreadyB",13,10) 
            'send a message back to the pc
goto timerreadyB    'initiate timerreadyB

else goto timerA    'otherwise start timerA
endif

timerA:        'the first timer programme

high B.5        'keep this lED on
high C.1         'activate the transistor/relay/motor output pin C.1

sertxd ("timer 10 mins",13,10) 'send message the timer is on for 10 mins

for b1 = 1 to 10    'use b1 memory space for 10 loops of 60 seconds each
pause 60000             
next b1 

low C.1        'deactivate transistor/relay/motor pin C.1
low B.5
wait 1
goto main        'go back to main(the start)

timerreadyB:    'where if you remove magnet timerB will activate
low b.5

for b3 = 1 to 5    'loop the LED      
high B.6            
pause 250        
low B.6            
pause 250            
next b3
high B.6            
pause 1000
low B.6

if pinc.2 = 1 then  'set the condition for moving to next timerready
sertxd ("going to timerreadyC",13,10)
goto timerreadyC


else goto timerB
endif

timerB:
high B.6        'keep B.6 LED on
high C.1        'activate the transistor/relay/motor output pin C.1            

sertxd ("timer on 20 mins ",13,10)

for b4 = 1 to 20     '20 loops of 60 seconds
pause 60000             
next b4                 

low C.1        'deactivate the transistor/relay/motor output pin C.1
low B.6
wait 1
goto main

timerreadyC:

for b5 = 1 to 5    'use variable b5 to loop LED pin B.7      
high B.7            
pause 250        
low B.7            
pause 250            
next b5
high B.7            
pause 1000
low B.7

if pinc.2 = 1 then  'reed switch 2
sertxd ("reed on going back to main",13,10)
goto main

else goto timerC
endif

timerC:
high B.7        'keep LED on                
high C.1        'activate the transistor/relay/motor output pin C.1            

sertxd ("timer on 25 mins ",13,10)

for b6 = 1 to 25     '25 loops of 60 seconds
pause 60000 
next b6

low C.1        'deactivate the transistor/relay/motor output pin C.1
low B.7
wait 1
goto main

interrupt:        'the conditions and code for interrupting anytime
sertxd ("interrupting ",13,10)

if pin7 = 1 then interrupt    'if reed switch on pin7 is high(on)
low C.1
low B.6
low B.7
low B.6
low B.5

wait 2
setint %10000000,%10000000
reset            'goes back to main


timer with 12v and relay.jpg12vtimer.jpg
 
Last edited by a moderator:

tony_g

Senior Member
hi steve,

when you post your code to the forum if you select it all from program editor then right click and there should be the option there for "copy for forum", that will put the code tags around it correctly so it posts in less space.

have you included any freewheeling/back emf diodes across the coil terminals of the relays?

if not it could be back emf when the relay is de-energized which can cause problems of a circuit not functioning/resetting, i have had this myself before and often the diode will often solve it.

if you can get the time to draw up a schematic either using windows paint or even with a good ol' pen/pencil then snap a good quality picture to post, that way if their are any mistakes or areas of concern they can be pointed out to you by the many knowledgeable people on here and solutions offered up for you to help fix the problems.

tony
 

Goeytex

Senior Member
Hi
I have a timer for the kontiki using 18m2, and two reed switches, built on a kiwipatch board. The timer activates an auto relay.One of the reeds is solely to interrupt at at any time, the other reed moves through three different timer settings, activating when the magnet is removed..
Is an "auto relay" any different from a regular relay?

It is however cutting out randomly when in use. What I have checked: I thought perhaps connections resetting the picaxe so checked everything. Seems ok.
What do you mean by "cutting out" ? Is the Picaxe resetting ? Is the relay de-energizing? Things are seldom random. There is a cause and an effect. What troubleshooting steps have you done?

When it "cuts out" does the program reset because of a glitch or because the interrupt routine ends with a "reset" instead of a (more normal) "return".

Is there a diode across the relay coil?

While photos can be helpful, they are not a good substitute for an actual schematic diagram. Take the time to draw up a schematic and post it. (No excuses)
 

Circuit

Senior Member
I don't seem to see any decoupling caps across the power terminals of the PICAXE. Motors and relays are notorious for upsetting PICs; special precautions are needed to prevent resets through interference. As was said, we really need a circuit diagram to help properly.
 

jims

Senior Member
hi steve,

when you post your code to the forum if you select it all from program editor then right click and there should be the option there for "copy for forum", that will put the code tags around it correctly so it posts in less space.

have you included any freewheeling/back emf diodes across the coil terminals of the relays?

if not it could be back emf when the relay is de-energized which can cause problems of a circuit not functioning/resetting, i have had this myself before and often the diode will often solve it.

if you can get the time to draw up a schematic either using windows paint or even with a good ol' pen/pencil then snap a good quality picture to post, that way if their are any mistakes or areas of concern they can be pointed out to you by the many knowledgeable people on here and solutions offered up for you to help fix the problems.

tony
tony, Is a "freewheeling/back emf diode " different from the 1N4001 garden variety emf diode that I'm used to?
 

Goeytex

Senior Member
"Freewheeling" and "back EMF" are terms that describe HOW the diode is used. They do not indicate the TYPE of type of diode used. A freewheeling or Back EMF diode can be of different types. The 1N4001 is of one of these types.

To confuse things even more, a "freewheeling" diode can also be referred to as a catch, snubber, or supressioi diode ( among other terms). So that makes "freewheeling" somewhat ambiguous. "Freewheeling" is not very descriptive of suppressing the back EMF generated when a relay coil de-energizes. I prefer the term "suppression diode"
 
Last edited:

tony_g

Senior Member
tony, Is a "freewheeling/back emf diode " different from the 1N4001 garden variety emf diode that I'm used to?
well thats just my choice of words more to get across that a diode is needed if not already included to possibly help with the problem, sometimes like all of us a slip of the tongue or even an incorrect term does happen
 

steviejay

Member
thanks for the feedback
Attached my first ever schematic, being the bricks and mortar type....so its not flash
any help infinding why it cuts out is appreciated
Stevetimer schematic5.jpg
 

inglewoodpete

Senior Member
There are a couple of points that I'll comment on.
1. The 100ohm resistor is not big enough to protect the output of the PICAXE. The power transistor will draw too much current through it's base connection.
2. Depending on how you have wired the 0v rail, the current surge when the relay operates and/or releases could cause the PICAXE to reset. This will only be the case if the PICAXE shares the 0v return path with the relay circuit.
 

MartinM57

Moderator
...the 100R + LED in the base circuit of the BD139 isn't a great design - you should just use a base resistor. What are you trying to achieve with the LED?...there are are probably other ways to get the same result.

I can't see the normal reservoir cap on the output of the 7805 - at least 470uF would be recommended. This should certainly help with keeping the supply to the PICAXE steady and prevent resetting issues, but still might not be the root cause.

The output of the 7805 will be 5v not 4.5v, as indicated
 

Circuit

Senior Member
Okay, so the 100R + LED will provide some current limiting, but really I would never tap out of a PICAXE output without a 330R in place to protect the PICAXE output. Obviously without knowing the LED you have used the current cannot be determined but I agree that this is a somewhat idiosyncratic design.

An automotive relay, upon the coil switching on, can draw a very considerable current for a short time. With your design it will draw on the 220uF capacitor and discharge it, possibly sufficiently to drop the voltage to the PICAXE. You might just try disabling the brownout in the PICAXE as a diagnostic measure; see DISABLEBOD, manual 2 page 57. If this measure reduces your problem then you have the answer. Of course, it may be that the drop is sufficient to cut the voltage completely and lead to a chip reset.

You might consider placing a 100uF capacitor on the 5 volt side of the regulator to see if this maintains the supply to the PICAXE as MartinM57 suggests. (He suggests 470uF which is fine, but I normally prefer to put the largest reservoir capacitor on the input side of the regulator so that the regulator has sufficient power reserve to draw upon.

You might also consider sticking a diode between the 220uF capacitor and battery so that the relay cannot discharge the capacitor when it fires. With the voltage overhead of 12 volts to a 5 volt regulator there should be no issue with this. I would also suggest beefing up the 220uF capacitor.

You have no suppression capacitors on the relay; you might benefit from a 220nF capacitor across the coil. Ideally, if the relay is of a substantial size, then a snubber network (see Wikipedia or whatever) across the coil might be best.

Does the issue arise when the marine motor is disconnected? Even though you are using a relay to switch it, a marine motor can cause quite some EMI issues. The coil of the relay might just be picking up stray fields from the motor if it is close by. Sometimes a full metal box is needed to protect the PICAXE circuit from heavyweight EMI from large motors and the like; there are mentions of this on this forum.

I have just noted that that the marine motor appears to be connected to the same battery as your PICAXE/relay circuit; if it is then the motor could definitely be a major issue; its start-up current could drop the circuit voltage quite considerably. You would certainly need to look at some suppression on the motor.

Finally, if nothing else seems to work for you, try disconnecting the + from the regulator; patch in three AA cells and see if the problem goes away. If it does, then the characteristics of the relay circuit are certainly the most suspect.

Do let us know how you get on and best of luck.
 
Last edited:

steviejay

Member
thanks for all of that
Ill redraw the scematic with the changes suggested and post
No, on the bench without the motor no issues cutting out, so youre on the money.
the regulator circuit is the std that comes with the kiwipatch pdf sheet, maybe not intended for bigger loads, I think the motor can draw over 20A under load dragging out the line(it didnt come with any data)
Ill get busy
STeve
 

steviejay

Member
I dont think heat was the problem as I had the cutting out problem before... but waterproofing in the tight space is hard. I did not have the cutting out problem on a similar timer with a hall effect and no interrupt(so I couldnt turn it off)
Ive added what I think is the snubber as suggested by Circuit( the values are the best I can find without knowing the variables to plug into an equation). If it looks right I will build it and send it back out to sea under load
Stevetimer schematic with snubber.jpg
 

MartinM57

Moderator
The 0.1uF on the output side of the regulator seems to have gone missing. The 100uF (I would definitely go higher, but you decide) was in addition to not instead of.

The 0.1uF also needs to go as physically close to the PICAXE as possible - it's purpose is to suppress high frequency digital noise going into and coming out of the PICAXE. The 0.1uF is mandatory IMHO, not optional.
 

Circuit

Senior Member
Wise advice from Martin, the 100nF capacitor is needed in addition to the 100uF (you may read up on bypassing and decoupling, the two functions of these capacitors); the same goes for putting a 100nF capacitor directly from the PICAXE power + power pin to ground.
Also stick a diode (1N4002/3 or the like) in the +12 volt feed to the regulator BEFORE the 220uF capacitor so that the relay and motor cannot discharge this capacitor. The purpose of that capacitor is to ensure that the voltage regulator always has power to call upon if there are variations in the supply; this will reduce the effect of motor surges reducing the voltage to the regulator. You could boost up the 220uF capacitor also; a factor of ten would not go amiss.
 

steviejay

Member
ok thanks again..I must be closing in on something that looks right to a critical eye...I seem to have another 0.1uF capacitor close to the picaxe+ as suggested, and I presume this is as well as the one close to the regulator...I did have an IN4007 into the regulator but forgot to show it, but that was in case of reverse polarity..I cooked some things by doing that...tell me if Im correct inassuming that diode will serve that purpose....

I genuinely appreciate the patience shown here with my fledgling skills...Ive built lots of houses..kitchens,staircases ,you name it,but find this stuff to be both challenging and rewarding
Stevetimer schematic with snubber2.jpg
 

MartinM57

Moderator
The diode by the battery is, as drawn, doing reverse polarity protection.

Circuit is suggesting placing it one step to the right - between the relay connection and the 2200uF. In this new position, the relay can only get its supply from the battery, not the 2200uF, which will be keeping the regulator and PICAXE running with little/no interruption. It still provides reverse polarity protection.

Two 0.1uF capacitors, one at the regulator, one at the PICAXE are fine
 
Top