Problem with my relay... Don't want to stop.

Hi!

I had a problem with a relay.
It works using a "Marklin Train" for my father, so I need to power up the rails sometimes or not power up.

But the problem is that the rails are always powered up, so I need to know where the error comes from. If it is come from the train stuff, or from the Arduino and relays stuff.

This is a shema of my relays and how they are connected to my Arduino:

And this is my arduino code:

const char rail = 6;

void setup() {
  // put your setup code here, to run once:
  pinMode(rail, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(rail, LOW);
}

Note this is not my definitive arduino code but this is the results:

When I replace "LOW" by "HIGH", there is electricity on the rails
When I replace "HIGH" by "LOW", there is also electricity on the rails.

Unfortunately I couldn't gives you attachments because the files are too big to be uploaded on most of the hosts, including the Arduino Forum...

NB: TomGeorge asked me to get a hand drawn version of my circuit, if you want to get it more quickly, here it is:

What do you think?

Thanks in advance

Chopin2712.

PS: When I set the rail to "LOW" in my Arduino code the little LED on my relay stops so I believe there is no problems in my Arduino code.

Hi,
Welcome to the forum.

If you disconnect the Mega completely from the relay, do you still get power to the track?

I've given you a karma, as you seem to have read the forum instructions and used code tags.

Thanks.. Tom.. :slight_smile:

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Fritzy pictures are not very informative for troubleshooting.
A picture of a hand drawn circuit can show so much more.

Thanks.. Tom.. :slight_smile:

Shouldn't your first line

const char rail = 6;

be
const byte rail = 6;?
Fof

TomGeorge:
Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Fritzy pictures are not very informative for troubleshooting.
A picture of a hand drawn circuit can show so much more.

Thanks.. Tom.. :slight_smile:

This is a link to my hand-drawn circuit:

Hope it will helps you to understand,
Maybe I could try to upload my pictures through Dropbox too if you need them.

IamFof:
Shouldn't your first line

const char rail = 6;

be

const byte rail = 6;

?
Fof

No because even if the Arduino is not connected I still get the same issue

then your problem is in the relay module....
you can test relay module directly without Arduino... it should work and you should listen the sound as well.
also you can put a led (with resistor) if it´s not included in the relay module (I assume there´s one) to monitor your code

oswe:
then your problem is in the relay module....
you can test relay module directly without Arduino... it should work and you should listen the sound as well.
also you can put a led (with resistor) if it´s not included in the relay module (I assume there´s one) to monitor your code

I already tried it, as the recommendation of TomGeorge. I disconnected completely the Arduino and the relay then the track is always powered up. So it is not my Arduino Code for sure.

I think I found the problem, I disconnected the track from the relay and the track is always powered up. So it probably means it is the isolation with the next track is not working (to understand, please check the hand drawn). I will gives you more informations if it is that or a relay / circuit problem...

But I don't think it is the relay because to solve the error I tried using another type of relay so I believe 2 different relays cannot be broken at the same time.

Hi,
OPs circuit;

Tom.. :slight_smile:

Hi,
If you pull the railway wires out of the relay terminals, does the train stop?

Are you using COM and NO (Normally Open) terminals?

Do you have a DMM?

Thanks.. Tom.. :slight_smile:

SOLVED! There were 2 issues with the rails:

The first one is that the tracks where not isolated correctly, so the power of the next tracks goes on the stopped one.

The second one is that the relay was broken, I tried with another one and it works!

I had 2 problems when solving who makes me thing it is a relay's issue:

  1. When I set the track's wire on the NC pin, the power is always on even if it is off
  2. When I set the track's wire on the NO pin, the power is always off even if it is on

Note in the 2 cases the COM pin is for the power supply.

I also tried other combinations but I had the same problem.

Thanks you very much for your support.

Chopin2712

PS: To solve this error it took me 1 full day. I am so happy it works now!

Edit: The relay wasn't broken but it was not powered up correctly, to use the 5V pin and GND multiple times I place them on a breadboard. But the breadboard connection wasn't good so when I touch relay's wire or directly the breadboard the relay make a weird noise.

I think it is also because there were too much wires on my breadboard.

But now I tested my "broken" relay and it works.

This was an information for peoples who had the same issue as mine...

Cordially

Chopin2712

Hi,
Thanks for letting us know, it helps complete the thread and as you say helps others.

I have given you a karma.

Tom.... :slight_smile:

TomGeorge:
Hi,
Thanks for letting us know, it helps complete the thread and as you say helps others.

I have given you a karma.

Tom.... :slight_smile:

Thanks!