picaxe RELAY modules and interference? help..

macsoft

Member
Hi there!

I've purchased several of there relay modules to work with my picaxes: http://www.ebay.com/itm/2-Channel-Relay-Module-for-Arduino-PIC-ARM-DSP-AVR-Electronic-5V-/121058681881?pt=LH_DefaultDomain_0&hash=item1c2fa8e419


The idea is to control a conversion on my outside blinds, i have manual outside blinds like these:

that wore originally manual, (you had to pull a strap) and i converted them to electrical. Got some good torque slow electrical 220v motors that work great with them.

So next idea? use my 08M2 picaxe to control them :)
the relay module is really simple (or so it seams..) you just connect outputs of the picaxe to it, and they trigger the relays to close bigger currents.
I also use some magnet switches on the blinds so the picaxe can tell when the blinds get to the top ot all the way down.

So on the picaxe i have:
INPUTS
- 1x switch to control up and down (alternating between, up - stop - down - stop ...)
- 2x magnetic sensors to sense position.

OUTPUTS
-2x outputs for 2 relays

the relays are wired so that they inverse movement. if you trigger relay 1 the blinds go UP, if you trigger relay 2, the blinds go down. never trigger both at the same time.

Programing is simple, and not the problem, because i've reduced the program to just basic functions and the problems persists.

PROBLEM:

what happens a few times is the relays go nuts! going ON and OFF sometimes alternating very fast..
But it makes the picaxe to go crazy to.. button does not respond properly :S
And THAT ONLY happens when I've got the power wires (220v) hooked up to them..
IS there any way the load on the relays are influencing the picaxe?

What can I do to avoid that?

Also:
if the sensor wires are too long (6-8 meters is all i need), the picaxe acts has the sensors have been triggered and they have not.
any way to prevent this too?

Thanks everybody!
 

boriz

Senior Member
"never trigger both at the same time." You sure? What if the program crashes?

Sounds like power supply noise to me. You probably need additional decoupling.
 

macsoft

Member
"never trigger both at the same time." You sure? What if the program crashes?

Sounds like power supply noise to me. You probably need additional decoupling.
Well if the program crashes, i don't see why should both be ON, it can happen.. but i have a separate circuit just for the power to my blinds, so nathing major would happen.

What is decoupling? and how can i do it? (sorry English is not my main language, and PICAXE is a fairly new language for me too :) )

RF would be an idea for the far away sensors, but I would hope there could be an easy way to shield the cables to go just 6-8 meters. I haven't tried RF circuits yet (i do have the electronics to try it out), but i do want to use an 08M2, and i already have 3 inputs and 2 outputs occupied, one of them serial out.

The biggest problem right now is how to isolate the circuit from the powerlines interference.

Sorry, i'm terrible in schematics, its just a simple circuit with 3 inputs (resistors on them) and 2 outputs to the relay board.
And the program i'm still using test programs to debug it. can be as simple as "push once go down. push again stop. push again go up. push again stop..."

thanks
 

jedynakiewicz

Senior Member
I am only working on assumptions - you provide no details of the circuit and there are none available from the ebay link for the relay board.
The 5 volt relays have coils that will draw quite a current. I am assuming that the PICAXE pins are connected to optocouplers on the relay board. The ebay spec says that these draw 15-20mA; that is the absolute limit for the output pins of a PICAXE. If the other side of the optocouplers are connected to the same 5 volt power supply as the PICAXE then when the relays are activated the coils could, instanteously, drop the 5volt power supply too low to keep the PICAXE alive and causing it to reset.

Firstly, try powering the PICAXE chip from three AA batteries whilst keeping the relay board on a separate 5 volt power supply. See if this cures your problem. If so, then you need to add a 100uF or larger across the PICAXE power supply input to protect against the transient voltage drop when the relays kick in.
You also need that decoupling capacitor that was mentioned; this is a 100 nanofarad ceramic capacitor that you connect across the PICAXE power pins. It should be as close to the pins as possible - it is all shown in the PICAXE manuals. This is to filter out any electrical noise on the power lines that may affect the operation of the PICAXE. Motors generate a lot of noise. If you still have problems, see if the relays operate as you would expect when the motors are disconnected. If the program works okay when the relays are not connected to the motors then the motors may be the source of the electrical noise and require supression - a less easy task, I am afraid.

With regard to the long cables from the sensors to the picaxe you may try twisted pair cables or shielded cable. If you use shielded cable then the shield should only be connected to earth at one end otherwise the shield can end up as a big inductive loop in its own right. The best idea is to keep the PICAXE closer to the site of operation - I don't quite see why you need eight metres of separation.
 

macsoft

Member
I am only working on assumptions - you provide no details of the circuit and there are none available from the ebay link for the relay board.
The 5 volt relays have coils that will draw quite a current. I am assuming that the PICAXE pins are connected to optocouplers on the relay board. The ebay spec says that these draw 15-20mA; that is the absolute limit for the output pins of a PICAXE. If the other side of the optocouplers are connected to the same 5 volt power supply as the PICAXE then when the relays are activated the coils could, instanteously, drop the 5volt power supply too low to keep the PICAXE alive and causing it to reset.

Firstly, try powering the PICAXE chip from three AA batteries whilst keeping the relay board on a separate 5 volt power supply. See if this cures your problem. If so, then you need to add a 100uF or larger across the PICAXE power supply input to protect against the transient voltage drop when the relays kick in.
You also need that decoupling capacitor that was mentioned; this is a 100 nanofarad ceramic capacitor that you connect across the PICAXE power pins. It should be as close to the pins as possible - it is all shown in the PICAXE manuals. This is to filter out any electrical noise on the power lines that may affect the operation of the PICAXE. Motors generate a lot of noise. If you still have problems, see if the relays operate as you would expect when the motors are disconnected. If the program works okay when the relays are not connected to the motors then the motors may be the source of the electrical noise and require supression - a less easy task, I am afraid.

With regard to the long cables from the sensors to the picaxe you may try twisted pair cables or shielded cable. If you use shielded cable then the shield should only be connected to earth at one end otherwise the shield can end up as a big inductive loop in its own right. The best idea is to keep the PICAXE closer to the site of operation - I don't quite see why you need eight metres of separation.
Thank you for the very complete post.
Has i said before, the problem only happens when the relays are connected to the 220 volt power supply and the motors. So power drop on the picaxe power source don't seam to apply.
The 6-8 meters of separation is the distance between the sensors on the blinds, and the picaxe circuit on the wall, where the operation switch is. So i can keep the picaxe close to the sensors, and the operating switch at 8 meters, or i can keep it close to switch, and at 8 meters from the sensors :S

My idea was to use CAT5 to make use of the twisted pairs inside. But to shield it, do i connect the strand to the minus on the picaxe power source, or can i connect it to earth on the main 220 power source?

The motor on the blinds does have a big capacitor between contacts, so i supose it has some suppression..
what else can i do to prevent the interference?
thank you
 

fernando_g

Senior Member
"the problem only happens when the relays are connected to the 220 volt power supply and the motors"

Operating an inductive load (like an AC motor) with a relay will always create contact sparking. Like an old fashioned Marconi transmitter, you will be radiating RF all over the place.

In lieu of a spectrum analyzer, use an AM radio tuned to an empty area, and activate the relays. You'll most likely hear the noise as the relays activate.
What you require to do next is to add a AC snubber circuit across the relay's contacts. Google the term. What I advise you here is to use a X1/Y1-rated capacitor. Don't use a normal ceramic disc capacitor.

With the same AM radio, see the difference in noise with and without the snubber circuit.

The big capacitor in the motors; how big is big? It could be a motor-start capacitor, and those are there to provide starting torque, not any type of noise suppression.
 
Have had lots of similar problems with switching mains. You need to decouple the Picaxe. This is to fit capacitors across the terminals that the interference is effecting the 08. 0.1 ceramic across the 5 volt supply and also between the inputs and 0 volt. This will greatly reduce the problem. Another good trick is to reduce the the input resistors from 10K to 1K this helps greatly and if you are running it from the mains it will not matter. The capacitors on the motors are for motor starting not suppression as they are single phase motors. There are some good articles written on this forum about interference and decoupling. If you do a search you will find several threads by some very clever people. I know very little about electronics but you learn the essential things pretty quickly.

If all else fails use some zero switching SCR's from Ebay about £5 all your problems will be gone then.
 

jedynakiewicz

Senior Member
As Mark Bishop said, you can search around on this forum for lots of information on suppressors and suppression methods. One other idea; why not put an optocoupler at the PICAXE end of the long line? - with a separate power supply for the sensor end of things. Whilst interference on the line is likely to upset the very sensitive inputs of a PICAXE, it is unlikely to generate enough current to light up the LED inside an optocoupler. This would separate the PICAXE very definitively from the source of the interference.
 

Goeytex

Senior Member
First and foremost .... there should be a 100nf capacitor across the Picaxe power pins 1 & 8. The capacitor should be as close to Pin 1 as is practical. If this does not solve the problem ....

An RC Snubber across the relay contacts will act to suppress relay contact arcing. Suggest a 150 ohm 1/2 watt resistor in series with a .1uf metalized polyfilm capacitor rated at 600v - 1Kv. The capacitor MUST be non-polarized. Another option for arc suppression is a QuenchArc type snubber. ( more expensive)

If you will post a complete circuit diagram, more help can be provided.
 

macsoft

Member
THank you everybody ! I see a lot of good ideas here. I will try has much of them as I can, and I will post the results here.
i love this forum! :)
 

macsoft

Member
Ok,
following many of the suggestions here I will try a quick fix with the components I have access right now... so what i did was:
condenser between 1 and 8 pins on the picaxe.
condensers on the 2 picaxe outputs to the relay board (between each output and ground)
one diode on the path of each output (i know.. no one told me to do that.. but if maybe some power is coming thru the relay board back to the picaxe outputs..this may block it?)
condenser between the relay board +5 and ground.

I only have 4.7uF condensers now, i've used these, I will try to get the right ones later.

After all this, it still works fine with the relays not connected to the mainline and motor.
I will connect them later in the day and see if it works.
crossing my fingers! :p
 

boriz

Senior Member
"condensers on the 2 picaxe outputs to the relay board (between each output and ground)"

Sounds iffy to me. Better post a schematic.
 

macsoft

Member
"condensers on the 2 picaxe outputs to the relay board (between each output and ground)"

Sounds iffy to me. Better post a schematic.
Sorry i suck at schematics :S

I mean a condenser between an output pin and ground.
is that wrong?
 

eclectic

Moderator
Sorry i suck at schematics :S

I mean a condenser between an output pin and ground.
is that wrong?
Do you mean that you cannot do them?

Draw one neatly on graph-paper,
scan it,
then post it.

It REALLY will help people to help you.

e
 
Last edited:
The condensers (I love that word, last time I heard it I was watching black and white TV), they need to be on the inputs to 0v. I also think you need some smaller condensers, about 0.1 uF or smaller and ceramic to work well to get rid of the interference, its to do with the high frequency that they operate at and their efficacy in decoupling the interference from the board.

The diodes will do nothing.

I think the proof will be when you put the power back on, getting rid of the RFI is a tricky and really maddening task.

Separating the signal cables from the power cables will help a bit but the condensers are the secret.
 

eclectic

Moderator
The condensers (I love that word, last time I heard it I was watching black and white TV), they need to be on the inputs to 0v. I also think you need some smaller condensers, about 0.1 uF or smaller and ceramic to work well to get rid of the interference, its to do with the high frequency that they operate at and their efficacy in decoupling the interference from the board.

The diodes will do nothing.

I think the proof will be when you put the power back on, getting rid of the RFI is a tricky and really maddening task.

Separating the signal cables from the power cables will help a bit but the condensers are the secret.
Go on Mark, be an example.


Post the schematic. :)
e
 

macsoft

Member
lol ok capacitors not condensers.:) My main language is Portuguese, we call them "Condensadores". "Condensers" remind my os Conderser Mikes on recording studios.
I'm be home soon, and I'll plug it in, and see how it roles.
If it does not, I will try to learn how to do a schematic, promisse! :)
 

fernando_g

Senior Member
"condensers on the 2 picaxe outputs to the relay board (between each output and ground)
one diode on the path of each output (i know.. no one told me to do that.. but if maybe some power is coming thru the relay board back to the picaxe outputs..this may block it?)"

This is a brute-force approach that may appear to work...a large electrolytic may maintain the relay energized for the RF transient to die down.....but it is the incorrect way of solving the problem.
 

macsoft

Member
OK FINALLY it works. Long live the capacitor crew :)
I know i know.. probably not the best way. I tried all the medicines at once and now i dont know what cured me :)
The sensor problems have vanished too !
I got so exited that I ditched the battery pack and tried to power the circuit with a cell phone charger... and the problems came back.
Gotta get me a decent power source. But i'm very happy with the circuit right now.
I hooked up 2 leds on the outputs for status check, hidden all the electronics behind a wall switch, and altered a wall switch to work by pushing a micro pushswitch to activate the blinds.
drilled 2 holes for the LEDS on the wall switch too.
Now 1 press of the wall switch, the UP led goes ON, and the blinds go up. a magnet sensor switch on the top, and one on the bottom control the position.
when the sensor on the bottom is triggered, the program leaves the blinds going down another 8 seconds so that is closes completely.
a timeout is also set so that if the sensors malfunction the system halts by itself.
I will post pics/movie tomorrow.

Next step it to program specific hours for the blinds to go up and down, and probably some remote controlling. my inputs/outputs are maxed out, so i'll probably do that on another 08M2 and get it to talk to this one. I'm using the serial output as a normal output to the relay board.. will probably get some trouble there?
Let me not get too worried by now.

Thank you everybody for your inputs and ideas! Discovering these little chips have completely revolutionized my "inventions", and you and this forum make my life a little happier :)
 

macsoft

Member
Also, I had a traffic accident on my motorcycle last december, and I have a broken foot since then. Working with these little chips has kept me sain ! Long live picaxe! :)
 

planchibus

New Member
Hello MacSoft:
I have the same problem as you and would help me very much to see the wiring diagram of the capacitors.
thanks
 

Axel87

Senior Member
Interesting project!
Can you share the code and any pictures or schematics with the community?
Thanks!
 
Top