Go Down

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

Southpark

Most welcome Joat. Nice to hear that you gained something from all this, and your system should work just fine. The relays should work nicely, and won't do the wear-out thing due to arcing/sparking with your new configuration.

Also --- nice diagram from MarkT.

raschemmel

Quote
This is how I draw a relay H-bridge so its clear (and looks similar to the common way bridges
are laid out, beit H-bridge, 3-phase, or whatever):
DPDT relay right ?

joatmon13

#47
Jan 14, 2021, 03:58 pm Last Edit: Jan 14, 2021, 04:22 pm by joatmon13 Reason: added code
Pop Bang smoke!! :o


I tried using the L298N as alternative to the relays, as I couldn't get the bridge rectifier to work on the relays.  However, while it initially ran the actuator in one direction, I then saw smoke coming from the L298N.  The only thing I didn't do was share the ground back to the 5v circuit.  Could that have caused it to blow up?  Here is how I had it wired:-




The relevant code for actuating the linear actuator is:-
Code: [Select]
void openFlap()
{
  delay (25);
  digitalWrite(HBridge1, LOW);// turn HBridge 1 OFF
  digitalWrite(HBridge2, HIGH);// turn HBridge 2 ON
}//openFlap()

void closeFlap()
{
  delay (25);
  digitalWrite(HBridge2, LOW);// turn HBridge 2 OFF
  digitalWrite(HBridge1, HIGH);// turn HBridge 1 ON
}//closeFlap()



raschemmel

#48
Jan 14, 2021, 05:07 pm Last Edit: Jan 14, 2021, 05:14 pm by raschemmel
 If you look at the schematic you posted, it shows only TWO inputs connected.'
What's missing ? ENB ! (for inputs IN3 & IN4)

Quote
Quote
Each bridge is driven by means of four gates the input of which are In1 ; In2 ; EnA and In3 ; In4 ; EnB.
Quote
The In inputs set the bridge state when The En input
Quote
is high ; a low state of the En input inhibits the bridge.
Quote
All the inputs are TTL compatible.
While not mandatory, it is recommended to use an ENable input so you can inhibit (disable) the motor if necessary.
I have no idea why the L298 should smoke but I CAN tell you that the two inputs you connected would not work
because there is no RETURN signal to the L298 for the input signals. The NodeMCU GND is NOT common to the
L298 and thus if you measure from the L298 GND (ALSO the 12V Batt GND) to either of those inputs coming from
the NodeMCU, you should NOT see a 0 to 5V TTL logic signal because the NodeMCE GND is NOT connected to the
L298 GND.  This is clearly a mistake. I would take that measurement to see what voltage you actually have on the
input pins of the L298. If they are 12V INSTEAD of 5V, that explains the smoke.
I realize that you are probably new to electronics, but I am obligated to advise you that connecting and powering
electronics BEFORE consulting electronics experts is unwise for a noob. It cannot end well.
This whole thread is about switching an actuator with relays until your last post where you inform us (AFTER the
FACT) that you tried the L298 . In retrospect, it would probably have been wiser to post your miswired fritzing for
that circuit BEFORE turning on the power. This is especially true when using such a powerful power source (12V
Battery) that is capable of delivery high levels of current.
Measure the voltage from the L298 GND to IN3 & IN4 and post the results. Then replace the L298 and make sure
to connect the L298 GND to whatever MCU used to input the input signals, as they have no meaning without a
return. I would also recommend adding the ENB connection from a NodeMCU output. FYI, an EMO (Emergency
Motor OFF) panic button can be wired using a Normally Open contact (instead of the standard N.C.) that connects the ENB input to the L298 GND, such that pressing the EMO asserts a logic LOW on the ENB input of the L298.
An EMO wired in Normally Closed mode between the 12V battery and the L298 motor power input would not
work for the simple reason the EMO switch would immediately burn up with 2A of motor current going through
it. (I'm explaining this for your benefit since everyone on the forum already knows this)

 I would also disconnect the battery and measure continuity from the buck converter input GND to the buck
converter Out - to see if they are connected.




Southpark

#49
Jan 14, 2021, 08:13 pm Last Edit: Jan 14, 2021, 08:45 pm by Southpark
Joat ------ I posted information earlier regarding the 5V Enable jumper section.

In your diagram that you showed, it looks like there is no jumper that links the two pins of the "5VEN".

When the 5VEN jumper is CONNECTED, then the 5V terminal at the L298N terminal block will be an OUTPUT 5V voltage pin ...... an output, that could be used to supply something that requires 5V supply. Here, the 5V output is possible only because this configuration of the 5VEN pin activates the inbuilt 5V regular on the L298N module board. And your 12V supply basically is used as input to that regulator in order to get 5V at the 5V pin.

However, when the 5VEN jumper is DISconnected, then the 5V terminal of the L298N terminal block changes behaviour ...... where that terminal magically becomes an INPUT ....... which requires a 5V supply to be connected to the 5V terminal block pin in order to power the L298N's logic circuits.

In your diagram - the jumper is not present. For that configuration (as mentioned before) the 5V pin of the L298N board is an input pin ----- not an output pin.

I'm not assuming you've connected anything incorrectly ------ but just mentioning it. And for full details ------- read through those web links that I posted in my earlier post.

At the moment, your diagram has the NodeMCU's USB port (or something) not connected to anything. So I just assume that your NodeMCU Vin pin is not going to be supplying power to anything.

And the L298N out4 and out3 pins appear to be short-circuited in your diagram.


joatmon13

#50
Jan 14, 2021, 11:28 pm Last Edit: Jan 14, 2021, 11:32 pm by joatmon13
Ok Thank you for the input.

1)  I removed the 5v jumper on the L298N as the spec sheet advised if the 12v input is > 12V, then one should apply 5v separately, which I did from the buck converter. So I believe that this is correct, as my battery when charged is 12.8v.   
2) I will also add ground to 5v side of buck converter and Node MCU.
3)  I didn't connect the EN input, as I thought that this was only required for controlling motor speed. I gather from your posts that this is a mistake.   I will add in the input to EN on my circuit from the Node MCU and set to High when I want the motor on.  However, this leads me to question the supporting code.  Previously when using relays I was relying on the Linear Actuator to stop by its own internal limit switches.  If I set this EN high while the actuator is running, how will I know when to stop the motor, since there is no feedback loop? Or do I set this pin High at all times and use IN3 & IN4 to control directions?
4) I can not find any explanation what the purpose is for the two jumpers on the EN pins.

Here is the revised proposed wiring:-








Southpark

#51
Jan 15, 2021, 03:02 am Last Edit: Jan 15, 2021, 06:15 pm by Southpark
Joat ------- the direction control pins eg. In1 and In2 could (I think) actually be used to not only control the direction of the motor spinning, but could also be used to control the motor speed (using PWM applied to In1 or In2) ----- that's when a jumper is used to connect the ENA pin to 5 volt.

But ----- I think the more convenient way to control motor speed is to simply use In 1 and In2 pins for direction control only. And have NO jumper connected to the ENA pin. And apply PWM to the ENA pin for controlling motor speed.

There is a diagram at this link here that shows logic AND gates. LINK

If the ENA pin just so-happens to have a jumper that connects ENA to 5 volt, then the ENA pin would be at a logic 'high', which feeds one of the inputs to its AND gate. But removing the jumper from the ENA pin will then give us control of that ENA pin, which allows us to apply PWM to the ENA pin for controlling motor speed. This means that we can just leave it to In1 and In2 to control motor direction, and then simply focus on the ENA pin for controlling motor speed.

Naturally, if the ENA pin is merely tied to 5 volt only (ie. constant logic high voltage), then the motor would just have the full supply voltage applied (to the motor) ........ meaning we just get stuck with full speed. Instead ------ we have the option to NOT have ENA connected (via jumper) to 5V, so that other motor speeds can be generated by applying PWM waveforms to the ENA pin (if needed).

Also ------ if the ENA pin is tied to a low voltage permanently, then one of those inputs to the AND gate will remain at a logic low, so that AND gate would be permanently stuck with a zero voltage output. So the ENA pin is basically a master control pin. That is ---- if the ENA pin is permanently connected to a low voltage, then it pretty much prevents the motor from getting power to it (because the AND gate that drives a particular transistor will keep the base of the transistor permanently at zero volt) for the case where ENA is tied to zero volt.

Yosuncle

Your actuator is bad...OR, your battery is not as good as you expect/think...I have seen car batteries produce what looks like proper 12v (12.6v specifically) under test for voltage but have absolutely no amps available to draw from such that would power a motor...

since your original post indicates the relays seem to work as expected, and with the actuator disconnected the relays seem to produce the expected voltage (see above for complications with that), this leaves only the actuator left as the trouble...The wiring from the original post has some things of concern for production, but nothing that would prevent this from working as expected otherwise (on the relay side, not overall project). 

you can test the actuator directly from the battery by connecting the terminals one way, then reverse for backwards test. This should not be needed but is a good test nonetheless. (tests the battery and actuator at same time...)

The above is ONLY for the relay side of the actuator...Other wiring and coding would need to be analyzed to determine if others issues may be present. Limit switches, reed switch, pir sensor, etc, and coding may be somehow causing trouble for you when combined overall...Please post your entire code for analysis that I may be able to see if that is part of your trouble...but first raw test the actuator to see if it is bad somehow and the battery...

joatmon13

Evidently you still don't understand what the issue is with the GND.
raschemmel     Thank you for your comments and assistance. I have added in ground as suggested by you and others.   In fact if you look at my previous diagram I am tying ground from the L298N to 12v side and to 5v side of buck converter including the Node MCU ESP8266.  My comment did not make that clear.  So I hope I do understand the issue, but didn't communicate it precisely.  


What is not clear to me is why the actuator worked initially without the ground on 5v tied back to buck converter and Node MCU, albeit creating smoke from the L298N !!  I have installed a new L298N and decoupled feed to motor and Node MCU 8266.


Here is my new diagram, which I hope will work as expected:-


joatmon13

Your actuator is bad...OR, your battery is not as good as you expect/think...I have seen car batteries produce what looks like proper 12v (12.6v specifically) under test for voltage but have absolutely no amps available to draw from such that would power a motor...

since your original post indicates the relays seem to work as expected, and with the actuator disconnected the relays seem to produce the expected voltage (see above for complications with that), this leaves only the actuator left as the trouble...The wiring from the original post has some things of concern for production, but nothing that would prevent this from working as expected otherwise (on the relay side, not overall project).

you can test the actuator directly from the battery by connecting the terminals one way, then reverse for backwards test. This should not be needed but is a good test nonetheless. (tests the battery and actuator at same time...)

The above is ONLY for the relay side of the actuator...Other wiring and coding would need to be analyzed to determine if others issues may be present. Limit switches, reed switch, pir sensor, etc, and coding may be somehow causing trouble for you when combined overall...Please post your entire code for analysis that I may be able to see if that is part of your trouble...but first raw test the actuator to see if it is bad somehow and the battery...
Hi Yosuncle, Thank you for your comments.  I have frequently tested the actuator director to the battery to make sure it wasn't an issue with the battery. (a BMW motorcycle 12v lead acid 150Ah). I had also tried a 12v PSU, with same erratic results. 
When the actuator was running it was drawing about 2 amps and I kept the battery properly charged.  My understanding is that I burnt out the relay by not deploying flyback diodes on the feed from the relay to the actuator, which caused the relay to become unreliable.  I might try to dismantle it and see if the contacts are pitted. 
So I took onboard the recommendation to try using a L298N instead of the relays. I believe that the L298N has flyback protection onboard.    I have developed the code with the assistance of other contributors on a Finite State Machine and it seem to be working ok, outputting the correct signals to my relays.  I just now need to modify it to work for the L298N.
I will post updates.

raschemmel

#55
Jan 17, 2021, 05:54 pm Last Edit: Jan 17, 2021, 07:53 pm by raschemmel


Quote
What is not clear to me is why the actuator worked initially without the ground on 5v tied back to buck converter and Node MCU, albeit creating smoke from the L298N !!  
Measure the voltage on from the L298 GND to the L298 inputs on the BAD L298  (EXACTLY as it
was wired when it smoked)

Southpark

#56
Jan 17, 2021, 10:48 pm Last Edit: Jan 18, 2021, 08:18 am by Southpark
I ordered a bunch of L298N when I first started getting into the h-bridge modules.

The L298N are still pretty good though. Just got to make sure they're driven properly. Maybe just have the L298N unloaded (not connected to the motor). And then fire up the software and use a multimeter to ensure that all the voltages are doing what is expected. Such as if the software is set to make the motor go forward ----- then run the code, and see if the voltage across the relevant terminals are the correct voltage such as +12V. Then set the code for reverse direction ...... and measure again ...... to get -12V.

And the other thing is to ensure that the L298 doesn't have any limits exceeded from its specifications, such as peak current and/or continuous RMS type current ------ or power specs.

Go Up