Lightweight program restart

If the load is indeed inductive and you have no flyback diodes yet, then the flyback diodes should improve it a lot.

Your drawing is correct. The 1N4001 is the 50V version of the 1N4007. That is good enough for 12V. Can you put those flyback diode close to the inductive loads ?

Shrinking tube does nothing for interference. The heat shrink tube prevents that the wires make a shortcut. That's all. A higher level of safety prevents a cascade of trouble.

Suppose you accidentally drop a tool on the circuit. You take your tool but it is stuck behind a wire. The wire is connected to a relay and pulling the wire it makes contact with an other wire. The power supply starts to smoke. The smoke alarm turns on. Someone comes to see what is wrong and stumbles over a loose wire. He just flew in from his work at the Large Hadron Collider and was carrying the first portable black hole. You see ? All because you didn't use heat shrink tube :wink:

Hmm in your example I think I will just put the entire central in som plastic melt and noone can touch nothing :wink:
Well I got your point and will of course upgrade this :slight_smile: thank you again.

Ok so I will try to put the diodes on the layout, not in central?
What may be damaged if I mistakenly turn the diode the wrong way?

Edit
Also, if the Arduino hangs when activating to relays it should be interference, as I am using 5v 10a power supply. But the fly back won't help in this case?

The flyback will only help when turning an inductive load off.
You can turn on the load to measure which side is 12V and which side is GND. Or turn everything off and measure which is the GND pin. Do you have a multimeter ? You really need one.

I think it is also called a "DMM", but in my country we call it a "multimeter".

If you have trouble when turning something on, then the problem might be with the power supply and the all the wires and the ground.

Thanks for clarification. We call it multimeter too in Sweden, Where do you live? :slight_smile:

So, I put one diode parallell to this sort of coil

and now it seems to work both with the program and the testprogram.
Well, lets see what happens when I activate other 12 volt-special effects on the railway... :o

I have also this type: https://www.faller.de/de/de/Produkte/Car-System/Technik/Abzweigung-sid9081.html
but much much smaller so not so noisy maybe.

Then I have electromagnets (or magnets really!) which with power on becomes deactivated.

These other types, do not seem to need a flyback.

Lets see if we need it.

Also strange that the first car system setup never did need this diodes. And there I use 2 of the coil above!

So this is a basic result and ran for a while,
UNTIL...
I went home and wrote this, thus bringing my PC home. :wink:

Thank you very much for all the help!

Please have a look at the video on the Minivärlden FB-page :slight_smile:

I think that all of those are inductive loads. They really need that flyback diode when a DC voltage is used with them, to avoid 300V peaks.
Check all your other builds and add those diodes as well.

Very nice video 8)

I live in the Netherlands. The highest hill in the Netherlands is 322 meters and we call it a mountain :o

1 Like

Nice to hear that. :slight_smile:
I have been busy a few weeks but the things are working :slight_smile:

However today adding another "fancy" function a similar problem occurred and maybe it is wrong to continue in this topic, however on the other hand it might be easier to understand it all together.

The picture below shows one relay in the power central (now all cleaned up and nice!)
The switch side of the relay (right) shows a cable running from "C" to model car charging station on the layout. Through the "driving mirrors" on the car we charge the car.

The car charger and the arduino (and the relays) have common ground to be able to measure and connect everything. The gnd are connected to one of the cars mirrors, while the other mirror are connected to "C" and recieves charge power or "returns" battery voltage for measurement to Arduino analouge input.

This function alter between charging or measuring the battery. (Just lets forget the inaccuracy of doing this with arduino). The battery voltage is max 2,4v.
A special charger fot this kind of cars supplies with 2,6v during charging.

The idea with this relay is control the signal to/from the car.
NC = car gets charging power (I can switch on/off this supply with an ordinary switch button)
NO = activated a few seconds to do some measurements

When shutting of charge power and run the relay, everything works fine.

When I supply NC with with power and run the relay, the Arduino freeze after 2-4 times when checking the car power with about 10 seconds intervall. I seems that it freeze when the relay goes off again.

As I have another Car system with constant charge power cable running together with other cables working flawless, I think the problem is situated just by the relay. Also when not switching the relay to "NO" but just let the car charge all the time everything is working fine.

When switching the relay to NO and back, maybe some electrical interference affects the Arduino?

Just would be interesting to hear your ideas on this and how to avoid it.

The voltage peak appears when an inductive load is turned off.
That means the left side of the relay seems to be the problem. A flyback diode solves that almost completely, but there might be other problems.

Don't connect a strong voltage to a analog input. You could add a protection resistor in the signal line of 1k to 10k.

protection resistor

How the ground wires are connected has a big influence.

I can not tell from here what the cause is.

This is a common problem. In such a situation you are supposed to get this kind of trouble. That is a cold comfort, I know.

Image that current peaks and voltage peaks and inductive fields are everywhere in your project. If you could see them, it would be like a Christmas tree haunted by buzzing ufo's. In reality it might be ten times worse.

There are for example: communication isolators, flyback diodes, optocouplers, balanced signals, and so on. However, all those components can be useless when ground wires are used wrong. As I said before: grounding is a craftsmanship.

1 Like

So this is a snubber?

I will try that and/or a diode at the charge station between +/gnd.

I call it a "protection resistor". It is for:

  • Voltages that are too high or too low, or voltage peaks.
  • When the Arduino is turned off, but there is still a strong voltage at a analog pin, then the Arduino might get damaged.

In my opinion, a "snubber circuit" is a RC Snubber.

If the contact pins of a relay create a spark, then the spark will eat through the contact pin and also causes electric noise. With a snubber circuit, the contact pins are not damaged anymore and there is almost no electric noise. It is often used with AC voltages.

Aha. I only use 0-5 volts in this charging/checking process. The analogue input to Arduino should not exceed 5 volts as the car can have about 3 volts of charged power. But if I understand you right, there might be voltage peaks that exceed this.

The car has a motor of course but it is shut of when charging, with an internal reed switch in the car.

The program runs flawless now and charge power are on and measuring is on, however the car is not there (I just covered the light sensor which control the process).
When I put the car at the charging bay the problem occurs.
Maybe a battery is an inductive load or create peaks?

I also tried to do a 2-step solution to use another relay to first shut of the power for charging, then switch the selection relay (that showed first) to checking, and then off and then activate charge again, just to secure that the relay switch created the problem. It does not help.

I will now add a resistor between the analogue input and the C-connection of the relay switch.

If I would use a flyback diode, I guess your intention was to put it at the switch side of the relay (as we did with the electromagnet)?

Addition.

I have tried 3》10k resistor and also
This:

I flyback at the charging bay. But does not work or stops program even earlier. :frowning:

Maybe I misunderstood where to put the diode?

Here you se the charging bay. The metal blade to the left of the car are + and to the right gnd. I have tried to put the diode in both ways just in case..

Maybe move it down to the relay switch screw terminal?

I'm sorry, I'm too confused. I is hard for me to understand what is going on without being able to touch it and see it myself. I am starting to repeat myself in this topic.
When someone draws a schematic and want us to look at it, that is easy to do via this forum.

A battery is not inductive, but when connecting or disconnecting, it might cause peaks.

The main trouble is always an inductive load. The coil of a relay is a inductive load.
Wires, long wires, a bunch of wires, wires next to each other, those are a little inductive as well. With short distances it is often no problem, but they can be the cause of voltage peaks and crosstalk.

I understand you, as I have been programming lots of php for websites. It is not easy when you do not have the entire picture and, as you say, can touch it yourself. :roll_eyes: :frowning: but I am very thankful for all your and others help! :slight_smile: it did solve a lot.

I will draw a general picture for clarification. Maybe it is all my error in the basic idea. Maybe it is not possible to do what I am trying to do :slight_smile: it could be that easy.

From another perspective and just forget my solution:

Is it possible to charge and measure an external battery simultaneously with an Arduino? And the battery is not powering the Arduino.

Maybe there is another smarter solution. :thinking:

EDIT:
This was my concept idea, but maybe it is a bad solution from the beginning.

Sure you can charge the battery and use the Arduino at the same time.

As an example, I have highlighted the critical parts of the ground wires. But that is only a (very) small part of possible problems. The current that is returning from the relay or battery can disturb the ground of the Arduino.

afbeelding

Thanks.

The grounds are tricky and the link you provided early is great. I thinking of connect the ground at the beginning having only 1 cable running to power central.

The returning current is a good theory.
Problem occurs when:

A. The car stands in charging bay, and charge power is supplied.

This means running the program with relays but not charging power on everything works.

If The car is removed but the charge power is supplied. The program runs, relay switches etc.

I Am thinking if moving the relay very close to chargestation would be a better solution? That would let the power cable and measurecable not changing.

Another thought I got is to try to "keep up" the voltage and I have a friend who suggested a capacitor between gnd and analoge in however without any luck.

And also if there is another smart solution to do this electrical intead of a relay

You mean the current when the car connects to the charging bay ? The contacts of the charging bay is the place to put also a flyback diode and maybe a RC-snubber circuit as well.
Follow the wires (both current towards and from the charging bay) and see if the wires are near wires to the Arduino.

When you use those black/red wires that are fused together, then the induction created by the red and black wire are opposites and they eliminate each other.

I really don't know what to say. I don't know how all your wiring and power supplies and flyback diodes is.

1 Like

Sorry for late reply and thank you for all help.
It have been too busy on my job AND Minivärlden.

We open on monday.
For this summer I have done another solution with just measuring the time it takes for the car to move between 2 positions and with this time decide of to charge the battery or not.

Maybe I shall put them.
I tried with what I hade but it did went really hot.
I am charging https://en.wikipedia.org/wiki/Nickel%E2%80%93metal_hydride_battery.

Maybe I did use to small diode. The voltage on the battery is about 2,5-5 volt, Normally 2,2-3.

If anyone reading this will go to Sweden for vacation I will gladly show everything to you:
[https://www.minivarlden.se/sommaroppet/](https://Miniture somme Minivärlden 2021)

Best regards Johan

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.