Go Down

Topic: Relay switching 12v erratically  (Read 1 time) previous topic - next topic

joatmon13

I have an issue with a dual channel relay which controls a 12v linear actuator with limit stops.  Mostly the relays output the correct voltage (+ or - 12v).  The input sides of the relays always switch fine, as evidenced by the onboard LED lighting when triggered.  I can hear the coil switching, but sometimes the linear actuator doesn't move and I check the supply voltage from the relays and it reads strange values from .3V to 7 volts.  

The leads to the linear actuator are about 2.5m long from the relays.  I read the article about fly-back diodes and wonder is this the issue?  I have tried changing the code to inject a small 1 second delay between switching the inputs from low/high and high/low.  When I disconnect the leads to the linear actuator and just read the output voltage with the multimeter, it works fine.  I have replaced the relay module and get the same results.


The Fritzing part for the relay does not allow me show it without the jumper connected, but I have removed the jumper and connected 5v positive to JDVCC.  Here is the schematic from Fritz, which I can't make anymore legible (apologies):-





Thank you for your suggestions.  Please note I am just a newcomer to microcontrollers and coding, so simple explanations work best!


Southpark

#1
Jan 01, 2021, 11:51 pm Last Edit: Jan 01, 2021, 11:52 pm by Southpark
Does the negative terminal of your 12 volt battery need to be connected to the GND pin of the arduino? If it needs to be connected, then it just looks like your existing fritzing diagram doesn't have it connected.

joatmon13

Does the negative terminal of your 12 volt battery need to be connected to the GND pin of the arduino? If it needs to be connected, then it just looks like your existing fritzing diagram doesn't have it connected.
Hello Southpark.  No I have not connected the 5v circuit negative to the battery 12v negative.  Should I do this?  I'm using Node MCU ESP8266 instead of Arduino, but I presume that is not so relevant?  Thank you for your assistance.

Paul__B

Those diagrams are a terrible mess!

So you have a 12 V to 5 V "buck" converter module.  Connect 12 V and ground from the battery to the converter.  In all cases, you must run the supply and ground bundled together as a pair.  This also applies to a control signal and its return, such as the switch you show.

On the "buck" converter module, the two grounds will actually be the same, however you must connect all the 5 V grounds back to the output ground, not to the input or battery.  You run the 5 V and ground as a pair to the NodeMCU.  You run the 5 V and ground as another pair from the converter to "JD-VCC" (with the link removed) and ground on the relay module.  As you gather, "Vcc"on the relay module connects to the "5V" terminal on the NodeMCU and the two "in" terminals on the relay module travel to the NodeMCU bundled along with this connection, you do not connect the ground.

Similarly, the PIR connections run together as bundles of three directly from the PIRs to the NodeMCU.

Finally, the power for the actuator should run - as a pair - from the two battery terminals to the relay contacts and from them as a pair to the actuator.  If you want to add "kickback" diodes, the easiest is a rectifier bridge at the relay with "+" and "-" connected to the 12 V supply and the "~" terminals to the actuator connections.

joatmon13

Apologies for the bad diagrams, I have simplified this by removing control inputs (switches and PIR's)  to focus on the relay, as I believe that is where the problem arises. The original Fritz schematic is very confusing, as it treats the contact points on the relay in a peculiar way, so I have just included a BB diagram, which is a more accurate reflection of what I have wired up. 
I hope this diagram is more readable:-


As I mentioned in the OP, the logic signal goes correctly to the relay, as evidenced by the relays onboard LEDs which light up according to requirements.  The issue to me seems to be in the 12v circuit.  The relays should just switch 12v polarity to the linear actuator to change direction.  The poles are being fed 12vDC yet sometimes when they switch, they just go from Positive 12v to a neg range of between -0.3V to -7v.

Reading the responses, I am still confused:-

1) I think the suggestion from Southpark to connect the negative from the 5v to the 12v negative is incorrect, and I have not done this. In my revised diagram,  I have separated out the 12v negative in black and 5v negative in Grey wire color.
2) The recommendation to pair positive and negative supplies is in fact how I have done this.  I have read articles about star grounding, which is what I believe I have done.
3) I have NOT connected the negative 5v to the relay on the signal side, as I have read elsewhere.
4) My understanding of a bridge rectifier is to switch ac to dc.  So would it not in fact stop the system from reversing polarity to the actuator when required?
5) Can anyone explain why the 12v output from the relays would switch to a negative value, less than required (-0.7 to -8v). Is this because of the long leads between the relays and the actuator? (2.5meters).  

Southpark

#5
Jan 02, 2021, 01:16 pm Last Edit: Jan 02, 2021, 01:19 pm by Southpark
joatmon ----- thanks for updating the diagram. I didn't suggest connecting the 12V negative terminal to the node32 gnd, but was just asking whether it needed to be connected, or not.

From what I can see, after checking out some details of the LM2596, and the two-relay module ----- it appears that we don't connect the 12V negative terminal to the GND of the node32 ------ ie. we don't connect together the Vin- terminal to to Out- terminal of the LM2596.

You mentioned flyback diodes. But can't see any flyback diodes in your diagram.

You want to drive the motor/actuator in forward and/or reverse direction, right? Have you considered dedicated off-the-shelf H-bridge driver modules?

Paul__B

Much more usable diagram.  :smiley-cool:

4) My understanding of a bridge rectifier is to switch ac to dc.  So would it not in fact stop the system from reversing polarity to the actuator when required?
It is just a convenient way of attaching to each actuator connection, a pair of diodes which prevent the voltage either exceeding the supply voltage or going negative to the ground (12 V negative).  Under normal operation, that clearly cannot happen, the diodes merely limit impulses out of the range of the supply voltage as the relay contacts change over.  Two wires, two diodes each, a bridge has them all.

5) Can anyone explain why the 12v output from the relays would switch to a negative value, less than required (-0.7 to -8v).  Is this because of the long leads between the relays and the actuator? (2.5meters).  
No.  If it is wired correctly and you were measuring correctly, then other than switching transients - which you would need a scope to observe - no part of the circuit generates negative voltages.

joatmon13

Thank you both Southpark and Paul__B.  This is a voyage of discovery for me and I really appreciate your perseverance.

Southpark, you ask have I considered a H-Bridge.  As a newcomer to this, I just googled how to drive a linear actuator and the internet seemed to be consistent in recommending dual channel relays.  I wasn't aware of the H Bridge solution, but if this is a more robust solution, then I will adopt this approach.  What are the pros and cons of each approach? Are there any specific characteristics I need to correctly select a H-Bridge?  Would this Amazon item work?

I only asked about fly back diodes in my OP, because I see this as a sticky post in this section and I thought maybe that was my problem.  I have none in my project.

Paul__B - is a bridge rectifier as you suggest similar to a H-Bridge? When I search for a bridge rectifier, they all seem to be to convert ac to dc.  Can you recommend what type I require, or do I need one at all, if I choose to use the H-Bridge approach?

To clarify further my earlier post # 4, when I say I get a negative feed from the relay, I should have stated more clearly that the voltage was reversed on the lines, as expected, it's just that the value was inconsistent - not + or -12Volts.  I have a multimeter hooked to the relay outputs to the linear actuator and so it shows a negative value when the actuator is being closed.  

Southpark

#8
Jan 02, 2021, 10:34 pm Last Edit: Jan 02, 2021, 11:09 pm by Southpark
Most welcome joat.

The bridge rectifier method includes diodes that achieves the desired voltage limiting function. So a properly controlled set of relays can be used to apply either a positive source polarity or a negative source polarity.

Off-the-shelf H-bridge modules generally have the necessary diode configurations too, and the switching is done using transistors instead of relays.

The bridge rectifier method could just be what you need. The diodes of the bridge rectifier will drop a few volts. So just take that into consideration too if it matters ------- as in --- if you want 12V or so across the linear actuator device, then could consider off-the-shelf H-bridge module ..... most likely costs more.

The 'flyback' diodes (they have other names too) are a name given to diodes that have the job of preventing a relatively large voltage from being generated (or developed) across the motor coil when somebody attempts to use a switch to abruptly disconnect the path (or line) of current (for the case where current is flowing through the motor coil).

The relatively large voltage generation an effect that the physics people found a long time ago. The developed large voltage during the 'switch-off' is known to have  a polarity that goes 'against' the direction of the original flow of current. And this is why the fly-back diodes are arranged in the configurations that we see in circuit diagrams, which allows the original current in the coil to decay away to zero (during the switch-off period) and also at the same time prevents the large reverse-voltage from being developed. They are clever tricks (methods) for preventing large voltages, sparks etc ------ which could otherwise damage certain components in our circuits or wear out physical contacts of relays pre-maturely.


joatmon13

Thank you Southpark for your very clear explanation. Karma points added!

I have ordered some H-Bridge units and will try my luck with them.  Meanwhile, I have noticed that the relays' erratic switching can be coaxed into operation with a gentle flick (an old trick!!).  Seems to suggest that the contacts in the relays have somehow worn out, even though they have only been driving the actuator for less than 1 month.

When I receive the H-Bridge units, I will update on the results.  

Southpark

#10
Jan 03, 2021, 02:08 am Last Edit: Jan 03, 2021, 02:09 am by Southpark
Most welcome joat. When an inductor (coil) is involved with a current flowing though the inductor, and a physical switch is used to break the path (to stop the current from flowing) ----- the physics people found that the flow of current through the coil is maintained for a while even when the two sides of the switch (electrical contacts) are not touching each other during contact separation. Associated with the 'spark' ----- the two sides stay electrically connected for a bit - even when there is physical distance separating the contacts. The spark eventually distinguishes when the contacts become far enough apart (relative to the initial touching 'zero' distance). The spark can create residue on the contacts, and wearing out of the contacts -------- and it is the clever methods such as using flyback diodes in contactor-switch and coil combination circuits that helps to stop sparks from occurring.

Paul__B


Not sure what the intention of that diagram is, but it has nothing whatsoever to do with what I was explaining about using a bridge rectifier as a convenient form of voltage limiting for the relay switching.

It is in fact, nonsensical!

Ron_Blain

When the 12 VDC to a motor starts becoming intermittent you may want to look long and hard at all of your connections. A loose or faulty connection will cause the symptoms you describe, especially under a higher current draw. How much current does your actuator draw under load? It's just a little peculiar it works fine sometimes and other times your 12 VDC drops down to 7.0 volts. If a breadboard is involved in this with wires poked into it I would wait for it to give the low voltage symptom and start wiggling and jiggling your connections. Nothing to lose trying that. 

Ron

Southpark

#13
Jan 03, 2021, 06:38 am Last Edit: Jan 03, 2021, 06:48 am by Southpark
Not sure what the intention of that diagram is, but it has nothing whatsoever to do with what I was explaining about using a bridge rectifier as a convenient form of voltage limiting for the relay switching.
oops..... ok ..... obviously misinterpreted the bridge rectifier scenario there. I assumed something different when looking at it ---- as in bridge rectifier diodes combined with a suitable set of relay switches (for flipping the polarity) and DC motor.

Quote
It is in fact, nonsensical!
I disagree with that.

Southpark

Nice recommendations you made there Ron.

Go Up